-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathGetProcessThreads.ahk
27 lines (21 loc) · 1.31 KB
/
GetProcessThreads.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
; ===============================================================================================================================
; Gets a list of threads in a process
; ===============================================================================================================================
GetProcessThreads(ProcessID)
{
if !(hSnapshot := DllCall("CreateToolhelp32Snapshot", "uint", 0x4, "uint", ProcessID))
throw Exception("CreateToolhelp32Snapshot", -1)
NumPut(VarSetCapacity(THREADENTRY32, 28, 0), THREADENTRY32, "uint")
if !(DllCall("Thread32First", "ptr", hSnapshot, "ptr", &THREADENTRY32))
throw Exception("Thread32First", -1), DllCall("CloseHandle", "ptr", hSnapshot)
Threads := []
while (DllCall("Thread32Next", "ptr", hSnapshot, "ptr", &THREADENTRY32))
if (NumGet(THREADENTRY32, 12, "uint") = ProcessID)
Threads.Push(NumGet(THREADENTRY32, 8, "uint"))
return Threads, DllCall("CloseHandle", "ptr", hSnapshot)
}
; ===============================================================================================================================
OwnPID := DllCall("GetCurrentProcessId")
for k, v in GetProcessThreads(OwnPID)
MsgBox % "ThreadID:`t`t" v
; ThreadID: 6408 | 7112 | 11052 | 4760