For those of you who do not want to make a Gui when your script start, because you may not need it...
I may be going against the grain here...
But I have a script that may not ever use a Gui... and when it does, it is a one time use, and discarded.
All the examples for Gui's I have seen create the Gui at the start of the script, and then the script is Gui driven. There are occasions when one does not want to do that.
So how then, to call the Gui later... As soon as you show the Gui, it "returns" to the point from which it is called, before the user has been able to use it.
I believe what it does then is fall back into itself if there is no code below the calling point, or executes the next line of code after the point of the Gui being called.
More or less, standard Gosub operation... except for the problem of not being able to use the Gui where you want it.
I looked all over for a remedy to this, but found nothing. Then when I realized how it was behaving, and thought of the answer... Control when it falls.
It works like this.. when you want the Gui, you Gosub to a Gui Maker routine, which resides immediately above the actual Gui.
It calls the Gui... and if the user is not finished with the Gui, it continues to "fall" back into the Gui. When the user is finished (determined by a variable set by operating the Gui), the GuiMaker subroutine returns control back to line in the script immediately after it's call.
The Guru's almost certainly have a better way to do it, but this works for me.
Code: Select all
;line of script
;line of script
Gosub Gui_Maker_Subroutine
Gui_Maker_Subroutine:
Gui_Used=0 ;Set the Flag used to Determine if the User is Finished with the Gui
Gosub The_Gui
Loop ;The Check must be in a loop or else it will fail
{
If (Gui_Used)
return
}
The_Gui:
Gui, Add, Button, gButton_Action
Gui, Show
return
Button_Action:
Gui_Used=1 ;If the action of the Button should close the Gui, Set the Flag
; Your Gui Action Here
Gui, Destroy ; Since the whole idea is that you will not need this Gui again, destroy it, and free up resources
return
Guru's, please let me know how you do it. Thanks
Code: Select all