0
votes

I'm trying to run some macrio which allow me emulate Left MOuse Button click until Left mouse button is pressed. But i don't know how to force script to stop when I physical release Left mouse button and start sript again once LButton is pressed again. My code looks like this:

SetTimer, keyStates, 100

LeftClick:="LButton"
KeyStates: ; SubRoutine
if GetKeyState(LeftClick, "P") {
            DllCall("mouse_event", uint, 4, int, x, int, y, uint, 0, int, 0)
            Sleep 75
            DllCall("mouse_event", uint, 2, int, 0, int, 0, uint, 0, int, 0)
            Sleep 75
            DllCall("mouse_event", uint, 4, int, x, int, y, uint, 0, int, 0)
            Sleep 75
            DllCall("mouse_event", uint, 2, int, 0, int, 0, uint, 0, int, 0)
            Sleep 75
            DllCall("mouse_event", uint, 4, int, x, int, y, uint, 0, int, 0)
            Sleep 75
            DllCall("mouse_event", uint, 2, int, 0, int, 0, uint, 0, int, 0)
            Sleep 75
            DllCall("mouse_event", uint, 4, int, x, int, y, uint, 0, int, 0)
            Sleep 75
            DllCall("mouse_event", uint, 2, int, 0, int, 0, uint, 0, int, 0)
            Sleep 75
            DllCall("mouse_event", uint, 4, int, x, int, y, uint, 0, int, 0)
            Sleep 75
            DllCall("mouse_event", uint, 2, int, 0, int, 0, uint, 0, int, 0)
            Sleep 75        
        }
    }

I'm complete new in this scripting language so i would be thankful for any help

1
It is still a bit unclear to me what you want to achieve: as far as I understand it right now you want to start a 'clicking loop' at the first physical left button click and stop that loop after doing the second physical left button click, right? - DAXaholic
No clicking loop when i physically hold left click. When I release left click it needs stop the loop - LukeJ
Now it is even more confusing for me :) No clicking loop when you hold the button but when you release it it should stop - how should it stop when it never started? - DAXaholic
OMG :) how can I say it simpler. The loop needs to be active (clicking) only when I press and hold left mouse button. When I stop script stops... - LukeJ
Well your last statement is simply contradictory -> "No clicking loop when you hold the button" and now "The loop needs to be active (clicking) only when I press and hold left mouse button" - DAXaholic

1 Answers

0
votes

Your code doesn't compile because the last closing bracket, }, doesn't have a cooresponding opening bracket. Remove it.

Add the line:

#Persistent

at the top of the script, so the program won't close immediately.

With those corrections the program works.