Sign in to follow this  
Followers 0
Donald8282

Mouse movement capture problem

11 posts in this topic

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?

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

I do have $rec set as 0 =[ that's not all of the code of course.

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by Mison

Hi ;)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Mison, thank you so much. It worked!

Share this post


Link to post
Share on other sites

My pleasure. ;)


Hi ;)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#11 ·  Posted (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 by Zibit

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0