-
Notifications
You must be signed in to change notification settings - Fork 72
/
EnumWindows++.ahk
101 lines (82 loc) · 2.29 KB
/
EnumWindows++.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
;get active window
WinGet, hWnd, ID, A
hWnd2 := DllCall("GetForegroundWindow", Ptr)
MsgBox, % hWnd "`r`n" Format("0x{:x}", hWnd2)
;window get class
WinGetClass, vWinClass, % "ahk_id " hWnd
vWinClass2 := ""
VarSetCapacity(vWinClass2, 261*2, 0)
DllCall("GetClassName", Ptr,hWnd, Str,vWinClass2, Int,261)
MsgBox, % vWinClass "`r`n" vWinClass2
;==============================
;list child windows (controls)
EnumFunc("", "c")
pEnumFunc := RegisterCallback("EnumFunc", "F", 2)
DllCall("EnumChildWindows", Ptr,hWnd, Ptr,pEnumFunc, Ptr,0)
vList := EnumFunc("", "r")
MsgBox, % StrSplit(vList, "`n").Length() "`n" vList
;list child windows (controls)
WinGet, vCtlList, ControlListHwnd, % "ahk_id " hWnd
vList := ""
Loop, Parse, vCtlList, `n
{
hCtl := A_LoopField
vList .= (hCtl+0) "`r`n"
}
vList := SubStr(vList, 1, -1)
MsgBox, % StrSplit(vList, "`n").Length() "`n" vList
;==============================
;list all windows
EnumFunc("", "c")
pEnumFunc := RegisterCallback("EnumFunc", "F", 2)
DllCall("EnumWindows", Ptr,pEnumFunc, Ptr,0)
vList := EnumFunc("", "r")
MsgBox, % StrSplit(vList, "`n").Length() "`n" vList
;list all windows
DetectHiddenWindows, On
WinGet, vWinList, List
vList := ""
Loop, % vWinList{
hWnd := vWinList%A_Index%
vList .= (hWnd+0) "`n"
}
vList := SubStr(vList, 1, -1)
MsgBox, % StrSplit(vList, "`n").Length() "`n" vList
;==============================
;list hidden windows
EnumFunc("", "c")
pEnumFunc := RegisterCallback("EnumFunc", "F", 2)
DllCall("EnumWindows", Ptr,pEnumFunc, Ptr,0)
vListAll := EnumFunc("", "r")
vList := ""
Loop, Parse, vListAll, % "`n"
{
if DllCall("user32\IsWindowVisible", Ptr,A_LoopField)
vList .= A_LoopField "`n"
}
vList := SubStr(vList, 1, -1)
MsgBox, % StrSplit(vList, "`n").Length() "`n" vList
;list hidden windows
DetectHiddenWindows, Off
WinGet, vWinList, List
vList := ""
Loop, % vWinList {
hWnd := vWinList%A_Index%
vList .= (hWnd+0) "`n"
}
vList := SubStr(vList, 1, -1)
MsgBox, % StrSplit(vList, "`n").Length() "`n" vList
;==============================
ExitApp
;==================================================
EnumFunc(hWnd, vMode) {
static vList
if (vMode = "c")
return vList := ""
else if (vMode = "r")
return RTrim(vList, "`n")
vList .= hWnd "`n"
return 1
}
;==================================================