littlebigman Posted June 22, 2023 Share Posted June 22, 2023 (edited) Hello, Just to keep the GUI open after doing stuff, I need to rerun a basic GUI loop. As an alternative to a Do/Until, I tried a ternary one-liner, but AutoIt doesn't like the syntax: ;So the app doesn't close after the for loop ;~ Do ;~ Sleep(10) ;~ Until GUIGetMsg() = $GUI_EVENT_CLOSE ;BAD (GUIGetMsg() = $GUI_EVENT_CLOSE) ? (Exit) : (Sleep(10)) ;BAD GUIGetMsg() = $GUI_EVENT_CLOSE ? Exit : Sleep(10) Is that syntax just impossible? Thank you. Edited June 22, 2023 by littlebigman Link to comment Share on other sites More sharing options...
Developers Jos Posted June 22, 2023 Developers Share Posted June 22, 2023 21 minutes ago, littlebigman said: Is that syntax just impossible? Not impossible, but for starters: Why do you think that a one line If or Ternary can replace a loop? You only test one time this way! 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. Link to comment Share on other sites More sharing options...
littlebigman Posted June 22, 2023 Author Share Posted June 22, 2023 Just because I was curious to see if it could be further shortened. Link to comment Share on other sites More sharing options...
Andreik Posted June 22, 2023 Share Posted June 22, 2023 What's the purpose? You still need the loop to keep you app running. This reminds me of this. Werty 1 When the words fail... music speaks. Link to comment Share on other sites More sharing options...
littlebigman Posted June 22, 2023 Author Share Posted June 22, 2023 Makes sense. So it's not a good idea Link to comment Share on other sites More sharing options...
Werty Posted June 22, 2023 Share Posted June 22, 2023 (edited) While GuiGetMsg() <> -3 And Sleep(10) WEnd Edited June 22, 2023 by Werty littlebigman 1 Some guy's script + some other guy's script = my script! Link to comment Share on other sites More sharing options...
Werty Posted June 25, 2023 Share Posted June 25, 2023 Hmm, according to "Oscar" on the german autoit forum, a guy worth listening to, the sleep isnt even necesary when using GuiGetMsg()... GUIGetMsg automatically creates sleeps (without mouse movement/keystrokes) to reduce the load on the processor. https://autoit.de/thread/88029-matrix-falling-code/?postID=710746#post710746 So... While GuiGetMsg()<>-3 WEnd ...should be enough. Some guy's script + some other guy's script = my script! Link to comment Share on other sites More sharing options...
Developers Jos Posted June 25, 2023 Developers Share Posted June 25, 2023 Guess Oscar read the helpfile as it is clearly defined how a msg loop works and no sleep() is needed : https://www.autoitscript.com/autoit3/docs/guiref/GUIRef_MessageLoopMode.htm It is actually discouraged to add any sleep(). 😉 littlebigman 1 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. Link to comment Share on other sites More sharing options...
Andreik Posted June 25, 2023 Share Posted June 25, 2023 26 minutes ago, Jos said: It is actually discouraged to add any sleep(). 😉 Just to prevent the GUI being unresponsive but this won't happen if you sleep just a few ms. I think for most people it's a habit to use the sleep in main loop. I know for years that GUIGetMsg() automatically idles the CPU and yet I still use that sleep most of the time. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Solution Werty Posted June 25, 2023 Solution Share Posted June 25, 2023 1 hour ago, Jos said: Guess Oscar read the helpfile as it is clearly defined how a msg loop works and no sleep() is needed : https://www.autoitscript.com/autoit3/docs/guiref/GUIRef_MessageLoopMode.htm It is actually discouraged to add any sleep(). 😉 yes, but you are aware of how many people actually reads the helpfile. Some guy's script + some other guy's script = my script! Link to comment Share on other sites More sharing options...
Developers Jos Posted June 25, 2023 Developers Share Posted June 25, 2023 1 minute ago, Werty said: yes, but you are aware of how many people actually reads the helpfile. Hardly anybody actually reads the whole page ever.... Only a few open it. Werty 1 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. 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