Jump to content
LaunchBox Community Forums

Auto Hotkey Scripts


Lordmonkus

Recommended Posts

On 12/19/2021 at 10:15 AM, JoeViking245 said:

@whazzzzzup17  So glad it's working as it should!!!!!!!   

Well, I broke down and actually tested it with RA on my cab. Finally. lol  Though I did 'cheat' and used [up to 4 instances of] the same retroarch.exe for each launch.  😊  Going through this (now, properly) I saw some things with the code that could be improved and cleaned up.

  • The Sleep 'timer' was kind of a cheesy and was bugging me, so I changed it to WinWait.  Now there's no guessing as to how long to set it.
  • I looked closer at the RemoveMenuBar method and saw it was only working on the "Active window".  Doh!  It was also long and ugly, so I revamped the 24-lines of code into 2 lines AND it [now] works on the window we tell it to.  I know this is a moot point because of the recent 'discovery' of turning off the menu bar directly in RA.  But it now actually works, regardless of the setting in RA.
  • The Loops inside each "If (UserInput=)" are all the exact same, so I moved them to single method and now just call that method.

Fun project!  Thanks.

I couldn't get them to align with this code. Probably the removal of the Sleep.

Link to comment
Share on other sites

24 minutes ago, whazzzzzup17 said:

I couldn't get them to align with this code.

Is the title bar, border and menu being removed on all of them?  Are the windows being stacked on top of each other?  Or are some moving and the rest stacking? They're not trying to open fullscreen ae they? Is it not aligning in all 4 scenarios?  (well 3 actually. Selecting "1" shouldn't need any aligning. ;))  Or is it they just have gaps in between them?  Maybe double check the WinMove lines.  I may have transposed their placement or something. It's been known to happen with me.  

Link to comment
Share on other sites

34 minutes ago, whazzzzzup17 said:

Everything works except the move.

Try adding a sleep after RemoveExcess().  Either inline (3 locations) or in the method itself (add a 'Sleep' line in between the last 2 close brackets).

38 minutes ago, whazzzzzup17 said:

thats also removed from Retroarch settings.

Because it's part of retroarch.exe.  If you need to tweak the emulator(s), you'll want to comment out RemoveExcess().  Or do them stand alone.

Link to comment
Share on other sites

21 hours ago, whazzzzzup17 said:

Everything works except the move.

Fixed script in previous post. (read below for "other" fixes added too)

The WinMove did work. The issue was you couldn't "see" it move until 'that' window took focus.  (Alt+Tab to the 'other' window(s) would set focus and then show it in its proper location on the screen)

[Still] no need for guessing Sleep times.  YAY!  After WinMove, added a WinActivate call to set focus and "show" the move(s).  At least it worked in my tests. ;) 

 

I noticed that with 3 screens, in the lower right [monitor] corner you see whatever is behind (LaunchBox, desktop icons, desktop wallpaper...).  2 possible solutions to hide that are:

A) make the 3rd screen fill the whole bottom half (though would probably look bad) 

or B) use the "fixed script" to have it:

  • Minimize all windows
  • Hide the desktop icons
  • Set the Windows wallpaper to null
  • Set the background color to black

then at the end of the script

  • Restore LB/BB window
  • Unhide the desktop icons
  • Reset the wallpaper back to what it was (if one was being used)
  • Reset the background color back to what it was (if other than black)
Link to comment
Share on other sites

On 12/31/2021 at 7:33 AM, JoeViking245 said:

Fixed script in previous post. (read below for "other" fixes added too)

The WinMove did work. The issue was you couldn't "see" it move until 'that' window took focus.  (Alt+Tab to the 'other' window(s) would set focus and then show it in its proper location on the screen)

 

I'm still noticing the same issue about the windows not moving. I do however, have 3 screens, and it made me wonder, that even though this was intended to use on my single tv, is there in option to use (2) or (3) monitors and if the user selects 2 or 3, it could do full screen on those monitors?

Link to comment
Share on other sites

1 hour ago, whazzzzzup17 said:

