#SingleInstance Prompt
global WinGet, WindowList, List
; Get a list of all open windows
WinGet WindowList, List
; Loop through the list and display information about each window
Loop % WindowList %
{
; Get the window title and process name
this_id := WindowList%A_Index%
WinGetTitle Title, % "ahk_id " % this_id
WinGet ProcessName, ProcessName, % "ahk_id " % this_id
; Display information
MsgBox Window %A_Index% `nTitle %Title%`nProcess %ProcessName%
}
给予
我做错了什么?
错误的变量声明语法。
尝试:
#SingleInstance Prompt
global WindowList
; Get a list of all open windows
WinGet WindowList, List
; Loop through the list and display information about each window
Loop %WindowList%
{
; Get the window title and process name
this_id := WindowList%A_Index%
WinGetTitle Title, % "ahk_id " this_id
WinGet ProcessName, ProcessName,"ahk_id " %this_id%
; Display information
MsgBox Window %A_Index% `nTitle %Title%`nProcess %ProcessName%
}
自动热键 v1:
#Requires AutoHotkey v1.1
#SingleInstance Prompt
; Get a list of all open windows
WinGet, id, list,,, Program Manager
; Loop through the list and display information about each window
Loop, %id%
{
; Get the window title and process name
this_ID := id%A_Index%
WinGetTitle Title, ahk_id %this_ID%
WinGet ProcessName, ProcessName, ahk_id %this_ID%
; Display information
MsgBox Window %A_Index% `nTitle: %Title%`nProcess: %ProcessName%
}
https://www.autohotkey.com/docs/v1/lib/WinGet.htm
自动热键 v2:
#Requires AutoHotkey v2.0
#SingleInstance Prompt
; Get a list of all open windows
ids := WinGetList(,, "Program Manager")
for this_id in ids
{
; Get the window title and process name
title := WinGetTitle(this_id)
ProcessName := WinGetProcessName(this_id)
; Display information
MsgBox("Window " A_Index "`nTitle: " title "`nProcessName: " ProcessName)
}