let WndID = GetIDByWindow(hWnd)
Das passiert, wenn man das Bsp. nicht testet:
Code
{
...
"severity": 8,
"message": "redefinition of 'WndID'; previous declaration here: c:\\Users\\ghost\\NIM\\@BugFix\\GetIDByWindow.nim(6, 3)\r\n\r\n",
...
}
Code
# Ermitteln von Process-ID und Thread-ID eines Fensters
include winim/[inc\winuser]
type
WndID = object
pid, tid: int
proc GetIDByWindow(hWnd: HWND): WndID =
# determines the process and thread ID by a window handle
# returns the object type "WndID" with .pid & .tid
# requires: include winim/[inc\winuser]
var
pPID: LPDWORD
pTID = GetWindowThreadProcessId(hWnd, cast[LPDWORD](addr pPID))
result = WndID(pid: cast[int](pPID), tid: cast[int](pTID))
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Example
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
var
wndName = newWideCString(r"M:\AutoIt\Cursor.au3 - SciTE [22 von 22]", 4096)
hWnd = FindWindowW(nil, cast[LPCWSTR](wndName))
let id = GetIDByWindow(hWnd)
echo "Process-ID = ", id.pid
echo "Thread-ID = ", id.tid
echo "Process-ID only = ", GetIDByWindow(hWnd).pid
echo "Thread-ID only = ", GetIDByWindow(hWnd).tid
#[
Process-ID = 16140
Thread-ID = 11472
Process-ID only = 16140
Thread-ID only = 11472
]#
Alles anzeigen
Tags: <Process ID>, <PID>, <Thread ID>