is there in option to use (2) or (3) monitors and if the user selects 2 or 3

Dude! You're killing me!! lol   You'd need to change the WinMove coordinates.  But since they're not moving in the 1st place, it seems like that won't work.  You might could do a WinActivate on one of the widows, then do a "Send #{Left}"  (aka hold the Windows key and hit the left arrow key) which might send it to the monitor to the left.  Then probably a WinMaximize to get it full screen.  

You wanna attach the script you're attempting to use?  There could be some simple little thing that's holding you back.  Just a thought.

Link to comment
Share on other sites

3 hours ago, JoeViking245 said:

Dude! You're killing me!! lol   You wanna attach the script you're attempting to use?  There could be some simple little thing that's holding you back.  Just a thought.

Hahah my apologies, just thought I would report back. I'm actually doing fine with the original script you provided with the Sleep. I have used the exact scripts after that for testing, didn't change a thing, and can't get them to move.

I'll continue using the Sleep one as it is working out great. Thank you

  • Like 1
Link to comment
Share on other sites

Hey guys. Wondering if i could get help with an AHK  script for a pc game that wont close unless i press Alt and F4. I wanted to load the ahk in the additional apps and have it wait as long as i need to. and when i press escape, i wanted it to send Alt + F4. then close ahk afterwards. after i get the script how would i insert it in here?

add application.jpg

Link to comment
Share on other sites

10 hours ago, Cnells2000 said:

when i press escape, i wanted it to send Alt + F4. then close ahk afterwards

$Esc::
Send, !{F4}
ExitApp

 

10 hours ago, Cnells2000 said:

how would i insert it in here

Under the Application Command-Line Parameters:, put "full/path/to/the/.ahk" file you created [including quotes].

 

But doesn't LB/BB try to pass the Esc keypress to the game and also attempt Alt+F4 when you press the button [combo] you assigned?

 

Link to comment
Share on other sites

Hi 

I’m having issues with closing out Teknoparrot via BigBox

I use Brook Universal Fighting Boards in my arcade cabinet which, as I understand, uses XInput.  

I’ve got the Xbox guide button (button 13) mapped to the ‘Close Active Window’ option, but this doesn’t seem to do anything for this particular emulator.  This functionality works fine in other emulators (MAME for example)

I’ve been trying to use some of the more generic Autohotkey exit emulator scripts in this thread, but not having any luck wondering if I need something more specific to Teknoparrot to force it to close - can anyone help me with the syntax?

Thanks!

Link to comment
Share on other sites

45 minutes ago, evilmrfrosty said:

I’ve got the Xbox guide button (button 13) mapped to the ‘Close Active Window’ option, but this doesn’t seem to do anything for this particular emulator.  This functionality works fine in other emulators (MAME for example)

This seems correct. When you press the button you have entered under "Close the Active Window", LaunchBox sends a virtual key press of the Escape key for emulators that close with Escape natively.

50 minutes ago, evilmrfrosty said:

I’ve been trying to use some of the more generic Autohotkey exit emulator scripts in this thread, but not having any luck wondering if I need something more specific to Teknoparrot to force it to close - can anyone help me with the syntax?

TeknoParrot should close with Escape natively. In the TeknoParrot settings make sure that "Confirmation prompt on exit" is unticked. And that "Global Hotkeys > Exit Game Key" shows the virtual-key code: 0x1B.

1947933167_Schermopname(34).thumb.jpg.b3ed5eb17e7696b93c8b4bd4acfc7a07.jpg

0x1B = Escape.

If this still does not work, you can try the following and see if it makes a difference:

- Disable Startup- / Shutdown screen for your game or TeknoParrot in general.

- Check if you run TeknoParrot with Admin rights. --> Run TeknoParrot as normal.

Link to comment
Share on other sites

2 hours ago, Your_Friendly_AI_Overlord said:

This seems correct. When you press the button you have entered under "Close the Active Window", LaunchBox sends a virtual key press of the Escape key for emulators that close with Escape natively.

