zivt Posted June 23, 2010 Share Posted June 23, 2010 Hi, during loop of while or For , events of GUISetOnEvent (functions) are not implimented. the call to the events are made at the end of the loop. is there any way to check if event happenes during the loop? Thanks, Ziv Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 23, 2010 Share Posted June 23, 2010 Have you changed Opt("GuiOnEventMode", 1)? If that doesn't fix it, please post a short demo script showing your issue. 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...
zivt Posted June 24, 2010 Author Share Posted June 24, 2010 #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode ; GUI $DlgHnd= GuiCreate("My App", @DesktopWidth-50,@DesktopHeight-50,0,0) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISetState(@SW_SHOW) ; Menu local $FileMenue = GUICtrlCreateMenu("File") local $DoMyWhile = GUICtrlCreateMenuItem("Do_While", $FileMenue) GUICtrlSetOnEvent($DoMyWhile , "MyWhile") While 1 WEnd Func CLOSEClicked() Exit EndFunc Func MyWhile() While 1 WEnd EndFunc Affter pressing "Do_While" menu option , try to close the dialog (Press the "X"). dialog "CLOSEClicked" evenet will not started. Thanks, Ziv Link to comment Share on other sites More sharing options...
enaiman Posted June 24, 2010 Share Posted June 24, 2010 What do you think this code is doing? While 1 WEnd No sleep in-between = 100% CPU Utilization While 1/WEnd = infinite loop What's the purpose of this piece of code? Of manually starting a While loop? If you want a loop started manually, at least put something to break the loop, otherwise your script will hang everytime. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
zivt Posted June 24, 2010 Author Share Posted June 24, 2010 I added sleep to the example of 1sec to the while , still the event is not started. This is just an example... the real application is read a long file... Bottom line: Sleep is not fix this issue. Link to comment Share on other sites More sharing options...
zivt Posted June 24, 2010 Author Share Posted June 24, 2010 Do you have any idea? Link to comment Share on other sites More sharing options...
zivt Posted June 24, 2010 Author Share Posted June 24, 2010 During function event , other events are waiting for the function to finish. is it bug? is there a workaround for this issue? Thanks, Ziv Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 24, 2010 Share Posted June 24, 2010 Never put time consuming stuff or blocking functions (i.e. MsgBox()) inside an event handling function. Further event processing is blocked until each event is finished. An event function should be minimalist and fast in returning to the main loop: #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Global $hDlgHnd, $idFileMenue, $idDoMyWhile, $idLabel, $f_Run = False, $iCount = 0 ; GUI $hDlgHnd = GUICreate("My App", @DesktopWidth - 50, @DesktopHeight - 50, 0, 0) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") ; Menu $idFileMenue = GUICtrlCreateMenu("File") $idDoMyWhile = GUICtrlCreateMenuItem("Do_While", $idFileMenue) GUICtrlSetOnEvent($idDoMyWhile, "MyWhile") ; Label $idLabel = GUICtrlCreateLabel("Count = " & $iCount, 20, 20, 200, 20) ; Main loop GUISetState(@SW_SHOW) While 1 Sleep(100) If $f_Run Then $iCount += 1 ControlSetText($hDlgHnd, "", $idLabel, "Count = " & $iCount) EndIf WEnd Func CLOSEClicked() Exit EndFunc ;==>CLOSEClicked Func MyWhile() $f_Run = Not $f_Run EndFunc ;==>MyWhile 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...
zivt Posted June 24, 2010 Author Share Posted June 24, 2010 OK, Thats what i thought. Thanks, Ziv 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