Jump to content
Sign in to follow this  
JBX028

GUISetOnEvent not working

Recommended Posts

JBX028

Hi,

I wrote the following script :

#include <GUIConstantsEx.au3>

Opt("WinTitleMatchMode", 2)
Opt("TrayAutoPause",0)
Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode 
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUISetState()

$msg = 0

While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()
    Sleep(1000)
Wend

Func _Exit()
    MsgBox(4096, "End", "End")
    Exit
Endfunc

But the messagebox is never displayed once i choosen "exit" in the tray.

Do you know what's wrong ?

Thanks in advance for your help

Johnny Baillargeaux

Share this post


Link to post
Share on other sites
furrycow

Problems i can see are:

1. You havent got a gui to close?

2. you dont use the whole $msg thing when using Opt("GUIOnEventMode", 1)

So the while loop you have would be:

While 1

Sleep(100); or something like this sleep time

WEnd

If you want to close it by the tray you would have to use Opt("TrayOnEventMode", 1)

#include <GUIConstantsEx.au3>

Opt("WinTitleMatchMode", 2)
Opt("TrayMenuMode",1)
Opt("TrayOnEventMode",1)
Opt("GUIOnEventMode", 1)  ; dont think you need this if you dont have a GUI.
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") ;leave this out if you are not going to use a GUI

$exit = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1,"_Exit")

GUISetState() ;again, you dont need this if youre not going to have a GUI

While 1
    Sleep(100)
WEnd

Func _Exit()
    MsgBox(4096, "End", "End")
    Exit
Endfunc
Edited by furrycow

Instant Lockerz Invite - www.instantlockerzinvite.co.uk

Share this post


Link to post
Share on other sites
JBX028

Hi,

Quick and perfect. Works perfectly.

You are right i made some confusions between GUI and tray. Now it's clear.

Thanks again for your prompt help.

Johnny Baillargeaux

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  

×