Author Topic: Guide: Using Autohotkey to change controls, window size and volume  (Read 3698 times)

Syd

  • Cherry Eater
  • Posts: 63
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Firefox 54.0.1 Firefox 54.0.1
    • View Profile
  • Playstyle: Keyboard
Guide: Using Autohotkey to change controls, window size and volume
« on: September 13, 2017, 11:22:20 AM »
Hi Guys  :atkHappy:

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 TRunnerFormWith 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::shiftThis 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,1045The 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 :)
« Last Edit: October 31, 2017, 06:06:19 AM by Syd »

EternalMiluk

  • Wannabe
  • Posts: 11
  • OS:
  • Linux (Ubuntu) Linux (Ubuntu)
  • Browser:
  • Firefox 55.0 Firefox 55.0
    • View Profile
    • DelFruit profile
  • Playstyle: Keyboard
Re: Guide: Using Autohotkey to change controls, window size and volume
« Reply #1 on: September 16, 2017, 05:07:10 PM »
This is really helpful! Thanks for your effort.

WatershameDave

  • Wannabe
  • Posts: 2
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Firefox 55.0 Firefox 55.0
    • View Profile
    • flirt cam girls right way
  • Playstyle: Keyboard
Re: Guide: Using Autohotkey to change controls, window size and volume
« Reply #2 on: October 01, 2017, 07:04:49 PM »
Exactly what I was looking for.

Mucho appreciato

Syd

  • Cherry Eater
  • Posts: 63
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Firefox 55.2.2 Firefox 55.2.2
    • View Profile
  • Playstyle: Keyboard
Re: Guide: Using Autohotkey to change controls, window size and volume
« Reply #3 on: October 30, 2017, 02:44:54 PM »
I just learned some new stuff  :atkHappy:

Make windows transparent
Code: [Select]
F5::WinSet, Transparent, 150,A
F6::WinSet, Transparent, off,A
The 150 in this example is the degree of opacity, so lowering it will make the window more transparent. The maximum opacity is 255.
This is useful when you want to recreate a room in jtool, as explained here. Note that unlike with ghostit, you have to make jtool transparent, not the game you are copying.

Make one color invisible
Code: [Select]
F8::WinSet, TransColor, 000000, A
F6::WinSet, Transparent, off,A
The number is the RGB value of the color you want to be invisible, in this case it's black. Very useful if you want to watch videos while playing fangames  :OneHand:
(click to show/hide)

edit: make color under mouse cursor invisible:
(click to show/hide)

Remove titlebar and borders (so you can make the window a little bit bigger, without going fullscreen)
Code: [Select]
F7::
WinSet, Style, ^0xC00000, A
WinSet, Style, ^0x40000, A
return
the ^ makes it so it toggles on and off
edit: this will make GM:Studio games behave weirdly, and is also the reason why those don't like borderless fullscreen scripts

Borderless Fullscreen Script (not made by me)
(Note: doesn't work well with GM-Studio games, and I haven't found any other fullscreen-script that works for those)
(click to show/hide)

If you have any other ideas about what you could do with autohotkey regarding fangames, but don't know how to code it, post it here. Maybe I will find a way  :atkHappy:
« Last Edit: October 30, 2017, 04:12:47 PM by Syd »

Wolsk

  • The Kid
  • Posts: 332
  • Wolsky McKitty :3
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Chrome 62.0.3202.94 Chrome 62.0.3202.94
    • View Profile
  • Playstyle: Keyboard
Re: Guide: Using Autohotkey to change controls, window size and volume
« Reply #4 on: November 23, 2017, 10:05:27 AM »
Autohotkey randomly deselects the window when I'm playing fangames sometimes, and I have no idea why.  I figured it'd be the same issue as what tenshots had but without the error message popping up, but adding #MaxHotkeysPerInterval 9999 did not seem to fix the issue for me.  The rest of my script is p much exactly what you have there.  Any ideas?

I know my script used to be a bit different from yours in regards to the ahk_class, and I don't remember having the random deselect issue until I changed it to match the example.  This is what my script looks like as of now:

Code: [Select]
GroupAdd, Fangame, ahk_class TRunnerForm
GroupAdd, Fangame, ahk_class YYGameMakerYY
GroupAdd, Fangame, ahk_class Mf2MainClassTh

#IfWinActive ahk_group Fangame
{
LCtrl::LShift
RShift::LShift
Up::LShift
;Down::r
|::Send, {SHIFTUP}
~^d::Suspend
}
meow :3

Why are you complaining about being a meme? this is a positive thing

Syd

  • Cherry Eater
  • Posts: 63
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Firefox 55.2.2 Firefox 55.2.2
    • View Profile
  • Playstyle: Keyboard
Re: Guide: Using Autohotkey to change controls, window size and volume
« Reply #5 on: November 25, 2017, 08:26:56 AM »
That is strange, I have no idea what could be the cause of your problem.
I tried your script and it didn't happen to me (I didn't try very long though). Maybe you should go back to your old script and see if it still happens

Edit: I would recommend using SendInput instead of Send, because it's faster and more reliable.