Jump to content

Recommended Posts

Posted

I have the impression that the traditional method for processing responses to a GUI is to assign variables to each GUICreateButton (or Pic) and then use Switch/Case/Endswitch to detect when any Control is clicked.  In the tutorials I've seen about Koda it appears to use this method, too.

While 1
    Global $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Pic2
            Call("verizon")
        Case $Pic3
            Call("skype")
        Case $PicExit
            Exit
    EndSwitch
WEnd

But in a few examples I've seen a script use a different method. The script always includes the following option near the top:

Opt("GUIOnEventMode", 1)

...and then, later, after creating each Control for the GUI, there's the function, GUICtrlSetOnEvent.  In these cases a very simple While/WEnd loop is used to wait for the user to respond. 

I happened to employ this second method in a recent script where I used "canned" controls (checkbox and buttons). Later in the same script I used the GuiCreatePic and Switch/Case/EndSwitch method because my GUI was all custom images. (I'm not sure if that's necessary, but it's what I've deduced.) The second GUI failed to respond to any mouse clicks, but eventually I figured out the cause was the GUIOnEvenMode being enabled at the top of the script.

This is when I realized I don't understand the reasoning behind choosing between these two methods. And I'm having no luck phrasing an appropriate search criterion. Is there an overview somewhere that explains the two methods and -- most importantly -- describes when each is appropriate?

Posted (edited)

I guess your search didn't include the HELP file.  It even goes so far as to suggest when one would be better than the other.

https://www.autoitscript.com/autoit3/docs/guiref/GUIRef.htm

 

Edited by TheXman
Posted

Thank you for pointing the way, though you guessed wrong. I did indeed search the HELP file but in my case the results were a haystack. I should've been more persistent and at least looked at every occurrence of "GUI Reference..."

5bfd9cce8ba73_Helpfileresults.JPG.6608d18f56acc4dbce2554a1b523938a.JPG

  • Developers
Posted
2 minutes ago, timmy2 said:

I did indeed search the HELP file but in my case the results were a haystack.

Not really when you simply use the TOC, select GUI Reference and then GUI Concept. ;)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted
1 hour ago, timmy2 said:

This is when I realized I don't understand the reasoning behind choosing between these two methods. And I'm having no luck phrasing an appropriate search criterion. Is there an overview somewhere that explains the two methods and -- most importantly -- describes when each is appropriate?

Your question was about event modes not controls.  Why would you search for GUI create when you want to know about GUI event modes. 

image.png.fee5b6481422d90c530af405d55aeb13.png

Posted
1 hour ago, TheXman said:

Your question was about event modes not controls.  Why would you search for GUI create when you want to know about GUI event modes. 

How right you are, @TheXman, if only I had started out knowing the subject is "event modes" instead of "controls". People like me should not be allowed to ask questions until they know such everyday terminology.

GUICreate was the first function that both methods have in common, and when one is grasping for a term to start with it was reasonable if futile starting point.

Posted
1 hour ago, Jos said:

Not really when you simply use the TOC, select GUI Reference and then GUI Concept. ;)

Jos

@jos, in this case the TOC would have been the best entry point. Not to excuse myself, but I'm just so accustomed to searching the forums and the HELP Index,  then following the breadcrumbs. This lesson learned. (in which case I always ask myself, "How many more are there?" :>)

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
×
×
  • Create New...