Jump to content
LaunchBox Community Forums

Autohotkey to remap keys for a specific game


Flope

Recommended Posts

Hi, 

My setup is an arcade cabinet with ipac-2 (like a keyboard) running LB 9.0 in win 10. 

I have a couple of simple steam games that I am not able to configure the keyboard controls. 

I was thinking to use AutoHotkey to remap the keys only for each of those games. 

I noticed that LB has the option to use AutoHotKey for all the games in the same platform. 

Can I use AutoHotkey for a specific game? Any pointers on how to start with this will be really helpful. 

Thanks, 

 

 

Link to comment
Share on other sites

This is how I solve it. I am not sure if it is the best way. So, I am happy to take suggestions.

This for a silly game called chompy chomp chomp or something like that. 

1. I installed AutoHotKey

2. I wrote the following script to run the game and to remap some of the keys. I saved it as "chompy.ahk"

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.


run, steam://rungameid/292570
#IfWinActive AHK_exe ChompyChompChomp.exe ;
LControl::.
g::d
d::a
r::w
f::s
a::v

3. I stored the script in launchbox\Games\Windows.

4. I edited the launcher for that game in LaunchBox changing the Application Path to "Games\Windows\chompy.ahk

Thus, LaunchBox will lunch the script instead of the game. The script will launch the game and it will remap the keys while the game is active. 

It seems it works fine.

 

Link to comment
Share on other sites

This is another example for "Guns, Gore, and Cannoli".  

Changing controls within the game does not work. It resets to defaults when starting the game. 

Do I need to exit the app (last lines of code below)?

 

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.


run, steam://rungameid/322210
#IfWinActive AHK_exe ggc.exe ;
 ; Player2 with keyboard1
d::a
g::d
r::Space ; Jump
a::Space ; Jump2
s::k     ; Kick
j::m        ; next weapon
w::j   ; shoot
i::r  ; reload
k::u  ; grenade
q::i   ; molotov
f::s  ; crouch

 ; Player1 with keyboard 2
LControl::Up    ; jump 2
LAlt::Numpad1   ; Kick
c::NumpadAdd    ; next weapon
v::NumpadSub    ; prev weapon
LShift::Numpad0   ; shoot
z::Numpad2  ; reload
x::Numpad4  ; grenade
Space::Numpad5   ; molotov

#IfWinNotExist AHK_exe ggc.exe ;
ExitApp

 

Link to comment
Share on other sites

  • 4 months later...

Thanks for posting this! I've made tweaks as I was having issues with the exitapp section. Here are the two scripts I came up with based on yours, hoping it helps others

I've spent like half a day on this so wanted to share my learns. link here: https://www.autohotkey.com/boards/viewtopic.php?f=18&t=63827&p=273602#p273602

 

method one

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.


Run, openliero.exe

#IfWinActive AHK_exe openliero.exe ;
 ; Player1
;KeyPressed::KeyItThinksIPressed
w::Up ;when pressing the W key, the game registers that up was hit instead
a::Left
s::Down
d::Right
LControl::Enter ;shoot

 ;Escape key
5::Escape
6::Esc

 ; Player2


#IfWinNotExist ahk_exe E:\Windows\Liero 1.36\openliero.exe ;	
w::
	send w
	Exitapp
return
s::
	send s
	exitapp
return
a::
	send a
	exitapp
return
d::
	send d
	exitapp
return
LControl::
	send ^
	exitapp
return
5::
	send 5
	exitapp
return
6::
	send 6
	exitapp
return

method two

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.


Run, openliero.exe

#Persistent ;only exits on an exitapp command
WinWait, ahk_exe openliero.exe, , 5
SetTimer, CheckForWindow, 5000 ; check every 5 seconds


#IfWinActive AHK_exe openliero.exe ;
 ; Player1
;KeyPressed::KeyItThinksIPressed
w::Up ;when pressing the W key, the game registers that up was hit instead
a::Left
s::Down
d::Right
LControl::Enter ;shoot

 ;Escape key
5::Escape
6::Esc

 ; Player2


CheckForWindow:
IfWinNotExist, ahk_exe openliero.exe
{
ExitApp
Return
}

Still trying to figure out the best method, but hoping this helps others that find this thread. both confirmed working.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...