Application Notes

5. Example AutoHotkey Scripts
5.a. Maestro Scripts
5.a.1. Toggle an LED
In this example, an LED is connected to channel 0. See Section 7.b of the Maestro Users Guide to see how to
connect an LED. Ctrl+Alt+C will turn the LED on, and Ctrl+Alt+B will turn the LED off.
^!c:: Run usccmd --servo 0`,8000,,Hide
^!b:: Run usccmd --servo 0`,0,,Hide
5.a.2. Start a Sequence
After making a sequence as described in Section 4.c of the Maestro Users Guide, use the Copy all Sequences
to Script button to save the sequences on the Maestro. You then can call the sequence by figuring out which
subroutine on the Script tab corresponds to your sequence. UscCmd needs to be given the number (NUM) of the
subroutine you want to call. To figure out the NUM of your subroutine, go to the Script tab and count the number
of subroutines that appear before the subroutine you want to call, the number you count is the subroutine you
want to call’s number (i.e. the first subroutine’s NUM is 0, the second is 1 and so on). Typing Ctrl+Alt+U runs
the subroutine whose NUM is 0.
^!u:: Run usccmd --sub 0,,Hide
5.a.3. Move a Servo
In the script below, Ctrl+Alt+C sets the servo’s target to near the end of its range. Ctrl+Alt+B sets the servo’s
target to near the other end of its range.
^!c::Run usccmd --servo 0`,7500,,Hide
^!b:: Run usccmd --servo 0`,4500,,Hide
In the script below, Ctrl+Alt+C will set the speed and acceleration of the servo on channel 0, then set its target to
near the end of its range. Ctrl+Alt+B will remove the speed and acceleration limits, then set the servo’s target to
near the other end of its range.
^!c::
RunWait usccmd --accel 0`,12,,Hide
RunWait usccmd --speed 0`,12,,Hide
Run usccmd --servo 0`,7500,,Hide
return
^!b::
RunWait usccmd --accel 0`,0,,Hide
RunWait usccmd --speed 0`,0,,Hide
Run usccmd --servo 0`,4500,,Hide
return
5.b. Simple Motor Controller Scripts
5.b.1. Control a Motor
Ctrl+Alt+C stops the motor, Ctrl+Alt+V sets the motor to go in the forward direction, Ctrl+Alt+B sets the motor
to go in the reverse direction,
^!c:: Run smccmd --brake 32,,Hide
^!v:: Run smccmd --resume --speed 1500,,Hide
^!b:: Run smccmd --resume --speed -1500,,Hide
5.c. Jrk Scripts
Application Note: Using AutoHotkey with Pololu USB Products © 2001–2011 Pololu Corporation
5. Example AutoHotkey Scripts Page 6 of 8