jeffonce Posted June 24, 2016 Share Posted June 24, 2016 Hello there, I'm new on this language and I'm currently learning about gui, controls, events, ... So, in a basic gui (using setupgui for example), I asked myself: what would happen if the user trigger two (or more) events at the same time ? I mean, I'm using an infinite loop to check events, so, theoretically, if I click a button, the defined action must be executed 'instantly' before anything else happens. OK, but let's imagine a supersayen user click the button1, then 'instantly' (before the "select loop" runs) click button2, what happens? Logically, as I understood the "GUIGetMsg" function, this one should return the control ID of the last control (here, a button) used/clicked. Well, it's not clearly explained in the help file, so that's how I explain it rationally.... BUT, to be sure, I added a pause at the very start of the infinite loop. First, I've set the pause delay to 1000ms, and what happened is a ~10s delay before the action related to my button would happens... Wow! Mindfuck for me ! What is happening ? Trying to find an explanation, I added a counter in my loop, and wow, the loop runs 27 times before doing anything ! And after this, all the actions are executed, like if they were retarded, butt kept in memory.... So, can anyone please tell me what's happening ? If it wasn't clear enough, tell me, but I'm sure it's simple to explain.... :/ Anyway I continue my 'training' because as for now, this 'problem' isn't really disturbing (except for my brain lol) Thank you for reading my noob story Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 24, 2016 Moderators Share Posted June 24, 2016 jeffonce, Welcome to the AutoIt forums. Firstly, there is no need to add a Sleep within the GUIGetMsg loop - the function has its own built-in delay of ~12ms to allow the CPU to breathe and adding a further pause just makes the GUI less responsive. Next, the events that occur within the GUI are queued and dealt with in order, so you will see this sort of thing: 000ms - Start of loop 015ms - If no events, GUIGetMsg returns 0 ... - This continues until an event occurs 600ms - An event occurs and the event value (I.e. a button ControlID) is returned by GUIGetMsg. Whatever code is within that Case section of the loop is now actioned Let us say it takes 200ms to run, but another control is actioned within that time 800ms - Once back in the loop, GUIGetMsg returns the next event value. Note that the Case code for this event only runs now, not at the time the event actually occurred if you want code to run immediately the event occurs, then you need to look at HotKeys, Windows message handlers, and the like which do not depend on the main idle loop of the script. I hope that helps - please ask again if you still have questions. M23 jeffonce 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
jeffonce Posted June 24, 2016 Author Share Posted June 24, 2016 Ooh okay ! So, events are simply queud and treated one by one ? In other words, "GUIGetMsg" doesn't simply return the controlID of last control used, but will remember what control were used and tell these one by one at each call ? I'm glad your understood me :D, thank you very much! Link to comment Share on other sites More sharing options...
AutoBert Posted June 24, 2016 Share Posted June 24, 2016 Quote AutoIt queues function calls in both OnEvent and MessageLoop modes. This means that it waits until a function is finished and the code is back in your idle While...WEnd loop before running the next. from: https://www.autoitscript.com/wiki/Interrupting_a_running_function For understanding the diference of OnEvent and MessageLoop mode read https://www.autoitscript.com/autoit3/docs/guiref/GUIRef.htm jeffonce 1 Link to comment Share on other sites More sharing options...
jeffonce Posted June 24, 2016 Author Share Posted June 24, 2016 That's complete, thank you both guys nb: i can't edit my post, but i think it's 'resolved'. have a nice day Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now