Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: swindow focus WinGetActive GetGUIThreadInfo
#DefineFunction udfGetGUIThreadInfo () ; BOOL WINAPI GetGUIThreadInfo( ; _In_ DWORD idThread, ; _Inout_ LPGUITHREADINFO lpgui ;); ;typedef struct tagGUITHREADINFO { ; DWORD cbSize; 4 0 ; DWORD flags; 4 4 ; HWND hwndActive; 4 8 ; HWND hwndFocus; 4 12 ; HWND hwndCapture; 4 16 ; HWND hwndMenuOwner; 4 20 ; HWND hwndMoveSize; 4 24 ; HWND hwndCaret; 4 28 ; RECT rcCaret; 16 32 ;} GUITHREADINFO, *PGUITHREADINFO; bufGUITHREADINFO = BinaryAlloc(48) ;Note that you must set the cbSize member to sizeof(GUITHREADINFO) before calling this function. BinaryPoke4( bufGUITHREADINFO, 0, 48 ) ret = DllCall(DirWindows(1):"user32.dll", long:"GetGUIThreadInfo", lpnull,lpbinary:bufGUITHREADINFO) If ret == 0 Pause('GetGUIThreadInfo Failed', DllLastError()) Exit;Return 0 Endif hwndActive = BinaryPeek4( bufGUITHREADINFO, 8 ) hwndFocus = BinaryPeek4( bufGUITHREADINFO, 12 ) Binaryfree(bufGUITHREADINFO) ;Window With FOCUS Return hwndFocus #EndFunction BoxOpen('Get Window with Focus','Press Alt+F12 to get the window handle of the window with focus') While WaitForKey('!{F12}','','','','') hwndFocus = udfGetGUIThreadInfo() Pause('Focused Window Handle',hwndFocus) EndWhile Exit
Article ID: W17791
Filename: Get Window with Focus.txt
File Created: 2014:01:07:15:06:00
Last Updated: 2014:01:07:15:06:00