-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathWinGetAll (2).ahk
53 lines (53 loc) · 1.51 KB
/
WinGetAll (2).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
WinGetAll(Which="Title", DetectHidden="Off"){
O_DHW := A_DetectHiddenWindows, O_BL := A_BatchLines ;Save original states
DetectHiddenWindows, % (DetectHidden != "off" && DetectHidden) ? "on" : "off"
SetBatchLines, -1
WinGet, all, list ;get all hwnd
If (Which="Title") ;return Window Titles
{
Loop, %all%
{
WinGetTitle, WTitle, % "ahk_id " all%A_Index%
If WTitle ;Prevent to get blank titles
Output .= WTitle "`n"
}
}
Else If (Which="Process") ;return Process Names
{
Loop, %all%
{
WinGet, PName, ProcessName, % "ahk_id " all%A_Index%
Output .= PName "`n"
}
}
Else If (Which="Class") ;return Window Classes
{
Loop, %all%
{
WinGetClass, WClass, % "ahk_id " all%A_Index%
Output .= WClass "`n"
}
}
Else If (Which="hwnd") ;return Window Handles (Unique ID)
{
Loop, %all%
Output .= all%A_Index% "`n"
}
Else If (Which="PID") ;return Process Identifiers
{
Loop, %all%
{
WinGet, PID, PID, % "ahk_id " all%A_Index%
Output .= PID "`n"
}
Sort, Output, U N ;numeric order and remove duplicates
}
DetectHiddenWindows, %O_DHW% ;back to original state
SetBatchLines, %O_BL% ;back to original state
Sort, Output, U ;remove duplicates
arr:=[]
loop,parse,output,`n
if (trim(a_loopfield)!="")
arr.insert("" a_loopfield)
return arr
}