ウィンドウハンドル(固有のID)や一覧、プロセスIDなどを取得
WinGet, OutputVar [, Cmd, WinTitle, WinText, ExcludeTitle, ExcludeText]
| 引数名 | 説明 |
|---|---|
| OutputVar | 結果を格納する変数名 |
| Cmd | 何を取得するかを指定。省略時は「ID」。詳しくは下記参照。 |
| WinTitle | ウィンドウタイトルなど。 ウィンドウ指定の方法参照。 |
| WinText | ウィンドウに含まれるテキスト |
| ExcludeTitle | 除外タイトル |
| ExcludeText | 除外テキスト |
ウィンドウハンドルは16進数の形式で取得される。
取得したハンドルは、ウィンドウ関連コマンドのWinTitleを指定するところで「ahk_id %OutputVar%」というようにして使用できる。
マウスカーソルの下のウィンドウのハンドルを取得するには、MouseGetPosコマンドを使う。
WinGetClass, WinGetTitle, MouseGetPos, GroupAdd
WinGet, active_id, ID, A WinMaximize, ahk_id %active_id% MsgBox, The active window's ID is "%active_id%".
; This next example will visit all open windows and display info
; about each of them:
WinGet, id, list, , , Program Manager
Loop, %id%
{
StringTrimRight, this_id, id%a_index%, 0
WinActivate, ahk_id %this_id%
WinGetClass, this_class, ahk_id %this_id%
WinGetTitle, this_title, ahk_id %this_id%
MsgBox, 4, , Visiting All Windows`n%a_index% of %id%`nahk_id %this_id%`nahk_class %this_class%`n%this_title%`n`nContinue?
IfMsgBox, NO, break
}
Example #3: Extract the individual control names from a ControlList:
WinGet, ActiveControlList, ControlList, A
Loop, Parse, ActiveControlList, `n
{
MsgBox, 4,, Control #%a_index% is "%A_LoopField%". Continue?
IfMsgBox, No
break
}
Example #4: Display in real time the active window's control list:
#Persistent
SetTimer, WatchActiveWindow, 200
return
WatchActiveWindow:
WinGet, ControlList, ControlList, A
ToolTip, %ControlList%
return