Sign in to follow this  
Followers 0
WTS

detect if mouse not in win coords..

9 posts in this topic

#1 ·  Posted (edited)

#include <GUIConstants.au3>
$Form1 = GUICreate("AForm1", 622, 447, 194, 152)
GUISetState(@SW_SHOW)

While 1
    $WinPos = WinGetPos($Form1)
    $MousePos = MouseGetPos()
    
    If $MousePos[0] <> $WinPos[0] Or $MousePos[1] <> $WinPos[1] Then NotOnGui()
        
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
;;;;;;;
    EndSelect
WEnd
Exit

Func NotOnGui()
    Msgbox(0,'Not','Out of pos')
EndFunc

Hello This code should detect if mouse move of the gui, then do a function.. what am I not doing right?

Edited by WTS

Share this post


Link to post
Share on other sites



If $MousePos[0] < $WinPos[0] Or _
        $MousePos[0] > $WinPos[0] + $WinPos[2] Or _
        $MousePos[1] < $WinPos[1] Or _
        $MousePos[1] > $WinPos[1] + $WinPos[3] Then NotOnGui()


[center]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.[/center]

Share this post


Link to post
Share on other sites

Thanks!

Do you know how to implement a timer function? lets say I move the mouse off the gui, it counts down lets say for 3 seconds and then does NotOnGui, but the count down resets if I have the mouse back on the GUI before it reaches 3 seconds..

Share this post


Link to post
Share on other sites

Thanks!

Do you know how to implement a timer function? lets say I move the mouse off the gui, it counts down lets say for 3 seconds and then does NotOnGui, but the count down resets if I have the mouse back on the GUI before it reaches 3 seconds..

Yes...

[center]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.[/center]

Share this post


Link to post
Share on other sites

Well that was no fun, you asked if I knew how, I said yes, and you left it alone :yawn:

#include <GUIConstants.au3>
Global $TimerStart = 0
$Form1 = GUICreate("AForm1", 622, 447, 194, 152)
GUISetState(@SW_SHOW)

While 1
    Local $WinPos = WinGetPos($Form1)
    Local $MousePos = MouseGetPos()
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
    If $MousePos[0] < $WinPos[0] Or _
        $MousePos[0] > $WinPos[0] + $WinPos[2] Or _
        $MousePos[1] < $WinPos[1] Or _
        $MousePos[1] > $WinPos[1] + $WinPos[3] Then
        If $TimerStart == 0 Then $TimerStart = TimerInit()
        NotOnGui(3)
    Else
        $TimerStart = 0
    EndIf
    Sleep(10)
WEnd
Exit

Func NotOnGui($TimeLapse)
    If TimerDiff($TimerStart) / 1000 >= $TimeLapse Then
        MsgBox(64, 'Info:', 'You were outside the GUI for ' & $TimeLapse & ' seconds or more.')
    EndIf
EndFunc
Is one way...


[center]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.[/center]

Share this post


Link to post
Share on other sites

SmOke_N, you're crazy.

Thanks I needed that.

Share this post


Link to post
Share on other sites

sorry.. I was busy watching my sister, thanks again..

Share this post


Link to post
Share on other sites

sorry.. I was busy watching my sister, thanks again..

Hmmm :D

[center]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.[/center]

Share this post


Link to post
Share on other sites

sorry.. I was busy watching my sister, thanks again..

LOL doing what :D:wacko::D


[s]Autoit[/s]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0