Discovering Autohotkey
2 posters
Discovering Autohotkey
Sorry for the long post, but I'm a geek and I can't always help myself. I also wanted to
share just in case there is anyone else who could find this useful for work.
At work, I'm responsible for extracting message protocol requirements from a large PDF
document and placing them in an online database. Basically a lot of copy and
pasting. From there I create test steps to make sure the requirements are being met.
Since many of the steps are the same from test to test I find myself doing more copy
and pasting.
Like water, I try to find the most efficient route from a to b, so I added a spreadsheet
document to the process. Even more copy and pasting, but being able to edit and manipulte
the requirements and tests in a spreadsheet saves a lot of time in the end.
Moving all this information around is tedious and repetitive work so I set out to find
a software solution to automate the process.
At first I used HID Macros, a little program that allows you assign a lot of keystrokes
to a single key on a secondary keyboard. The biggest drawback is that it only has 1 speed,
fast, and often it would send the next keystroke before Windows could complete the current
task, like atl-tabbing between programs. My solution was to break the string of commands
up into several keystrokes. This worked but it wasn't automatic as I still had to sit
there and press the same 4,5 or 6 keys, in sequence, over and over. The other problem is I
was quickly running out of keys so I had to create and juggle several profiles because
only 1 instance of HID Macros can be running at a time.
A couple of weeks ago I stumbled across autohotkey. Like HID Macros I could assign several
keystrokes to a single key, but I could also assign them to a key combination such as
ctrl-alt-q as well as use abbreviations such as "ide003" to generate "G2S_IDE003 Device
Disabled by Host". The best part is, it is actually a scripting language with some powerful
commands, the least of which being "sleep" which allows me to add pauses in the appropiate
places so Windows or the web can keep up. Using an input box and a loop command I can tell
Autohotkey I have 12 steps for a particular test case and watch as it copies and pastes,
repeating the same series of keystrokes 12 times and then save at the end.
Best of all it's absolutely free.
Since I use a web data base I can't alway select the proper field with just keyboard
commands, so I started researching mouse commands when I learned that AHK could also read
joystick inputs.
The reason I'm posting this here is that after a few hours of research and planning, I was
able to create 3 simple scripts for Cliffs of Dover.
- an analog fuel cock so that each position in game is represented by a
position of the throttle axis on my joystick.
- an H shifter for the gear and flaps which I control with my old joystick.
- and antilock toe brakes which increases the number of brake commands/sec the harder I press
the pedal. I'm still tweaking this because the rollout is too long. I'm thinking
instead of several commands/sec, just 1 held longer the harder I step down.
I'm looking ahead to creating dials for the gunsight and cockpit lighting as well compass
and gyro. The last two wont be easy since AHK only recognizes 100 steps/axis and I'm going
to need 360.
http://www.autohotkey.com/ is the website and it fully supports users with tutorials,
scripts, documentation and a user forum.
I know I'm not the first to discover AHK as I've seen it mentioned lots of times in flight
sim forums, but I had no idea how powerful it could be in the hands of a new user using simple
script commands.
StiC
share just in case there is anyone else who could find this useful for work.
At work, I'm responsible for extracting message protocol requirements from a large PDF
document and placing them in an online database. Basically a lot of copy and
pasting. From there I create test steps to make sure the requirements are being met.
Since many of the steps are the same from test to test I find myself doing more copy
and pasting.
Like water, I try to find the most efficient route from a to b, so I added a spreadsheet
document to the process. Even more copy and pasting, but being able to edit and manipulte
the requirements and tests in a spreadsheet saves a lot of time in the end.
Moving all this information around is tedious and repetitive work so I set out to find
a software solution to automate the process.
At first I used HID Macros, a little program that allows you assign a lot of keystrokes
to a single key on a secondary keyboard. The biggest drawback is that it only has 1 speed,
fast, and often it would send the next keystroke before Windows could complete the current
task, like atl-tabbing between programs. My solution was to break the string of commands
up into several keystrokes. This worked but it wasn't automatic as I still had to sit
there and press the same 4,5 or 6 keys, in sequence, over and over. The other problem is I
was quickly running out of keys so I had to create and juggle several profiles because
only 1 instance of HID Macros can be running at a time.
A couple of weeks ago I stumbled across autohotkey. Like HID Macros I could assign several
keystrokes to a single key, but I could also assign them to a key combination such as
ctrl-alt-q as well as use abbreviations such as "ide003" to generate "G2S_IDE003 Device
Disabled by Host". The best part is, it is actually a scripting language with some powerful
commands, the least of which being "sleep" which allows me to add pauses in the appropiate
places so Windows or the web can keep up. Using an input box and a loop command I can tell
Autohotkey I have 12 steps for a particular test case and watch as it copies and pastes,
repeating the same series of keystrokes 12 times and then save at the end.
Best of all it's absolutely free.
Since I use a web data base I can't alway select the proper field with just keyboard
commands, so I started researching mouse commands when I learned that AHK could also read
joystick inputs.
The reason I'm posting this here is that after a few hours of research and planning, I was
able to create 3 simple scripts for Cliffs of Dover.
- an analog fuel cock so that each position in game is represented by a
position of the throttle axis on my joystick.
- an H shifter for the gear and flaps which I control with my old joystick.
- and antilock toe brakes which increases the number of brake commands/sec the harder I press
the pedal. I'm still tweaking this because the rollout is too long. I'm thinking
instead of several commands/sec, just 1 held longer the harder I step down.
I'm looking ahead to creating dials for the gunsight and cockpit lighting as well compass
and gyro. The last two wont be easy since AHK only recognizes 100 steps/axis and I'm going
to need 360.
http://www.autohotkey.com/ is the website and it fully supports users with tutorials,
scripts, documentation and a user forum.
I know I'm not the first to discover AHK as I've seen it mentioned lots of times in flight
sim forums, but I had no idea how powerful it could be in the hands of a new user using simple
script commands.
StiC
StiC- Warrant Officer
- Posts : 908
Join date : 2012-02-27
Age : 54
Location : Cape Breton Island
Re: Discovering Autohotkey
BRILLIANT StiC. I know you mentioned it the other night, but I had no idea of the particulars. Great work! I'll spread the word about it and hope to get some people over here to the forum to see your results.
Fuel Cock Script
This test script will help locate a particular axis for using the Fuel Cock Script
http://www.autohotkey.com/docs/scripts/JoystickTest.htm
It's supposed to automatically detect and report all sticks but I had to change my joystick number manually until I found the one I needed.
Just replace my "1joyz" with whatever results you get.
As you can see I used S and A for my Fuel Cock Next/Previous inputs.
Off:
GetKeyState, 1joyz, 1joyz
if 1joyz < 25
{
goto off
}
else
{
send s
goto on
}
on:
GetKeyState, 1joyz, 1joyz
if 1joyz < 25
{
send a
goto off
}
if 1joyz > 75
{
send s
goto reserve
}
else
{
goto on
}
reserve:
GetKeyState, 1joyz, 1joyz
if 1joyz > 75
{
goto reserve
}
else
{
send a
goto on
}
StiC
http://www.autohotkey.com/docs/scripts/JoystickTest.htm
It's supposed to automatically detect and report all sticks but I had to change my joystick number manually until I found the one I needed.
Just replace my "1joyz" with whatever results you get.
As you can see I used S and A for my Fuel Cock Next/Previous inputs.
Off:
GetKeyState, 1joyz, 1joyz
if 1joyz < 25
{
goto off
}
else
{
send s
goto on
}
on:
GetKeyState, 1joyz, 1joyz
if 1joyz < 25
{
send a
goto off
}
if 1joyz > 75
{
send s
goto reserve
}
else
{
goto on
}
reserve:
GetKeyState, 1joyz, 1joyz
if 1joyz > 75
{
goto reserve
}
else
{
send a
goto on
}
StiC
StiC- Warrant Officer
- Posts : 908
Join date : 2012-02-27
Age : 54
Location : Cape Breton Island
H-shifter
;For this one you need two axis. I use an old joystick.
neutral:
sleep 1000 ;Adjustable time buffer to get stick back to neutral position.
getkeystate, 3joyz, 3joyz
if 3joyz < 25
{
goto gear
}
if 3joyz > 75
{
goto flaps
}
else
{
goto neutral
}
gear:
getkeystate, 3joyr, 3joyr
if 3joyr < 25
{
goto gearup
}
if 3joyr > 75
{
goto geardn
}
else
{
goto gear
}
flaps:
getkeystate, 3joyr, 3joyr
if 3joyr < 25
{
goto flapsup
}
if 3joyr > 75
{
goto flapsdn
}
else
{
goto flaps
}
gearup:
getkeystate, 3joyr, 3joyr
if 3joyr < 25
{
send g
goto gearup
}
else
{
send b
goto neutral
}
geardn:
getkeystate, 3joyr, 3joyr
if 3joyr > 75
{
send b
goto geardn
}
else
{
send g
goto neutral
}
flapsup:
getkeystate, 3joyr, 3joyr
if 3joyr < 25
{
send f
goto flapsup
}
else
{
send v
goto neutral
}
flapsdn:
getkeystate, 3joyr, 3joyr
if 3joyr > 75
{
send v
goto flapsdn
}
else
{
send f
goto neutral
}
neutral:
sleep 1000 ;Adjustable time buffer to get stick back to neutral position.
getkeystate, 3joyz, 3joyz
if 3joyz < 25
{
goto gear
}
if 3joyz > 75
{
goto flaps
}
else
{
goto neutral
}
gear:
getkeystate, 3joyr, 3joyr
if 3joyr < 25
{
goto gearup
}
if 3joyr > 75
{
goto geardn
}
else
{
goto gear
}
flaps:
getkeystate, 3joyr, 3joyr
if 3joyr < 25
{
goto flapsup
}
if 3joyr > 75
{
goto flapsdn
}
else
{
goto flaps
}
gearup:
getkeystate, 3joyr, 3joyr
if 3joyr < 25
{
send g
goto gearup
}
else
{
send b
goto neutral
}
geardn:
getkeystate, 3joyr, 3joyr
if 3joyr > 75
{
send b
goto geardn
}
else
{
send g
goto neutral
}
flapsup:
getkeystate, 3joyr, 3joyr
if 3joyr < 25
{
send f
goto flapsup
}
else
{
send v
goto neutral
}
flapsdn:
getkeystate, 3joyr, 3joyr
if 3joyr > 75
{
send v
goto flapsdn
}
else
{
send f
goto neutral
}
Last edited by StiC on Sun May 05, 2013 7:24 am; edited 1 time in total
StiC- Warrant Officer
- Posts : 908
Join date : 2012-02-27
Age : 54
Location : Cape Breton Island
Permissions in this forum:
You cannot reply to topics in this forum