mcvetyty Posted February 22, 2007 Share Posted February 22, 2007 Can anyone assist me with this? I cannot seem to get _MouseTrap() to work with Client coordinates instead of absolute window coordinates? My code is simple, i basically am trying this: AutoItSetOption("MouseCoordMode", 2) _MouseTrap(80, 70) Except that seems to do coordinates 80,70 of the Screen, and not the client program... Is there a way to have MouseTrap use the client window coordinates? Thanks! Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 23, 2007 Moderators Share Posted February 23, 2007 The _MouseTrap() example in the help file does exactly that, traps in the client area of the GUI created using WinGetPos(). Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 23, 2007 Moderators Share Posted February 23, 2007 Guess you could always just mod a UDF around _MouseTrap() itself to make life easier (Not tested but once)HotKeySet('{ESC}', '_ExitNow') Dim $GUI, $coords[4], $msg $GUI = GUICreate("Mouse Trap Example", 392, 323) GUISetState() While 1 _MouseTrapClient($GUI, 80, 70) $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd _MouseTrap () Exit Func _MouseTrapClient($hWnd = '', $nXTopLeft = 0, $nYTopLeft = 0, $nXBottomRight = 0, $nYBottomRight = 0) If $hWnd = '' And $nXTopLeft = 0 And $nYTopLeft = 0 And $nXBottomRight = 0 And $nYBottomRight = 0 Then Return _MouseTrap() If Not IsHWnd($hWnd) And WinExists($hWnd) Then $hWnd = HWnd($hWnd) Local $aWPos = WinGetPos($hWnd) If IsArray($aWPos) Then If $nXBottomRight = 0 Then $nXBottomRight = $nXTopLeft If $nYBottomRight = 0 Then $nYBottomRight = $nYTopLeft Return _MouseTrap($aWPos[0] + $nXTopLeft, $aWPos[1] + $nYTopLeft, $aWPos[0] + $nXBottomRight, $aWPos[1] + $nYBottomRight) EndIf Return SetError(1, 0, '') EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
NBJ Posted October 17, 2008 Share Posted October 17, 2008 (edited) Or you could use the following function after moving the mouse to the position to be locked Cheers Wakido Func MouseTrapCurrent() Opt("MouseCoordMode",0) $local = MouseGetPos() _MouseTrap($local[0],$local[1]) Opt("MouseCoordMode",2) EndFunc Edited October 17, 2008 by NBJ Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 17, 2008 Moderators Share Posted October 17, 2008 (edited) Or you could use the following function after moving the mouse to the position to be locked Cheers Wakido Func MouseTrapCurrent() Opt("MouseCoordMode",0) $local = MouseGetPos() _MouseTrap($local[0],$local[1]) Opt("MouseCoordMode",2) EndFuncYou're serious? You revived a 20 month old thread for this. Edited October 17, 2008 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
NBJ Posted October 17, 2008 Share Posted October 17, 2008 You're serious? You revived a 20 month old thread for this.I posted a solution as the ones previously posted didn't work with Opt("MouseCoordMode",2)And for the sake of anyone who is using the Forums search functions for answers before re-posting questions, I thought it may be appropriate there was a working solution in this thread.I apologise if this is offensive.wakido Tomas10 1 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