Cusem Posted August 29, 2007 Share Posted August 29, 2007 (edited) Hi all, I have the following code (just a portion): What it does is check if there are files in a certain folder and if there are files, those files will be parsed by the HHParser function(not posted). Then the script is idle for 60 seconds and starts all over again. This all works fine. I also have a GUI which is enabled by a hotkey. If I fire up the GUI right now, the posted below portion of the script will be "paused", since there is a [While 1][WEnd] loop in the code for the GUI to. Is there a way to keep the code below running even though I am starting another [While 1][WEnd] loop for the button-trapping of the gui? While 1 If $parsechk = 1 Then $search = FileFindFirstFile($hh_everestpath & "*.*") If $parsechk = 1 Then While 1 $fileparse = FileFindNextFile($search) If @error Then ExitLoop HHParser($fileparse) GUICtrlSetData($parsedinput, $parsedfiles) WEnd EndIf If $parsechk = 1 Then $timera = TimerInit() While 1 Sleep(100) If TimerDiff($timera) > (1000 * 60) Then ExitLoop WEnd EndIf WEnd Edited August 29, 2007 by Cusem Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 29, 2007 Share Posted August 29, 2007 Use GuiOnEventMode instead of a GuiGetMsg() loop for your GUI. Your script can go back to what it was doing and will be interrupted if there are configured GUI events. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Cusem Posted August 29, 2007 Author Share Posted August 29, 2007 Use GuiOnEventMode instead of a GuiGetMsg() loop for your GUI. Your script can go back to what it was doing and will be interrupted if there are configured GUI events. Thank you PsaltyDS.At this moment I worked out the problem by placing the $msg = GuiGetMsg() within the first loop (posted in the first post), since i didn't wan't to rewrite a lot in the script, but thank you for the tip. I'll look into it. Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 29, 2007 Share Posted August 29, 2007 Thank you PsaltyDS.At this moment I worked out the problem by placing the $msg = GuiGetMsg() within the first loop (posted in the first post), since i didn't wan't to rewrite a lot in the script, but thank you for the tip. I'll look into it.If that woks, that's good enough! The more general problem with it is that your GUI is only as responsive as THAT loop now, and the GUI doesn't work at all if you exit THAT loop. If the loop is pretty fast and you don't need the GUI outside of it then no harm done, but that is why I would push GuiOnEventMode when you rewrite someday, or for your next script. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Cusem Posted August 30, 2007 Author Share Posted August 30, 2007 (edited) Well, eventually I did started rewriting the script in order to use OnEvent's. With the GuiGetMsg, the script was lagging a bit and the GuiCtrlSetOnEvent's really do work smoother. Only one thing, I used to have code like: Case $msg = $Button_1 TableReorder(1) Case $msg = $Button_2 TableReorder(2) etc. But GuiCtrlSetOnEvent($Button_1, "TablReorder(1)") does not work. Is there a way to give variables to the function when calling the function through GuiCtrlSetOnEvent? And also, when not using OnEvents yet, I had code like this: Case $msg = $parsecheckbox And BitAND(GuiCtrlRead($parsecheckbox), $GUI_CHECKED) = $GUI_CHECKED and Case $msg = $radio1 And BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED How can I get these things to work with OnEvent commands? I tried GUICtrlSetOnEvent($parsecheckbox AND BitAND(GuiCtrlRead($parsecheckbox), $GUI_CHECKED) = $GUI_CHECKED, "HHParserOn") But this doesn't seem to work. Edited August 30, 2007 by Cusem Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 30, 2007 Share Posted August 30, 2007 (edited) Well, eventually I did started rewriting the script in order to use OnEvent's. With the GuiGetMsg, the script was lagging a bit and the GuiCtrlSetOnEvent's really do work smoother. Only one thing, I used to have code like: Case $msg = $Button_1 TableReorder(1) Case $msg = $Button_2 TableReorder(2) etc. But GuiCtrlSetOnEvent($Button_1, "TablReorder(1)") does not work. Is there a way to give variables to the function when calling the function through GuiCtrlSetOnEvent? And also, when not using OnEvents yet, I had code like this: Case $msg = $parsecheckbox And BitAND(GuiCtrlRead($parsecheckbox), $GUI_CHECKED) = $GUI_CHECKED and Case $msg = $radio1 And BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED How can I get these things to work with OnEvent commands? I tried GUICtrlSetOnEvent($parsecheckbox AND BitAND(GuiCtrlRead($parsecheckbox), $GUI_CHECKED) = $GUI_CHECKED, "HHParserOn") But this doesn't seem to work. You can't pass any parameters at all in the function called by the event. But there are certain macros that carry useful info like @GUI_CTRLID, @GUI_CTRLHANDLE, and @GUI_WINHANDLE: GuiCtrlSetOnEvent($Button_1, "TablReorder") GuiCtrlSetOnEvent($Button_2, "TablReorder") GUICtrlSetOnEvent($parsecheckbox, "HHParserOn") Func TablReorder() Switch @GUI_CTRLID Case $Button_1 ; Do button 1 stuff Case $Button_2 ; Do button 2 stuff EndSwitch EndFunc Func HHParserOn() If BitAND(GuiCtrlRead($parsecheckbox), $GUI_CHECKED) = $GUI_CHECKED Then ; Do checked stuff Else ; Do unchecked stuff EndIf EndFunc Edit: Forgot to address second part in the code. Edited August 30, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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