Processor Posted February 5, 2013 Posted February 5, 2013 (edited) Hi, When I launch this script I can't close the gui because of the high value of the sleep. I just want the message box appear every 4sec and be able to kill the gui when I want. Anybody has an idea? thx by advance for your help. Gui() Func Gui() Local $msg GUICreate("My GUI") GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop $count = 2 while $count > 0 msg("toto","titi") sleep(4000) WEnd WEnd GUIDelete() EndFunc Func msg($x,$y) msgbox("","",$x & $y) end func Processor Edited February 5, 2013 by Processor
Moderators Melba23 Posted February 5, 2013 Moderators Posted February 5, 2013 Processor, I would do it like this: #include <GUIConstantsEx.au3> Gui() Func Gui() GUICreate("My GUI") GUISetState(@SW_SHOW) $count = 2 While $count > 0 msg("toto", "titi") $count -= 1 $iBegin = TimerInit() Do If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop EndIf Until TimerDiff($iBegin) > 4000 WEnd GUIDelete() EndFunc ;==>Gui Func msg($x, $y) MsgBox("", "", $x & $y) EndFunc ;==>msg Please ask if you have any questions. M23 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
kylomas Posted February 5, 2013 Posted February 5, 2013 (edited) Processor, It's not the sleep, you are stuck in the while loop kylomas edit: Hi, M23 - quicker than quick Edited February 5, 2013 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
ileandros Posted February 5, 2013 Posted February 5, 2013 If you want to keep your first script, add the the $msg in the while $count loop. Didn't tested it but that should work. P.s your code is bad written. I feel nothing.It feels great.
Processor Posted February 5, 2013 Author Posted February 5, 2013 I know that is the while loop that is blocking me, but without the sleep or with a very short one I can exit the loop. Melba you idea is good but in fact my while is not while $count > 0 but while 1 so I have to exit 2 loops, is there any way to kill 2 loops in 1 time?
kylomas Posted February 5, 2013 Posted February 5, 2013 Processor, You are processing messages ( guigetmsg() ) in your outer loop so it should not be a problem. What's wrong with M23's suggestion? Did you try it? kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
Processor Posted February 5, 2013 Author Posted February 5, 2013 (edited) I answer myself exitloop(2) save me.Thanks you all Melba23 once again you saved me.If you want to keep your first script, add the the $msg in the while $count loop.Didn't tested it but that should work.P.s your code is bad written.It's a resume of what I'm really doing, the real code is worst, you should see!! Edited February 5, 2013 by Processor
Moderators Melba23 Posted February 5, 2013 Moderators Posted February 5, 2013 Processor,the real code is worst, you should see!!If your code is really that bad, you are not going to get much help here as most people will not bother to struggle to understand large chunks of complicated code unless it is structured and has at least some comments. So I would start trying to do both those things, if I were you. M23 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
Processor Posted February 5, 2013 Author Posted February 5, 2013 (edited) Hi Melba23, It was a joke, of course the complete code is structured and I put all comments I can in it. Whatever I won't put the whole code here. I try before to understand what's blocking and sum it in a short code like in this post. It's more efficiant because, as you said people don't have time to struggle with chunks of complicated code even commented it could be a pain. (even if how I use autoi is quite simple). At least, I repeat thx all for your help! Edited February 5, 2013 by Processor
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