Jump to content
LaunchBox Community Forums

Auto Hotkey Scripts


Lordmonkus

Recommended Posts

Shows how often I go in to Bigbox! Thanks, I enabled it, set LeftAlt as the hold key, then b for vol down and n for vol up. It worked for around 10 secs and then just stopped. Stickykeys are disabled, no other funky mapping programs installed or running, multiple reboots/power cycles and turning settings off/on/clearing out keyboard mappings in Bigbox etc.

This sounds like I have to fire up another thread somewhere on here for that, but ideally, if anyone could help me with the AHK above to do the same thing, that would be amazing, thanks.

Edited by Mr Footlong
Link to comment
Share on other sites

19 hours ago, Mr Footlong said:
<^b::
send {Volume_Up 5}
<^n::
send {Volume_Down 5}
return

I have no idea what the < symbol is for.  But the ^ is the 'shorthand' for Ctrl.  ! is for Alt.

!b::
send {Volume_Up 5}
!n::
send {Volume_Down 5}

Also, since you have other hotkeys in there, you don't need to have a "return".  (it is implied)

Alternatively, if you know the [volume] level that works best, you can simply set it to that.

; set volume level to 35%
SoundSet, 35

 

Ideally, you should figure out how to keep it working with the BigBox bindings.  Although I'm not sure if the Volume binding in BB remains active during emulation.  And it may be that the emulator has other uses for Alt-b and Alt-n.?.

Link to comment
Share on other sites

  • 2 weeks later...
6 minutes ago, JoeViking245 said:
1Joy14::
   If GetkeyState("Joy11")
   WinClose, ahk_exe {{{StartupEXE}}}

I think this one'll work.  You'll need to press (and hold) Joy11 1st, then Joy14 (right away).

Thanks! Worked like a charm!  Extra Kudos for answering so fast ^_^

  • Game On 1
Link to comment
Share on other sites

I've got a dumb question....

I'd like to change key bindings with AHK when starting certain steam games and then close the ahk script on game exit.  Is the best was to do this by having launchbox open the ahk script on game startup that changes the keybindings and then have launchbox run another app which would simply be an ahk script with the following on game exit:

Process, Close, AutoHotkey.exe

 

I tried going down the WaitWinClose or WinClose app to have it in one script to close the script when the game close but I wasn't having much luck there.

Link to comment
Share on other sites

2 hours ago, hawkfanz said:

I'd like to change key bindings with AHK when starting certain steam games and then close the ahk script on game exit.

The way that Steam launches their games, that's not really going to work.  ...the [wait for game to exit and] closing the AHK script on exit part.  Though you may be able to do that if you launch the Steam game directly from its exe file. Basically ignoring the Steam interface.  But then you may be opening the door to a lot of other issues.

You should be able to map any necessary keys for a game, in the game itself.  At least I can in all my Steam Lego games. :)

If you're wanting to create a key to exit the game, can't (won't, actually) help you there.  Mainly because of how easy it is to go to the in-game menu and select Exit to Windows.

  • Like 1
Link to comment
Share on other sites

1 hour ago, JoeViking245 said:

The way that Steam launches their games, that's not really going to work.  ...the [wait for game to exit and] closing the AHK script on exit part.  Though you may be able to do that if you launch the Steam game directly from its exe file. Basically ignoring the Steam interface.  But then you may be opening the door to a lot of other issues.

You should be able to map any necessary keys for a game, in the game itself.  At least I can in all my Steam Lego games. :)

