Jump to content
LaunchBox Community Forums

Auto Hotkey Scripts


Lordmonkus

Recommended Posts

3 hours ago, jmirage said:

Sorry if this is already available somewhere else, but is there any reference to which other variables we can use in AutoHotKey scripts? Or is it only {{StartupEXE}} ?

For Running Scripts (and Additional Apps), you can't pass any variables to them.  But for Command-Line Parameters....

In addition to those listed, there's also %romlocation% (added in v12.7).

  • Thanks 1
Link to comment
Share on other sites

On 4/7/2023 at 2:25 PM, JoeViking245 said:

For Running Scripts (and Additional Apps), you can't pass any variables to them.  But for Command-Line Parameters....

In addition to those listed, there's also %romlocation% (added in v12.7).

thanks a lot! reading a bit more about this, actually what I can use is Adittional Apps that are triggered before the game.
This is because I'm playing Sekiro on both the Steam Deck and PC and sadly From Software syncs the graphic settings, not only the save game as they should. I'm planning on fixing this by modifying the settings before and after triggering the game on PC

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

Not sure if this was posted, but I couldn't find this in this topic

I am having problems enabling mouse in SNES9X

I have -port1 mouse1 added as a parameter to the emulator, but I find that it still requires my pressing 7 to actually enable it in SNES9X

I tried the following AHKs in the Running Scripts section, to no avail

  • SendInput {vk47}

  • Send, 7

  • Send 7

  • Send {7}

  • SendInput, {7}

  • SendInput, {Raw}7

Any help is greatly appreciated.

Link to comment
Share on other sites

1 hour ago, MCF said:

Not sure if this was posted, but I couldn't find this in this topic

I am having problems enabling mouse in SNES9X

I have -port1 mouse1 added as a parameter to the emulator, but I find that it still requires my pressing 7 to actually enable it in SNES9X

I tried the following AHKs in the Running Scripts section, to no avail

  • SendInput {vk47}

  • Send, 7

  • Send 7

  • Send {7}

  • SendInput, {7}

  • SendInput, {Raw}7

Any help is greatly appreciated.

I've never used SNES9x.  Does the Use Mouse not work?

image.png.124e56fb5c14fe23e01da314635ecff6.png

 

Regardless, if you find you still need to press 7 to switch controllers, you may try adding a SetKeyDelay.  You'll also need to add a delay/pause/wait because the running script executes right away.  You want to wait a little for the emulator to actually be running before "pressing 7".

Sleep, 5000
SetKeyDelay, 125, 50
Send, 7

"5000" = 5 seconds.  Adjust accordingly depending on how long it takes for the emulator to be fully loaded.

Link to comment
Share on other sites

40 minutes ago, JoeViking245 said:

I've never used SNES9x.  Does the Use Mouse not work?

image.png.124e56fb5c14fe23e01da314635ecff6.png

 

Regardless, if you find you still need to press 7 to switch controllers, you may try adding a SetKeyDelay.  You'll also need to add a delay/pause/wait because the running script executes right away.  You want to wait a little for the emulator to actually be running before "pressing 7".

Sleep, 5000
SetKeyDelay, 125, 50
Send, 7

"5000" = 5 seconds.  Adjust accordingly depending on how long it takes for the emulator to be fully loaded.

I want to eventually use BigBox and not require using keyboard and mouse :)

Unfortunately the suggested AHK did not work... I had set a variation of Sleep, even delaying up to 20 seconds did not work

This is different from the KEGA Fusion emulator (which I use to emulate Sega Master System games), and the following AHK to send F12 works

Sleep 5000
Send {F12}

Link to comment
Share on other sites

18 minutes ago, MCF said:

Unfortunately the suggested AHK did not work

Download and tested a game and the following worked for me.

WinWaitActive ahk_exe snes9x-x64.exe
send 7

 

This assumes your executable is "snes9x-x64.exe".  Didn't need the key delay (which some emulators do. i.e. MAME) and the WInWaitACtive alleviates any guessing games for the Sleep timer.  Be sure it's above any escape sequence.

image.png.df6cbb7227fd4feaa1f7c58e4f8dcc81.png

If that still doesn't work for you, then there's something else wonky going on.  It'd also mean it's time to move to BigBox and a proper controller. ;) 

Link to comment
Share on other sites

On 4/26/2023 at 11:55 PM, JoeViking245 said:

Download and tested a game and the following worked for me.

WinWaitActive ahk_exe snes9x-x64.exe
send 7

 

