1
Gameplay & Discussion / Guide: Using Autohotkey to change controls, window size and volume
« on: September 13, 2017, 11:22:20 AM »
Hi Guys
There are three things that bother me about fangames. The controls, the small window size, and the high volume. Most of the veteran players probably learned to live with this, but for the rest of you, I made this little guide on how to deal with those issues using Autohotkey.
To create a new Autohotkey script, simply create a .txt file and change the file extension to .ahk after you are done edititing it.
First, add this line to the top of your script:
For Gamemaker-Studio games this line needs to be different: #IfWinActive ahk_class YYGameMakerYY. For MMF games (Boshy and the orginal IWBTG) it should be #IfWinActive ahk_class Mf2MainClassTh.
Edit: If just found out you can create custom window-groups. So you can group GameMaker 8, Studio and MMF games together:
Also, add this line to the beginning of the script, otherwise you might get a message saying that you activated to many hotkeys in the last few seconds:
#MaxHotkeysPerInterval 9999
Changing controls
To change the controls, use this:
Define each key in a new line, directly below the "#IfWinActive" stuff.
To make one key do nothing:
Changing window size and position
This just needs one line:
Changing the game volume
To do this easily with autohotkey, you need this nice little tool: nircmd (download at the bottom of the page). After downloading, run it once and choose to put it in the windows-directory. If you don't want to put it into the windows directory, just put the complete path into the code (e.g. "C:\stuff\nircmd.exe")
You can then use it in the ahk-script like this:
If you want to set it directly to a predifined value, use setappvolume instead (e.g. setappvolume focused 0.1)
You can also combine this with resizing the window:
The complete script should look something like this:
I hope this helps someone
Edit:
you might also want to put this stuff to the top of the script. I don't know what it does, but it's supposed to increase performance:
Edit 2: If you experience problems with input lags, or anything else, try putting #UseHook somewhere above your hotkey.
Edit 3: more stuff in my next post
There are three things that bother me about fangames. The controls, the small window size, and the high volume. Most of the veteran players probably learned to live with this, but for the rest of you, I made this little guide on how to deal with those issues using Autohotkey.
To create a new Autohotkey script, simply create a .txt file and change the file extension to .ahk after you are done edititing it.
First, add this line to the top of your script:
Code: [Select]
#IfWinActive ahk_class TRunnerForm
With this line the script will only work when a fangame-window (or any other gamemaker-exe) is active. That way you can keep the script running in the background while you are doing stuff other than playing fangames. If let it autorun with windows, and it has never caused any problems at all.For Gamemaker-Studio games this line needs to be different: #IfWinActive ahk_class YYGameMakerYY. For MMF games (Boshy and the orginal IWBTG) it should be #IfWinActive ahk_class Mf2MainClassTh.
Edit: If just found out you can create custom window-groups. So you can group GameMaker 8, Studio and MMF games together:
Code: [Select]
GroupAdd, Fangame, ahk_class TRunnerForm
GroupAdd, Fangame, ahk_class YYGameMakerYY
GroupAdd, Fangame, ahk_class Mf2MainClassTh
#IfWinActive ahk_group Fangame
Also, add this line to the beginning of the script, otherwise you might get a message saying that you activated to many hotkeys in the last few seconds:
#MaxHotkeysPerInterval 9999
Changing controls
To change the controls, use this:
Code: [Select]
w::shift
This example sets Shift to the w-key. In the same manner, you can set any key to any other. Just note that if you want to set your jump button to the Numpad, you need to deactivate numlock, otherwise you will constantly cancel your jumps (e.g. instead of setting jump to Numpad5, set it to NumpadClear)Define each key in a new line, directly below the "#IfWinActive" stuff.
To make one key do nothing:
Code: [Select]
q::return
Changing window size and position
This just needs one line:
Code: [Select]
Tab::WinMove,A,,290,0,1340,1045
The first two numbers are the position of the windows (upper left corner), the last two numbers are the width and heigth. This example will resize the game to 1340x1045 pixels and put it in the center of the screen when you press Tab.Changing the game volume
To do this easily with autohotkey, you need this nice little tool: nircmd (download at the bottom of the page). After downloading, run it once and choose to put it in the windows-directory. If you don't want to put it into the windows directory, just put the complete path into the code (e.g. "C:\stuff\nircmd.exe")
You can then use it in the ahk-script like this:
Code: [Select]
^Up::run nircmd changeappvolume focused +0.1
^Down::run nircmd changeappvolume focused -0.1
This examples lowers the volume of the active window by 10% when you press ctrl+down, and increases it with ctrl+Up.If you want to set it directly to a predifined value, use setappvolume instead (e.g. setappvolume focused 0.1)
You can also combine this with resizing the window:
Code: [Select]
Tab::
WinMove,A,,200,0,1340,1045
run nircmd setappvolume focused 0.1
return
The complete script should look something like this:
Code: [Select]
#MaxHotkeysPerInterval 9999
GroupAdd, Fangame, ahk_class TRunnerForm
GroupAdd, Fangame, ahk_class YYGameMakerYY
GroupAdd, Fangame, ahk_class Mf2MainClassTh
#IfWinActive ahk_group Fangame
{
a::Left
d::Right
w::Shift
s::Down
NumpadClear::Shift
NumpadLeft::z
NumpadRight::s
Space::r
Tab::
WinMove,A,,200,0,1340,1045
run nircmd setappvolume focused 0.1
return
}
This is of course just an example. It's completely customizable for your needs.I hope this helps someone
Edit:
you might also want to put this stuff to the top of the script. I don't know what it does, but it's supposed to increase performance:
Code: [Select]
#NoEnv
#KeyHistory 0
ListLines Off
Process, Priority, , A
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
Edit 2: If you experience problems with input lags, or anything else, try putting #UseHook somewhere above your hotkey.
Edit 3: more stuff in my next post