Donald8282 Posted October 28, 2010 Posted October 28, 2010 Hello, I have a problem in this code that I am making. I am not too good in using GUI but I think I'm ok at it. Please help. Case $msg = $stop $go = 0 $rec = 0 GUICtrlSetState($stop, $GUI_DISABLE) GUICtrlSetState($start, $GUI_ENABLE) GUICtrlSetState($playback, $GUI_ENABLE) GUICtrlSetData($recording, "Recording: Off Frame:" & $all1) Case $msg = $start $rec = 1 GUICtrlSetState($start, $GUI_DISABLE) GUICtrlSetState($stop, $GUI_ENABLE) GUICtrlSetState($playback, $GUI_DISABLE) While $rec = 1 $readx1 = FileRead("Mousex.txt") $splitx1 = StringSplit($readx1, ":") $all1 = $splitx1[0] $mpos = MouseGetPos() FileWrite("Mousex.txt", $mpos[0] & ":") FileWrite("Mousey.txt", $mpos[1] & ":") Sleep(27) GUICtrlSetData($recording, "Recording: On Frame:" & $all1) WEnd When I press "Start" it works perfectly but when I press "Stop" it seems like $rec stays at 1 and doesn't let me stop it. I tried it without While and just If $rec = 1 and that only let me do one frame. I need it so it will keep going but I will be able to stop it when I press stop. Is there a way to loop it like that?
Drifter Posted October 28, 2010 Posted October 28, 2010 check $msg in your while loop? seems like a hard problem indeed and i dont know if this will fix, but it seems to make sense. Your program is stuck in the while loop because you never set rec to 0. ONLY when the while loop ends can you check your cases again, this is why your code isnt allowing you to press stop.
Drifter Posted October 28, 2010 Posted October 28, 2010 you could remove $rec all together and the case $msg = $rec and then POSSIBLY have While Not ($msg = $stop) This should loop as long as the $msg is not $stop.
Donald8282 Posted October 28, 2010 Author Posted October 28, 2010 I do have $rec set as 0 =[ that's not all of the code of course.
Mison Posted October 28, 2010 Posted October 28, 2010 (edited) While $rec = 1 $readx1 = FileRead("Mousex.txt") $splitx1 = StringSplit($readx1, ":") $all1 = $splitx1[0] $mpos = MouseGetPos() FileWrite("Mousex.txt", $mpos[0] & ":") FileWrite("Mousey.txt", $mpos[1] & ":") Sleep(27) GUICtrlSetData($recording, "Recording: On Frame:" & $all1) Sleep(10) ;<-- recommended If GUIGetMsg() = $stop Then $rec = 0 ;<-- added line WEnd Assuming the value of $msg is of GUIGetMsg(), Edited October 28, 2010 by Mison Hi ;)
Drifter Posted October 28, 2010 Posted October 28, 2010 I do have $rec set as 0 =[ that's not all of the code of course. But you dont do it in the while loop. Your script will never read your clicking the stop button. the while loop needs to end first. This is why i am giving you alternate methods. You either need to set rec to 0 somehow or modify your while loop.
Donald8282 Posted October 28, 2010 Author Posted October 28, 2010 Drifter, If I gave you the whole source could you figure out a solution? This problem has been killing me practically all day and I can't get it to work. You seem like you could find a solution to this problem a lot faster than I could.
Donald8282 Posted October 28, 2010 Author Posted October 28, 2010 Mison, thank you so much. It worked!
AlmarM Posted October 28, 2010 Posted October 28, 2010 You would like to record and playback mouse movement/clicks?Take a look into my signature. _Mouse UDF. Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.
Zibit Posted October 28, 2010 Posted October 28, 2010 (edited) if you push start before then it will not function if you push stop. the loop you have in start is inifinite. ExitLoop function. add these there. $msg = GUIGetMsg() if $msg = $stop then exitloop endif and i see while $rec = 1 you have to declare a new variable -> $rec <- so it could exit the loop so thats how its infinite. Edited October 28, 2010 by Zibit Creator Of Xtreme DevelopersPixel Pattern UDFTray GUI UDFMathssend & recive register scriptMouse Control via Webcam
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