Advertisement
Dr_Mon

Get Info Window

May 26th, 2020
1,076
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.49 KB | None | 0 0
  1. #include <WinAPI.au3>
  2. #include <WindowsConstants.au3>
  3.  
  4. AdlibRegister("_Mouse_Win_GetInfoAdlib", 10)
  5.  
  6. While 1
  7.     ConsoleWrite("Start Sleep" & @CRLF)
  8.     Sleep(0x7FFFFFFF)
  9. WEnd
  10.  
  11. Func _Mouse_Win_GetInfoAdlib()
  12.     Local $a_info = _Mouse_Win_GetInfo()
  13.     If @error Then Return
  14.  
  15.     ToolTip("Window Handle = " & $a_info[0] & @CRLF & _
  16.             "Window Title = " & $a_info[1] & @CRLF & _
  17.             "Control Handle = " & $a_info[2] & @CRLF & _
  18.             "Control Class = " & $a_info[3] & @CRLF & _
  19.             "Mouse X Pos = " & $a_info[4] & @CRLF & _
  20.             "Mouse Y Pos = " & $a_info[5])
  21. EndFunc   ;==>_Mouse_Win_GetInfoAdlib
  22.  
  23. Func _Mouse_Win_GetInfo()
  24.     Local $structCoords, $a_mpos, $hWnd, $hControl, $sClass
  25.     $structCoords = DllStructCreate($tagPOINT) ; Build Structure
  26.     $a_mpos = MouseGetPos() ; Get Mouse Position
  27.     If @error Then Return SetError(1, 0, 0)
  28.  
  29.     DllStructSetData($structCoords, "X", $a_mpos[0]) ; Populate Structure
  30.     DllStructSetData($structCoords, "Y", $a_mpos[1]) ; Populate Structure
  31.     $hControl = _WinAPI_WindowFromPoint($structCoords) ; Identify Window
  32.     If Not $hControl Then Return SetError(2, 0, 0)
  33.  
  34.     $hWnd = _WinAPI_GetAncestor($hControl, $GA_ROOTOWNER); Get Parent Window
  35.     $sClass = _WinAPI_GetClassName($hControl) ; Get Control Class
  36.     If Not $hWnd Then Return SetError(3, 0, 0)
  37.  
  38.     Local $a_ret[6] = [$hWnd, WinGetTitle($hWnd), $hControl, $sClass, $a_mpos[0], $a_mpos[1]]
  39.     Return $a_ret
  40. EndFunc   ;==>_Mouse_Win_GetInfo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement