Comrades in Arms Discussion Board

Full Version: AutoHotKey
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
As you know, most recording software only supports one Push-To-Talk key, so when recording missions with TFAR , you will have the problem that short/long range/underwater/alternate channel keys go unnoticed. You don't want to record everything, though, since you're kids are noisy in the background or you don't want to record you cursing at the game Big Grin

So the idea is to use AutoHotKey.

The installer for AutoHotKey can be downloaded here. Just install it andfollow the instructions.

Next, you set up your recording software to always record (no Push To Talk).

Finally, you need a script that automatically opens or closes your mic. For that, you need to install the Vista Audio Control Library. Unfortunately, the link to the download is broken. I'll add the version I have to this post (AutoHotKey.7z). Just unpack to you My Documents, i.e. c:\Users\<you>\Documents\

Finally, you will need the actual script (also added).

The script is predefined with my own keys. Customization is easy:

The script is basically four blocks, looking like this:

Code:
~y:: ;Change this for the button you want to use
    VA_SetMasterMute(false, "capture")
    KeyWait, y
    VA_SetMasterMute(true, "capture")
    Return

This watches the key 'y' and once it goes down (~ in front denotes key down, otherwise, it waits until the key comes up again), unmutes the mic, and when it goes up again, it mutes the mic again... change the existing blocks, or add new ones depending on your needs. Key names can be found here.
You need to add your key in two places, after the ~, and after the KeyWait,

This would for example make the CTRL+Home key work as a PTT key:


Code:
~^Home:: ;Change this for the button you want to use
    VA_SetMasterMute(false, "capture")
    KeyWait, Home
    VA_SetMasterMute(true, "capture")
    Return

Note that a ^ in front means CTRL. The link with the key names above also lists these modifiers.

Any questions, just ask
Thanks Varanon, it works! However I don't manage to set my underwater radio (Ctrl+Tilde). The key list mention the tilde key just as a modifier key. I tried that but it doesn't work:

Code:
~^~:: ;Change this for the button you want to use
    VA_SetMasterMute(false, "capture")
    KeyWait, ~
    VA_SetMasterMute(true, "capture")
I'll check how this works tomorrow
Alright, it's possible to use just any key, but some keys require the use of scan codes.

If a key doesn't work for you, proceed like this:

Add #InstallKeybdHook as the second line in the PuthToTalk.ahk script.
Start AHK
Press the key that you want to use (a few times if you want to be sure)
In the try bar icon, select "Open"
In the window that opened, select View->Key History and Script info
Press f5
Find the key. There will be some line that lists the key under the "Key" column
Note the second value in that line (under the SC header). This is the scan code

In the script, you can use scan codes instead of keys with a 'SC' prefix. So, for example, the '^' key on the german keyboard (top row before the number keys) has a scan code of 029, so the script would look something like this (if you want CTRL+that key)

Code:
~^SC029:: ;Change this for the button you want to use
    VA_SetMasterMute(false, "capture")
    KeyWait,SC029
    VA_SetMasterMute(true, "capture")
    Return