Sign in to follow this  
Followers 0
plastix

Non-modal Gui / Prevent Script Pauses...

3 posts in this topic

Hopefully i have my modal / non-modal the right way round :) I have modified tray icon to call a function when a given item is selected [ TrayItemSetOnEvent(-1,"Info") ]. "Info" creates a GUI which displays some information - but in itself (at present) has no additional functionality (ie no buttons etc etc). The only thing the form needs to do is be able to be closed down... I have a standard

While 1
 $msg = GuiGetMsg()
 Select
 Case $msg = $GUI_EVENT_CLOSE
  ExitLoop
 EndSelect
WEnd
GUIDelete($Form1)
...loop running. The problem I am having is that when the GUI is displayed, the script stays in the loop within the function, and doesn't run the main system loop with all the monitoring functuality...

Can a GUI be displayed who's "close" event can be triggered from outside a loop, maybe by the 'ObjEvent' method, or some other means of creating a handle-listener that will close the GUI when the close event occurs, but lets the script continue running in the meantime ?? (I looked on search - there are some examples of GUIs enabling / disabling each other, but these are still within their own loops etc...)

TIA :mellow:

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Have you looked at Opt(GUIOnEventMode, 1)? Instead of using the main loop just to use the one exit call, you could use it to call your functions instead. Then use something like:

GUISetOnEvent($GUI_EVENT_CLOSE, 'EXITSCRIPT')
Func EXITSCRIPT()
    EXIT
EndFunc

Edit:

This is how I am understanding your question I think:

#include <GUICONSTANTS.AU3>
Opt('GUIONEVENTMODE', 1)
Opt('TRAYONEVENTMODE', 1)
Opt("TrayMenuMode",1)

$MAIN_GUI = GUICreate('SOME GUI')
GUISetOnEvent($GUI_EVENT_CLOSE, 'EXITSCRIPT', $MAIN_GUI)

$EVENT1 = TrayCreateItem('RUN NOTEPAD')
TrayItemSetOnEvent($EVENT1, 'RUNNOTEPAD')

TraySetState()
GUISetState()

While 1
    Sleep(1000)
;DO ALL MY FUNCTION CALLS HERE IN THIS MAIN LOOP
WEnd

Func RUNNOTEPAD()
    Run('NOTEPAD.EXE')
EndFunc

Func EXITSCRIPT()
    Exit
EndFunc
Edited by SmOke_N

[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 SmOke_N

The idea was close... the difference is that there isn't a Main GUI - the only GUI (at the moment) is an info sheet that i wanted to display without stopping the flow of the main loop waiting for the window to be closed... but I declared the GUI a global object & used the GUIONEVENTMODE Opt. The GUI is created in its function call, and I used GUISetOnEvent within the function to set up event (as you suggested). A seperate function closes the GUI as it is now global.

Works nicely. Many thanks :)

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