TeknoParrot should close with Escape natively. In the TeknoParrot settings make sure that "Confirmation prompt on exit" is unticked. And that "Global Hotkeys > Exit Game Key" shows the virtual-key code: 0x1B.

1947933167_Schermopname(34).thumb.jpg.b3ed5eb17e7696b93c8b4bd4acfc7a07.jpg

0x1B = Escape.

If this still does not work, you can try the following and see if it makes a difference:

- Disable Startup- / Shutdown screen for your game or TeknoParrot in general.

- Check if you run TeknoParrot with Admin rights. --> Run TeknoParrot as normal.

Thanks for your help - no luck on any of those suggestions, unfortunately

Teknoparrot does close with the Escape key as intended on the keyboard, so I'm at a bit of a loss as to where to go next :D

Link to comment
Share on other sites

9 minutes ago, evilmrfrosty said:

Thanks for your help - no luck on any of those suggestions, unfortunately

Teknoparrot does close with the Escape key as intended on the keyboard, so I'm at a bit of a loss as to where to go next :D

In LB under >Tools >Manage >Emulators edit TeknoParrot.

In the Running Script tab try putting this script in.

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

 

Link to comment
Share on other sites

14 hours ago, Retro808 said:

In LB under >Tools >Manage >Emulators edit TeknoParrot.

In the Running Script tab try putting this script in.

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

 

Thanks for this - really helpful

Whilst this doesn't let me exit out of the game straight away, it does bring up the Pause Menu, where if I select the 'Exit Game ' functionality from there it's exiting out of the emulator.  Previously selecting Exit Game would just close the Pause Menu and return me to the game!  

Given the grief this has caused me, I'm taking it as a result though! :D 

  

Link to comment
Share on other sites

2 hours ago, evilmrfrosty said:

Thanks for this - really helpful

Whilst this doesn't let me exit out of the game straight away, it does bring up the Pause Menu, where if I select the 'Exit Game ' functionality from there it's exiting out of the emulator.  Previously selecting Exit Game would just close the Pause Menu and return me to the game!  

Given the grief this has caused me, I'm taking it as a result though! :D 

  

This does not make sens. Can you provide a pic of the script and where you placed it. I think you put it in the wrong spot. Needs to specifically be in the one I mentioned.

Link to comment
Share on other sites

2 hours ago, evilmrfrosty said:

Thanks for this - really helpful

Whilst this doesn't let me exit out of the game straight away, it does bring up the Pause Menu, where if I select the 'Exit Game ' functionality from there it's exiting out of the emulator.  Previously selecting Exit Game would just close the Pause Menu and return me to the game!  

Given the grief this has caused me, I'm taking it as a result though! :D 

  

Sounds like you put the script in the Exit Script instead of the Running Script. Exit script is what is ran when you press Exit Game on the Pause screen. Running script is ran while the game/emulator is being played.

Link to comment
Share on other sites

2 hours ago, Retro808 said:

This does not make sens. Can you provide a pic of the script and where you placed it. I think you put it in the wrong spot. Needs to specifically be in the one I mentioned.

 

52 minutes ago, C-Beats said:

Sounds like you put the script in the Exit Script instead of the Running Script. Exit script is what is ran when you press Exit Game on the Pause screen. Running script is ran while the game/emulator is being played.

 No worries!

I've attached my Running Script & Exit Script tabs, a copy of my Teknoparrot settings, along with my InputBindings.xml, in the event there's any conflicts/issues in there that you can spot (I've tried changing the input bindings  for a single key and a combo, with no difference in results)

 

RunningScript.PNG

ExitScript.PNG

TPSettings.PNG

InputBindings.xml

Link to comment
Share on other sites

1 hour ago, Retro808 said:

@evilmrfrosty So where you have it in the pics, the emulator is only closing properly from the Pause Menu?

Can you paste it both in the Running Script and the Exit Script pages and test.

Adding to both seems to kill the Pause Screen only, with TP still running in the background.

Wondering if there's something else that's conflicting in my settings that's driving things haywire?  I've attached my most recent xml files 

BigBoxSettings.xml Settings.xml InputBindings.xml

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