Having had the trial version, I finally coughed up and bought the full program of macro scheduler yesterday, and I would like to start using it efficiently,
I want to link a keystroke to a particular screen coordinate and a mouseclick, so that instead of moving the mouse, I can automatically click in one of three pre set screen positions, I have been trying this code;
OnEvent>KEY_DOWN,a,0,AnswerA
OnEvent>KEY_DOWN,s,0,AnswerB
OnEvent>KEY_DOWN,d,0,AnswerC
SRT>AnswerA
MouseMove>434,407
Lclick
END>AnswerA
SRT>AnswerB
MouseMove>673,406
Lclick
END>AnswerB
SRT>AnswerC
MouseMove>914,412
Lclick
END>AnswerC
Any help on how I can turn this into a script to run properly?
Thanks
MouseClick on a keystroke?
Moderators: JRL, Dorian (MJT support)
Glad you found the answer to your issue.
It bears mention that when you have an OnEvent set up for a key press, the subroutine associated with that key press will be executed over and over again the entire time you have the key depressed. You can't press and release a key fast enough to prevent the routine from executing 4 or 5 times. To prevent the activity of the subroutine from occurring repeatedly one can use a variable flag. I took your "a" press example and set it up so that the mousemove and left click will occurr only once while the "a" key is pressed. See the remarks for more explanation.
It bears mention that when you have an OnEvent set up for a key press, the subroutine associated with that key press will be executed over and over again the entire time you have the key depressed. You can't press and release a key fast enough to prevent the routine from executing 4 or 5 times. To prevent the activity of the subroutine from occurring repeatedly one can use a variable flag. I took your "a" press example and set it up so that the mousemove and left click will occurr only once while the "a" key is pressed. See the remarks for more explanation.
Code: Select all
OnEvent>KEY_DOWN,a,0,AnswerA
//A variable to be the flag
Let>Suppress_a_flag=0
SRT>AnswerA
//if the value of the flag is zero the rotine is executed
If>Suppress_a_flag=0
MouseMove>434,407
Lclick
EndIf
//Every time through the loop reset the flag to one
//The sub will continuously be called while the key is held
//but the flag must be zero for the routine to execute
//so the routine will not execute until the key is released and pressed again.
Let>Suppress_a_flag=1
END>AnswerA
Label>Loop
Wait>0.01
//The following if/endif routine will reset the flag back to
//zero soon after teh key is released
If>Suppress_a_flag>0
add>Suppress_a_flag,1
If>Suppress_a_flag>2
Let>Suppress_a_flag=0
EndIf
EndIf
Goto>Loop