Jump to content

Help with $GUI_EVENT_?

Recommended Posts

I am a real noob here, but I have searched for something like this and can't find it...

I have a GUI that I would like to close when it loses focus. There is not a GUI constant for this in GUIConstantsEx.au3, so is there a way to capture this event? For example, it would look something like:

If $msg = $GUI_EVENT_LOSEFOCUS Then ExitLoop

Thank you for your help!


Link to comment
Share on other sites

#include <GUIConstants.au3>

$GUI = GUICreate("Close if focus is lost", 400, 400)
While 1
    If Not WinActive($GUI) Then
    $nMsg = GUIGetMsg()
    If $nMsg = $GUI_EVENT_CLOSE Then
This works "sort of". Because it's not a windows event, you have to click another window and hold it long enough to have the GUI loop one more time for it to tell that it's no longer active. If you don't hold the click long-enough, my GUI just takes the focus again and keeps on going.
Link to comment
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...