KaFu Posted June 18, 2009 Share Posted June 18, 2009 For sure , but here's my little example... needed the func for an app. expandcollapse popup#include <WinAPI.au3> #include <WindowsConstants.au3> #include<GUIConstants.au3> Opt('GuiOnEventMode', 1) $hGui = GUICreate("hWnd, PID and Exe under cursor", 350, 67, 244, 160, BitOR($WS_POPUP, $WS_BORDER, $WS_SIZEBOX), BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $label = GUICtrlCreateLabel("", 0, 0, 350, 200, 0, $GUI_WS_EX_PARENTDRAG) GUICtrlSetBkColor(-1, 0xEEF1F6) GUICtrlSetColor(-1, 0x000000) GUISetState(@SW_SHOW) While Sleep(50) $hWndCtrl = HWnd(_WindowFromPoint()) $hWndWin = _WinAPI_GetAncestor($hWndCtrl, $GA_ROOTOWNER) $hWndPid = WinGetProcess($hWndWin) $hWndExeLoc = _ProcessGetLocation($hWndPid) $hWndExe = StringRight($hWndExeLoc, StringLen($hWndExeLoc) - StringInStr($hWndExeLoc, "\", 0, -1)) GUICtrlSetData($label, "$hWndCtrl " & @TAB & $hWndCtrl & @CRLF _ & "$hWndWin " & @TAB & $hWndWin & @CRLF _ & "$hWndPid " & @TAB & $hWndPid & @CRLF _ & "$hWndExe " & @TAB & $hWndExe & @CRLF _ & "$hWndExeLoc " & @TAB & $hWndExeLoc) WEnd Func _WindowFromPoint() ; from _GUICtrl_SetOnHover ; http://www.autoitscript.com/forum/index.php?s=&showtopic=55120 ; by G.Sandler a.k.a MrCreatoR (CreatoR's Lab, http://creator-lab.ucoz.ru) Local $Old_Opt_MCM = Opt("MouseCoordMode", 1) Local $aRet = DllCall("User32.dll", "int", "WindowFromPoint", _ "long", MouseGetPos(0), _ "long", MouseGetPos(1)) ;$aRet = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $aRet[0]) Opt("MouseCoordMode", $Old_Opt_MCM) Return $aRet[0] EndFunc ;==>_WindowFromPoint Func _ProcessGetLocation($iPID) Local $aProc = DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $iPID) If $aProc[0] = 0 Then Return SetError(1, 0, '') Local $vStruct = DllStructCreate('int[1024]') DllCall('psapi.dll', 'int', 'EnumProcessModules', 'hwnd', $aProc[0], 'ptr', DllStructGetPtr($vStruct), 'int', DllStructGetSize($vStruct), 'int_ptr', 0) Local $aReturn = DllCall('psapi.dll', 'int', 'GetModuleFileNameEx', 'hwnd', $aProc[0], 'int', DllStructGetData($vStruct, 1), 'str', '', 'int', 2048) If StringLen($aReturn[3]) = 0 Then Return SetError(2, 0, '') Return $aReturn[3] EndFunc ;==>_ProcessGetLocation Func _Exit() Exit EndFunc ;==>_Exit Fubarable and mLipok 2 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Andreik Posted June 19, 2009 Share Posted June 19, 2009 Nice example. I like it. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now