Newbie help with Maestro and Autohotkey while key pressed?

Hi, i’m trying to figure out if I can use Autohotkey with a Maestro to control 1 continuous servo in this way :

I would like to be able to use the Left and right arrow keyboard keys to do this :

While the left or right arrow are pressed it moves the servo in either direction at a fast set speed.
When pressing Alt+left or right arrow are pressed it moves the servo in either direction at a slower speed.

Now when I let go of the key it stops the servo. That’s the part i’m not sure about?

Can this be done, that it detect that the key is pressed and stays pressed? Then when i let go of the key it send a stop command?

Thanks for any help or suggestions!

Cryoteck

Hello.

The “Repeating a series of actions over and over” section of the AutoHotkey tutorial shows how to set actions while a key is being held down. You should be able to use this to have the Maestro control a continuous rotation servo using inputs from your keyboard as you described.

-Brandon

Hi Brandon,

Thank you very much, i’ll look into it and let you know how it works out!

I’ll post my results, on the forum.

Thanks again,

~Cryoteck

Ok here it is so far.

Using F6 to move slow in one direction
Alt+F6 move faster
F8 move slow in the other direction
Alt+F8 move faster
F7 stop

Now the values used may be different for your servo, mine is a continuous.

It works pretty good like this. Will try to modify the code to use the detection of the key pressed in or not and report back.

[size=85]moveservo.ahk :

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

$F6::
RunWait usccmd --accel 0,0,,Hide RunWait usccmd --speed 0,0,Hide
Run usccmd --servo 0`,6138,Hide
return

$F7::
RunWait usccmd --accel 0,0,,Hide RunWait usccmd --speed 0,0,Hide
Run usccmd --servo 0`,6200,Hide
return

$F8::
RunWait usccmd --accel 0,0,,Hide RunWait usccmd --speed 0,0,Hide
Run usccmd --servo 0`,6370,Hide
return

!$F6::
RunWait usccmd --accel 0,0,,Hide RunWait usccmd --speed 0,5,Hide
Run usccmd --servo 0`,6100,Hide
return

!$F8::
RunWait usccmd --accel 0,0,,Hide RunWait usccmd --speed 0,5,Hide
Run usccmd --servo 0`,6400,Hide
return[/size]