If you're wanting to create a key to exit the game, can't (won't, actually) help you there.  Mainly because of how easy it is to go to the in-game menu and select Exit to Windows.

I’m using an i-PAC 2 in a cabinet and playing some games like Downwell that unfortunately doesn’t offer any remapping in game.  This makes it a lot harder!  Maybe keyboard2xinput would be a better option for this. I recently (finally! switched from hyperspin/rocketlauncher) and the only thing that I miss is the simple ability to use ahk scripts for specific games. 

Link to comment
Share on other sites

2 hours ago, hawkfanz said:

I’m using an i-PAC 2 in a cabinet and playing some games like Downwell that unfortunately doesn’t offer any remapping in game.  This makes it a lot harder!  Maybe keyboard2xinput would be a better option for this. I recently (finally! switched from hyperspin/rocketlauncher) and the only thing that I miss is the simple ability to use ahk scripts for specific games. 

You could try a script that first waits for the game executable to start and then for it to close, then terminates itself. But for Steam games this has to be done on a per game basis.

Process, Wait, Downwell.exe
Process, WaitClose, Downwell.exe
ExitApp

Put your remaps below ExitApp.

The easiest way to find out what the name of the executable is, is to Alt + Tab out of your games and open the Windows Task Manager. Then add your script as an Additional App to your game.

*Note*

This may not work for every game as some games restart an executable. In that case you can try:

WinWait, ahk_exe Downwell.exe
WinWaitClose
ExitApp

Sometimes it only works when you tell WinWait the exact window- or class name to wait for.

Link to comment
Share on other sites

7 hours ago, Your Friendly A.I Overlord said:

You could try a script that first waits for the game executable to start and then for it to close, then terminates itself. But for Steam games this has to be done on a per game basis.

Process, Wait, Downwell.exe
Process, WaitClose, Downwell.exe
ExitApp

Put your remaps below ExitApp.

The easiest way to find out what the name of the executable is, is to Alt + Tab out of your games and open the Windows Task Manager. Then add your script as an Additional App to your game.

*Note*

This may not work for every game as some games restart an executable. In that case you can try:

WinWait, ahk_exe Downwell.exe
WinWaitClose
ExitApp

Sometimes it only works when you tell WinWait the exact window- or class name to wait for.

Thank you!!!! That did the trick.  For whatever reason, the first script process was closing out before the game was opening so I added in Sleep 2000 at the top and then it worked perfectly.  Your second script works for me perfectly as is.  Thanks again!

  • Like 1
Link to comment
Share on other sites

The wife asked me to add a few flash games. I have the swf's and am able to run them in the flashplayer_32_sa.exe from adobe. 

If I set up flashplayer_32_sa.exe (as an emulator) and use the swf files for the roms, am I able to do something in LB using a AHK to do a <CTRL>+F4 when or after it launches the swf?  The <CTRL>+F4 is just making the flash player go full screen after a game is launched in it.

I meant <CTRL>+f O.o

Edited by The Papaw
Link to comment
Share on other sites

1 hour ago, The Papaw said:

am I able to do something in LB using a AHK to do a <CTRL>+F4 when or after it launches the swf?  The <CTRL>+F4 is just making the flash player go full screen after a game is launched in it.

As far as I can see Ctrl + f makes  flashplayer_32_sa.exe go fullscreen. In LaunchBox go to the flashplayer_32_sa emulator setup and in the "Running Script" paste:

WinWait, ahk_exe {{{StartupEXE}}}
Sleep 500
SendInput ^f

$Esc::
{
WinClose, ahk_exe {{{StartupEXE}}}
}

82487564_Schermopname(91).thumb.jpg.638192e5d7df37b44982d69ccd445c45.jpg

This makes flashplayer_32_sa go fullscreen after launching a rom and exits it with Escape. Depending on your PC you may have to alter Sleep 500 to Sleep 1000.

Edited by Your Friendly A.I Overlord
Link to comment
Share on other sites

1 hour ago, Your Friendly A.I Overlord said:

As far as I can see Ctrl + f makes  flashplayer_32_sa.exe go fullscreen. In LaunchBox go to the flashplayer_32_sa emulator setup and in the "Running Script" paste:

WinWait, ahk_exe {{{StartupEXE}}}
Sleep 500
SendInput ^f

$Esc::
{
WinClose, ahk_exe {{{StartupEXE}}}
}

This makes flashplayer_32_sa go fullscreen after launching a rom and exits it with Esc Depending on your PC you may have to alter Sleep 500 to Sleep 1000.

That's exactly what I was needing, thank you @Your Friendly A.I Overlord

Link to comment
Share on other sites

Hello, i use Keyboard2Xinput for steam games to remap my ipac IO to xbox controls. I am extremely new to AHK and i have no idea how to make a script.

What im trying to do is launch Keyboard2Xinput when i launch a game via BigBox and have Keyboard2Xinput close after i quit the game. If anyone would be so kind in helping me out that would be greatly appreciated. I have to manually close Keyboard2Xinput after i quit a game and it defeats the purpose of running it on an arcade set up and just doesnt feel authentic. 

Link to comment
Share on other sites

3 hours ago, MonsterKenny said:

What im trying to do is launch Keyboard2Xinput when i launch a game

Edit your game(s) and add an Additional Application that launches Keyboard2XinputGui.exe and check the box Automatically Run Before Main Application

That's the easy part which I gather you already figured out.  Running (closing, in this case) an application after a Steam game exits is a bit more tricky.  The easiest way to accomplish this is to launch the games exe file rather than using the Steam gameID #.  Edit the game, and in the Launching section change the Application Path to point to the games exe file.  I don't know if this affects any of the Steam interface or achievements, but the games will run this way.

Now create a new text file and in it put:

SendInput, {NumpadMult}
ExitApp

Save the file somewhere where you won't forget where it is.  Maybe in the same folder as your "Keyboard2XinputGui.exe" file is.  Like with everything else, give it a fancy name like "ExitK2X".  Now rename the file to have an .ahk file extension. like "ExitK2X.ahk".  Be careful that it doesn't get renamed "ExitK2X.ahk.txt".

[Back to editing the game in LaunchBox] Add another Additional Application.  Give it a fancy Application Name like "Exit Keyboard2XinputGui".  For the Application Path, Browse to and select "AutoHotkey.exe".  You'll find one in /LaunchBox/ThirdParty/AutoHotkey/

In the Application Command-Line Parameters field, type the full path to where you saved the .ahk file, and put it in quotes.  i.e.

"D:\Games\Keyboard2Xinput\ExitK2X.ahk"

Now check the box for Automatically Run After Main Application.  Click OK.  And Click OK again.

 

I've never personally used keyboard2xinput, but it's my understanding that the asterisk * on the keyboards' 10-key [a.k.a. the multiply button on the number pad] is what closes the program. That's where the "SendInput, {NumpadMult}" comes from.

 

  • Like 1
Link to comment
Share on other sites

20 hours ago, JoeViking245 said:

Edit your game(s) and add an Additional Application that launches Keyboard2XinputGui.exe and check the box Automatically Run Before Main Application

That's the easy part which I gather you already figured out.  Running (closing, in this case) an application after a Steam game exits is a bit more tricky.  The easiest way to accomplish this is to launch the games exe file rather than using the Steam gameID #.  Edit the game, and in the Launching section change the Application Path to point to the games exe file.  I don't know if this affects any of the Steam interface or achievements, but the games will run this way.

Now create a new text file and in it put:

SendInput, {NumpadMult}
ExitApp

Save the file somewhere where you won't forget where it is.  Maybe in the same folder as your "Keyboard2XinputGui.exe" file is.  Like with everything else, give it a fancy name like "ExitK2X".  Now rename the file to have an .ahk file extension. like "ExitK2X.ahk".  Be careful that it doesn't get renamed "ExitK2X.ahk.txt".

[Back to editing the game in LaunchBox] Add another Additional Application.  Give it a fancy Application Name like "Exit Keyboard2XinputGui".  For the Application Path, Browse to and select "AutoHotkey.exe".  You'll find one in /LaunchBox/ThirdParty/AutoHotkey/

In the Application Command-Line Parameters field, type the full path to where you saved the .ahk file, and put it in quotes.  i.e.

"D:\Games\Keyboard2Xinput\ExitK2X.ahk"

Now check the box for Automatically Run After Main Application.  Click OK.  And Click OK again.

 

I've never personally used keyboard2xinput, but it's my understanding that the asterisk * on the keyboards' 10-key [a.k.a. the multiply button on the number pad] is what closes the program. That's where the "SendInput, {NumpadMult}" comes from.

 

thank you very much, it worked. I have been struggling with this for months! 

Edited by MonsterKenny
  • Like 1
  • Game On 1
Link to comment
Share on other sites

Hello guys!! i have a pesky PC game with no exit option. the only way i can close it is Alt + F4. can someone help me with a script that i can place in an .AHK file to escape this PC game by pressing ESC and that sends the Alt + F4?

 

also would i ✔️ the run before main application box? thank you in advance..

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...