Jump to content

Search the Community

Showing results for tags 'guigetcursorinfo'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. I was messing with a double window gui and found GUIGetCursorInfo() not to work as expected winhandle [optional] The handle of the window to use. If omitted the "current" window will be used. so what does "current" window mean its surely not the active window? In this case its the last created window I think the documentation should at least be: winhandle [optional] Windows handle as returned by GUICreate() (default is the previously used window). https://www.autoitscript.com/autoit3/docs/functions/GUIGetCursorInfo.htm #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) Global $g_idX1 = 0, $g_idY1 = 0, $g_idX2 = 0, $g_idY2 = 0 Global $g_idB1, $g_idB2 Global $hWnd1, $hWnd2 Example() Func Example() $hWnd1 = GUICreate("#1 Click to Get Pos", 400, 400, 100, 100) $g_idX1 = GUICtrlCreateLabel("0", 10, 10, 50) $g_idY1 = GUICtrlCreateLabel("0", 40, 10, 50) $g_idB1 = GUICtrlCreateButton("Window1", 10, 30) GUISetOnEvent($GUI_EVENT_CLOSE, _Exit, $hWnd1) GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, GetPos, $hWnd1) GUISetState(@SW_SHOW) $hWnd2 = GUICreate("#2 Click to Get Pos", 400, 400, 200, 200) $g_idX2 = GUICtrlCreateLabel("0", 10, 10, 50) $g_idY2 = GUICtrlCreateLabel("0", 40, 10, 50) $g_idB2 = GUICtrlCreateButton("Window2", 10, 30) GUISetOnEvent($GUI_EVENT_CLOSE, _Exit, $hWnd2) GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, GetPos, $hWnd2) GUISetState(@SW_SHOW) ; Loop Forever While 1 Sleep(100000) WEnd EndFunc ;==>Example Func GetPos() Local $hWndActive = WinActive("") Local $sWindow, $a $a = GUIGetCursorInfo() ;$a = GUIGetCursorInfo(WinActive(""));Works If @error Or Not IsArray($a) Then Local $a[5] = [-1, -1, -1, -1, -1] If $hWndActive = $hWnd1 Then $sWindow = "#1" GUICtrlSetData($g_idX1, $a[0]) GUICtrlSetData($g_idY1, $a[1]) ElseIf $hWndActive = $hWnd2 Then $sWindow = "#2" GUICtrlSetData($g_idX2, $a[0]) GUICtrlSetData($g_idY2, $a[1]) Else $sWindow = "N/A" EndIf ConsoleWrite("Window " & $sWindow & " is active" & @CRLF) If IsArray($a) Then ConsoleWrite("Control Id = " & $a[4] & @CRLF) EndFunc ;==>GetPos Func _Exit() GUIDelete() Exit EndFunc ;==>_Exit It goes on further to state Even thats not true, if so this should fail for window #2 instead you'd need to call GUISwitch ($hWnd1) Func GetPos() Local $hWndActive = WinActive("") Local $sWindow, $a ;$a = GUIGetCursorInfo() $a = GUIGetCursorInfo($hWnd1) ;$a = GUIGetCursorInfo(WinActive(""));Works If @error Or Not IsArray($a) Then Local $a[5] = [-1, -1, -1, -1, -1] If $hWndActive = $hWnd1 Then $sWindow = "#1" GUICtrlSetData($g_idX1, $a[0]) GUICtrlSetData($g_idY1, $a[1]) ElseIf $hWndActive = $hWnd2 Then $a = GUIGetCursorInfo() $sWindow = "#2" GUICtrlSetData($g_idX2, $a[0]) GUICtrlSetData($g_idY2, $a[1]) Else $sWindow = "N/A" EndIf ConsoleWrite("Window " & $sWindow & " is active" & @CRLF) If IsArray($a) Then ConsoleWrite("Control Id = " & $a[4] & @CRLF) EndFunc ;==>GetPos
×
×
  • Create New...