This assumes your executable is "snes9x-x64.exe".  Didn't need the key delay (which some emulators do. i.e. MAME) and the WInWaitACtive alleviates any guessing games for the Sleep timer.  Be sure it's above any escape sequence.

image.png.df6cbb7227fd4feaa1f7c58e4f8dcc81.png

If that still doesn't work for you, then there's something else wonky going on.  It'd also mean it's time to move to BigBox and a proper controller. ;) 

Could this be failing becuase I configured SNES9X to be fullscreen by default?

Link to comment
Share on other sites

5 hours ago, MCF said:

Could this be failing becuase I configured SNES9X to be fullscreen by default?

Just tried fullscreen. Still worked here (sending "7").

image.png.754c7487a5cbe2d141786d7bfd52a1b0.png

 

Are you using v1.62.3?  You may try a [temp] fresh install of SNES9x.  Create a new folder next to the original install (/Emulators/SNES9xTEMP/).  Open "snes9x-1.62.3-win32-x64.zip" (that's the one I downloaded) with 7-Zip and drag/drop the files into the new TEMP folder.  Use 7-Zip so you don't have to mess with un-blocking any of the files.  Start it once and close (in case it needs to create any files on 1st run).  Don't change any settings at this point.  In LB, edit the emulator and change the app path to "snes9x-x64.exe" that's in the new temp folder.

I tried it with and without "-port1 mouse1" in the default command-line and both ways worked to send 7.  

I never tested actual playing with a mouse (because that would be weird  ;)).  But at game startup, the screen text would appear briefly.

image.thumb.png.c52af04da64340ed762e8f3f3f77cec4.png

  • Like 1
Link to comment
Share on other sites

I only setup the Mouse and Superscope games in Launchbox... other SNES games I play on a Super Nt. :)

Some games like Shien's Revenge and Mario & Wario are really fun mouse games, and do not work with controllers.

I have the 24 April SNES9X Git installed, and have the Fullscreen on ROM Open checkbox ticked, but the results are still the same. Sending 7 just does not work on my PC.

I gave up setting up the AHK for the mouse in SNES9X and switched to Mednafen. Thanks for all your help @JoeViking245... SNES9X is just being stubborn on my PC I guess.

  • Game On 1
Link to comment
Share on other sites

Hello Guys. Sorry If I Broke The topic but Im Using The MelonDS Emulator and i can't for the life of me get it to go in fullscreen by pasting the below script in running autohotkey Script. Usually i dont have this problem and it usually works but it will not for MelonDs... this is the script i use currently.......

Sleep, 5000
Send, {F11}

Or I Use

Sleep, 5000
Send, !{Enter}

It Wont Work Tho....  I even disabled startup screen

An Alternative I thought about is getting an AHK script to wait 5 Seconds then Hold Alt and then pressing enter. Pressing Either Hotkey I change It to whether it is Alt+Enter Or F11, it works when i manually press it with my fingers, But It Does Not Work at all By Script. Please Help.

 

heres the video of whats happening and screenshot of settings.

1398341609_melon1.thumb.jpg.32b7ff20194da2deaaf3d59bf7ec7fdf.jpg

 

 

and the video.

Emulator Settings

melon 3.jpg

Edited by Cnells2000
Link to comment
Share on other sites

Hi @Cnells2000 it's likely you need to try methods that get more specific if the method you tried isn't working. it would be better to spell out each keystroke press and release for ex

Right Alt down, Enter down, Enter up, Right Alt up

same would go for the F11 version

F11 down, F11 up

instead of just the F11 which implies the down and up but as you can see doesn't always translate well to every program

 

Sleep, 5000
SetKeyDelay, 50
Send {F11 down}{F11 up}

or

Sleep, 5000
SetKeyDelay, 50
Send {RAlt down}{Enter down}{Enter up}{RAlt up}

 

keydelay further mimics closer to human input since some programs might not poll inputs quick enough to detect them otherwise. hopefully all this does the trick

  • Like 1
  • Unusual Gem 1
Link to comment
Share on other sites

4 hours ago, Cnells2000 said:

Using The MelonDS Emulator and i can't for the life of me get it to go in fullscreen

Needs a SetKeyDelay.  Also, instead of guessing how long to pause for, simply wait for the executables window to become active.

WinWaitActive ahk_exe melonDS.exe
SetKeyDelay, -1, 110
Send, {F11}

 

 

A year and a half ago I had it in a loop waiting until the window is active.  This way (above) does the same thing, but a lot cleaner. ;) 

 

  • Like 1
Link to comment
Share on other sites

9 hours ago, skizzosjt said:

Hi @Cnells2000 it's likely you need to try methods that get more specific if the method you tried isn't working. it would be better to spell out each keystroke press and release for ex

Right Alt down, Enter down, Enter up, Right Alt up

same would go for the F11 version

F11 down, F11 up

instead of just the F11 which implies the down and up but as you can see doesn't always translate well to every program

 

Sleep, 5000
SetKeyDelay, 50
Send {F11 down}{F11 up}

or

Sleep, 5000
SetKeyDelay, 50
Send {RAlt down}{Enter down}{Enter up}{RAlt up}

 

keydelay further mimics closer to human input since some programs might not poll inputs quick enough to detect them otherwise. hopefully all this does the trick

after trying your method With RALT and Enter Everything Is Working Fine Now. Also I Changed it To 8000 To make It maximize Just In Time. Thank you Guys So Much for your help.

  • Like 1
Link to comment
Share on other sites

Looking for help guys and I'm sure someone has already asked this BUT... When I run BigBox I use an Xbox controller and have assigned start+back to exit the game to go back to game selection. I am using PCS2X app and the PS2 games run great but when I exit to game selection PCS2X comes up and makes me use my mouse to close it. What script could someone suggest I try to close the window and continue using BigBox all with the xbox controller? Thanks in advance everyone, this is really going to help my experience I have envisioned for my system.

Link to comment
Share on other sites

Thanks for replying Joe, I have double checked and confirm shutdown was and remains unchecked. The game closes fine but PCS2X stays open over BigBox. I'd love to hear any other suggestions you or anyone else may have. Not sure if I can map my controller to ALT+F4 but even force focus BigBox dosnt work. Everything halts as PCS2X just waits to be shut down manually.

Link to comment
Share on other sites

4 hours ago, LtMetal said:

Thanks for replying Joe, I have double checked and confirm shutdown was and remains unchecked. The game closes fine but PCS2X stays open over BigBox. I'd love to hear any other suggestions you or anyone else may have. Not sure if I can map my controller to ALT+F4 but even force focus BigBox dosnt work. Everything halts as PCS2X just waits to be shut down manually.

If you're using a recent version of PCSX2, specifically QT (recommended), in your Default Command-line parameters (when you edit the emulator in LaunchBox) put 

-nogui

"Old" PCSX2 would have you put "--batch" (I believe that's what it was).  Also, to have it start in full screen, you can either open PCSX2 emulator and check the box for fullscreen, or add "-fullscreen" (old way was "--fullscreen" (2 dashes) [both without quotes]) to the command-line parameters.  (sorry. I had forgot about the -nogui part)

Link to comment
Share on other sites

  • 2 weeks later...

I was wondering if anyone knew how to set the save and load states for Citra in the pause menu? By default it's Ctrl+V and Ctrl+C to load and save games on that emulator so I thought this would work:

Quote

Send {Ctrl down}
Sleep 50
Send {C down}
Sleep 50
Send {C up}
Sleep 50
Send {Ctrl up}
Sleep 50

Cos thats how it works for Snes9x but it's Shift+F1 instead of Ctrl+C. But I'm honestly clueless how it works and it's clear that not all emulators pick up the same AHK commands.

Does anyone know how I would add load and save states to the pause menu for citra games? 

 

Link to comment
Share on other sites

16 hours ago, Madhead said:

I was wondering if anyone knew how to set the save and load states for Citra in the pause menu? By default it's Ctrl+V and Ctrl+C to load and save games on that emulator so I thought this would work:

Cos thats how it works for Snes9x but it's Shift+F1 instead of Ctrl+C. But I'm honestly clueless how it works and it's clear that not all emulators pick up the same AHK commands.

Does anyone know how I would add load and save states to the pause menu for citra games? 

 

could be because you used a generic "Ctrl" key instead of specifying which one. Try using the same script but use "LCtrl" instead. Also do not capitalize "C" due to it would imply sending a capitalized C which requires also hitting the shift key. So I believe what your script is actually sending is more like "Ctrl, SHIFT, C" and that alone might make the Citra hotkey not work.

AHK is weird here, it doesn't matter if the letter is capital or not if it's a hotkey. ie if you make two hotkeys like so, both of these would work the same, exiting the script

A::ExitApp

a::ExitApp

Both of those hotkeys would trigger with the "a" or "A" key press, as in whether or not you hold the shift key. So using "a" or "A" is interchangeable in the context of a hotkey. Lowercase/uppercase doesn't matter

But when a letter is in the send command it is case sensitive as I described above.

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