- Jan 19, 2008
- 234
- 312
A while back I finally got around to installing HotKeys and started reading about scriptable keys. I applied this to Hammer as well as dozens of other programs and found I'm saving a huge amount of time so I'd figure I'd pass on the info.
Some of you might know about this already and / or may know of an even more efficient method then the one I describe here, please don't keep this to yourself, I'm no scripting guru by any means.
For this first tutorial you'll need two similar sounding programs, HotKeys and AutoHotKey
Why bother making an AutoKotKey script?
Here I have a structure made out of brushes that lets say I want to rotate 90 degrees....
To do this normally I would:
-select all the brushes
-press "Ctrl" & "M" to bring up the transformation window
-change the Z value to 90
-then hit "Enter"
This may not sound too time consuming, but I tend to do something like this 20 or more times on the fly when I'm mapping. The time it takes to repeat this same procedure over and over again adds up. Now what if I could bind the whole procedure to a 2 key combination....
This is where AutoHotKey and Hotkeys come in, first I'm going to use AutoHotKey to record the procedure to a file and next I'll use Hotkeys to bind the file to a key combination.
Here's the steps:
1st: After installing the two programs mentioned above, open up Hammer and load a vmf file to experiment with (or create a new one).
2nd: while Hammer is still running, open up Hotkeys' AutoScriptWriter and hit the "Record" button in the top left of the window.
There should now be a "Stop" button in the top left corner of your screen.
3rd: Pull Hammer up again and perform the same routine:
- select the brushes you want to rotate
- press "Ctrl" & "M" to bring up the transformation window
- press the "Tab" button 3 times two get down to the Z value
- type in "9" and "0" to change the degrees from 0 to 90
- press "Enter" to perform the rotation
4th: Click the "Stop" button in the top left corner of the screen. You should now be presented with a window that looks something like this:
We don't want to keep all of this, look near the bottom for the line "Send, {CTRLDOWN}m{CTRLUP}", remove all the text above this line leaving you with this:
5th: Click save and put in "rotate_90" for the filename and hit "Enter" to save it, taking note of where you save the file to. Close the AutoScriptWriter.
6th: Bring up the HotKeys keyboard editor by pressing "Z" & the "Windows Key"
.
Here we can see what the default key bindings are for each key. Now drag the "rotate_90.ahk" file that was just created onto the number 1 key.
And we've completed binding the procedure to rotate an object 90 degrees onto the number 1 key. Now to test it out.
Remove the HotKeys keyboard editor from the screen by again pressing "Windows Key" & "Z" and bring Hammer back up. Now select the brush(es) you want to rotate, but instead of hitting "Ctrl" & "M" to bring up the transformation window, hit the "Windows Key" & "Z". HotKeys should load up the script we just made and send the required commands into Hammer to rotate the brush 90 degrees.
No selecting Z, no typing in 90, no hitting enter; Time = Saved.
I use the script above in Hammer myself, as well as several other I've created over time. I've been using the 2 programs above to do everything from change the resolution of an image in MS-Paint, to changing the extension on a file.
There are a few snags I've run into with using AHK scripts, though:
1: the procedure you're binding has to performable using only the keyboard, I haven't had any success with procedures that requires mouse input
2: while the script is running, you can't hit any other keys until it's finished or you could jack-up the process (ie: instead of rotating a brush 90 degrees, it'll be scaled larger by a factor of 90)
(The place holder posts below are for another tutorial I'm planning to add to this thread)
Some of you might know about this already and / or may know of an even more efficient method then the one I describe here, please don't keep this to yourself, I'm no scripting guru by any means.
For this first tutorial you'll need two similar sounding programs, HotKeys and AutoHotKey
Why bother making an AutoKotKey script?
Here I have a structure made out of brushes that lets say I want to rotate 90 degrees....

To do this normally I would:
-select all the brushes
-press "Ctrl" & "M" to bring up the transformation window
-change the Z value to 90
-then hit "Enter"
This may not sound too time consuming, but I tend to do something like this 20 or more times on the fly when I'm mapping. The time it takes to repeat this same procedure over and over again adds up. Now what if I could bind the whole procedure to a 2 key combination....
This is where AutoHotKey and Hotkeys come in, first I'm going to use AutoHotKey to record the procedure to a file and next I'll use Hotkeys to bind the file to a key combination.
Here's the steps:
1st: After installing the two programs mentioned above, open up Hammer and load a vmf file to experiment with (or create a new one).
2nd: while Hammer is still running, open up Hotkeys' AutoScriptWriter and hit the "Record" button in the top left of the window.


There should now be a "Stop" button in the top left corner of your screen.

3rd: Pull Hammer up again and perform the same routine:
- select the brushes you want to rotate
- press "Ctrl" & "M" to bring up the transformation window
- press the "Tab" button 3 times two get down to the Z value
- type in "9" and "0" to change the degrees from 0 to 90
- press "Enter" to perform the rotation
4th: Click the "Stop" button in the top left corner of the screen. You should now be presented with a window that looks something like this:

We don't want to keep all of this, look near the bottom for the line "Send, {CTRLDOWN}m{CTRLUP}", remove all the text above this line leaving you with this:

5th: Click save and put in "rotate_90" for the filename and hit "Enter" to save it, taking note of where you save the file to. Close the AutoScriptWriter.
6th: Bring up the HotKeys keyboard editor by pressing "Z" & the "Windows Key"


Here we can see what the default key bindings are for each key. Now drag the "rotate_90.ahk" file that was just created onto the number 1 key.

And we've completed binding the procedure to rotate an object 90 degrees onto the number 1 key. Now to test it out.
Remove the HotKeys keyboard editor from the screen by again pressing "Windows Key" & "Z" and bring Hammer back up. Now select the brush(es) you want to rotate, but instead of hitting "Ctrl" & "M" to bring up the transformation window, hit the "Windows Key" & "Z". HotKeys should load up the script we just made and send the required commands into Hammer to rotate the brush 90 degrees.
No selecting Z, no typing in 90, no hitting enter; Time = Saved.
I use the script above in Hammer myself, as well as several other I've created over time. I've been using the 2 programs above to do everything from change the resolution of an image in MS-Paint, to changing the extension on a file.
There are a few snags I've run into with using AHK scripts, though:
1: the procedure you're binding has to performable using only the keyboard, I haven't had any success with procedures that requires mouse input
2: while the script is running, you can't hit any other keys until it's finished or you could jack-up the process (ie: instead of rotating a brush 90 degrees, it'll be scaled larger by a factor of 90)
(The place holder posts below are for another tutorial I'm planning to add to this thread)
Last edited: