DongVo Posted January 24 Share Posted January 24 I am new in AutoIT and need help detect the Mouse Move position. If I move the mouse outside a Window region, the script will show a message that I have moved the mouse outside. Example: I have a Window region size is 640 x 480 pixel, If I move the mouse outside that one, the script will show a message. Link to comment Share on other sites More sharing options...
Solution ioa747 Posted January 24 Solution Share Posted January 24 1 #include <StaticConstants.au3> Local $MyGui = GUICreate("TaskPin GUI", 640, 480, -1, -1) GUICtrlCreateLabel("", 0, 0, 640, 480, $SS_GRAYFRAME) GUISetState(@SW_SHOW) MouseMove(@DesktopWidth / 2, @DesktopHeight / 2, 1) ;********************************** While 1 Switch GUIGetMsg() Case -3 ;$GUI_EVENT_CLOSE ExitLoop EndSwitch $aTrigger = GUIGetCursorInfo($MyGui) If $aTrigger[4] = 0 Then ConsoleWrite("mouse outside a Window region" & @CRLF) Sleep(10) WEnd ;********************************** 2 #include <StaticConstants.au3> Local $MyGui = GUICreate("TaskPin GUI", 640, 480, -1, -1) GUISetState(@SW_SHOW) MouseMove(@DesktopWidth / 2, @DesktopHeight / 2, 1) ;********************************** While 1 Switch GUIGetMsg() Case -3 ;$GUI_EVENT_CLOSE ExitLoop EndSwitch If Not IsMouseOverWin($MyGui) Then ConsoleWrite("mouse outside a Window region" & @CRLF) Sleep(10) WEnd ;********************************** Func IsMouseOverWin($hWnd) Local $aMPos = MouseGetPos() Local $aWPos = WinGetPos($hWnd) ;$aWPos[0]=Xposition ;$aWPos[1]=Yposition ;$aWPos[2]=Width ;$aWPos[3]=Height If $aMPos[0] > $aWPos[0] And $aMPos[1] > $aWPos[1] And $aMPos[0] < $aWPos[0] + $aWPos[2] And $aMPos[1] < $aWPos[1] + $aWPos[3] Then Return True EndIf Return False EndFunc ;==>IsMouseOverWin DongVo 1 I know that I know nothing Link to comment Share on other sites More sharing options...
DongVo Posted January 24 Author Share Posted January 24 Wao, perfectly ! Link to comment Share on other sites More sharing options...
Werty Posted January 25 Share Posted January 25 Compacted version of @ioa747's first one. #include <StaticConstants.au3> Local $MyGui = GUICreate("TaskPin GUI", 640, 480, -1, -1) GUICtrlCreateLabel("", 0, 0, 640, 480, $SS_GRAYFRAME) GUISetState(@SW_SHOW) MouseMove(@DesktopWidth / 2, @DesktopHeight / 2, 1) ;********************************** While GUIGetMsg() <> -3 ? GUIGetCursorInfo($MyGui)[4] = 0 ? ConsoleWrite("mouse outside a Window region" & @CRLF) : Sleep(10) : ExitLoop WEnd ;********************************** Some guy's script + some other guy's script = my script! 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