RazorTorque4X Posted February 25, 2010 Share Posted February 25, 2010 Ok, so this is the thing first I declare a variable and set it to false $var = False then after some code I create a GUI and a button, on clicking which, the $var will toggle. $gui = GUICreate("whatever",coordinates go here) $button = GUICtrlCreateButton("Toggle",coordinates here) $slider = GUICtrlCreateSlider(whatever coordinates) GUICtrlSetLimit(-1,200,1) Now, I loop in a while loop to check if the button is clicked and depending on state of $var (which will be toggled by our button) it updates a slider. while 1 $nMsg = GUIgetmsg() If $nMsg = $button Then $var = NOT $var EndIf ;Now here I update a slider depending the status of $var If $var Then Dim $temp = 0 ;here the problematic issue starts while 1 $temp +=1 GUICtrlsetdata($slider, $temp) sleep(1000) Wend else GUICtrlsetdata($slider, 200) $temp = 200 while 1 $temp -=1 GUICtrlsetdata($slider, $temp) sleep(1000) Wend EndIf Wend So, this is the problem, when at first the $var is False the if condition will be executed and the slider will update every second, but even if I click on button the else condition won't execute, and the reason is quite logical that its polling through the loop that's why no other action is taken into account that is outside of loop. Atleast this is what I think! So, How should I look if button is clicked or not when I am polling in a loop? Link to comment Share on other sites More sharing options...
Valuater Posted February 25, 2010 Share Posted February 25, 2010 (edited) This will help, however, you will not be able to pole the button until the loop is complete $Action = False While 1 $nMsg = GUIGetMsg() If $nMsg = $button Then $var = Not $var $Action = True EndIf ;Now here I update a slider depending the status of $var If $Action Then If $var Then For $temp = 0 To 200 GUICtrlSetData($slider, $temp) Sleep(1000) Next Else GUICtrlSetData($slider, 200) For $temp = 0 To 200 GUICtrlSetData($slider, $temp) Sleep(1000) Next EndIf $Action = False EndIf WEnd If you use "On-Event" mode, the button action will be received 8) Edited February 25, 2010 by Valuater Link to comment Share on other sites More sharing options...
RazorTorque4X Posted February 25, 2010 Author Share Posted February 25, 2010 If you use "On-Event" mode, the button action will be receivedThanks for that, I'll try it and see if it gets me what I want !But is there anything related to threading that is supported by autoit, because if it so I can start two threads one for main while loop and other to update the slider, and they can work consistently. Is there a way I can implement it? 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