Sign in to follow this  
Followers 0
slightly_abnormal

Close A Window When Mouse Loses Focus After A Few Seconds

3 posts in this topic

#1 ·  Posted (edited)

been trying this script to close itself if the window is not active in 5 seconds, it doesn't do that. it just freezes itself.. :)

#include <GuiConstants.au3>

$GUI = GuiCreate("Example",200,200,-1,-1)
GuiSetState()
_keepmouse()

while 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
sleep(100)
EndSelect
WEnd


Func _keepmouse()
Opt("wintitlematchmode",2)
if WinActive("Example") Then
Else
If NOT WinActive("Example") Then
sleep(5000)
Exit
EndIf
EndIf
EndFunc
Edited by slightly_abnormal

Share this post


Link to post
Share on other sites



#include <GuiConstants.au3>

$GUI = GUICreate("Example", 200, 200, -1, -1)
GUISetState()
$not_Active = 0
AdlibEnable("_keepmouse", 1000)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Sleep(100)
    EndSelect
WEnd


Func _keepmouse()
    Opt("wintitlematchmode", 2)
    If WinActive("Example") Then
        $not_Active = 0
    Else
        If Not WinActive("Example") Then
            $not_Active += 1
            If $not_Active = 5 Then Exit
        EndIf
    EndIf
EndFunc  ;==>_keepmouse


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

cool! thanks gary!

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