Jump to content
LaunchBox Community Forums

Auto Hotkey Scripts


Lordmonkus

Recommended Posts

I appreciate you troubleshooting it with me. It must be something with my setup, because I tried just taking out the script altogether to start. That will close the game window, but obviously the GUI window still remains. Every script I tried just causes the emu to essentially hang when I exit. At this point I almost need an extra script that would run a few seconds around the initial exit in order to close the GUI separately.

Link to comment
Share on other sites

6 minutes ago, TheNewClassics said:

I appreciate you troubleshooting it with me. It must be something with my setup, because I tried just taking out the script altogether to start. That will close the game window, but obviously the GUI window still remains. Every script I tried just causes the emu to essentially hang when I exit. At this point I almost need an extra script that would run a few seconds around the initial exit in order to close the GUI separately.

Are you running the nightly build or canary? Did you change any settings in Citra like the control HotKeys in the configuration? Is it just exiting to the GUI or also asking you to confirm exit?

When you run a game through Launchbox and just hit Alt+F4 (or CTRL+Q) will it exit correctly?

Link to comment
Share on other sites

I'm using canary builds. Didn't touch any of the control hotkeys. Just exiting to the GUI, no confirmation.

Just tried it with keyboard. Alt+F4 just freezes it; I took a look at the hotkeys you mentioned and it does say F4 can pause emulation. But the good news is that Ctrl+Q closes it perfectly. So I just need to put a script together for Ctrl+Q and I bet I'll be good to go. You're the man Retro!

Would it just be 

Esc::

Send, ^q

 

Edited by TheNewClassics
Link to comment
Share on other sites

Hey all I'm finishing up my LB build.. coming from hyperspin I used xpadder for various PC games for button mapping but also exiting, like Alt+F4.

The AHK scripting in LB is a nice feature. How can I add a exit AHK script to games that don't use an emulator... so I can map an exit button for PC games.. (or any executable without an emulator)

Link to comment
Share on other sites

8 hours ago, drewjbx said:

Hey all I'm finishing up my LB build.. coming from hyperspin I used xpadder for various PC games for button mapping but also exiting, like Alt+F4.

The AHK scripting in LB is a nice feature. How can I add a exit AHK script to games that don't use an emulator... so I can map an exit button for PC games.. (or any executable without an emulator)

When you right click and edit a game there is an additional apps tab. You can launch an AHK on a per game basis there. Since you used xpadder I would also recommend Controller Companion. It is only $2.99 on Steam and works like xpadder. I know we have quite a few members and mods that use it with Launchbox. 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

can anyone help me with a script i've been dealing with?

1joy5 & 1joy6::

Process, Exist, osk.exe
if (ErrorLevel) {
PostMessage, 0x112, 0xF060,,, ahk_exe osk.exe
} else {
Run, C:\Windows\System32\osk.exe
}
return

This so far works, but only with 1joy5 and 1joy6 pressed at the same time, which is the shoulder buttons on my controller, how would i do this if i want shoulder buttons AND start + select? (1joy10, 1joy9)

i tried "1joy5 & 1joy6 & 1joy10 & 1joy9::" and similar but doesn't work at all.

Link to comment
Share on other sites

Per https://www.autohotkey.com/docs/Hotkeys.htm

Quote

Combinations of three or more keys are not supported.

This of course excludes modifiers (Alt, Ctrl, Win, Shift....).  

That being said, they continue on with something about GetKeyState. I was able to get a 3 key press to work.  ("key" being a non-modifier, joy/mouse button...)

#if GetKeyState("Z", "P")
X & C::MsgBox X then C were pressed while holding Z.

If while Z is pressed, X and then C are both pressed/held, post the message box.  It seems like they need to be pressed (and held) in that order.  Just change Z, X and C to your 1Joyx.

If you have to have 4 buttons pressed, I'm sure there's a way to do an If-Then-While-Not-Get... overly complicated, brainiac way.  Well, maybe not that bad.

Link to comment
Share on other sites

  • 1 month later...
On 6/3/2019 at 12:10 PM, Retro808 said:

When you right click and edit a game there is an additional apps tab. You can launch an AHK on a per game basis there. Since you used xpadder I would also recommend Controller Companion. It is only $2.99 on Steam and works like xpadder. I know we have quite a few members and mods that use it with Launchbox. 

I can vouch for Controller Companion. I use Controller Companion and Xpadder together. Controller Companion is the only one of the two that can map buttons to the Xbox Guide Button. Like Alt+F4 for Citra and Cemu etc.

Link to comment
Share on other sites

#j::		;press Win+J to start
Sleep, 8000
send, {right}
Process,Wait,notepad.exe
Sleep,1000
send, 6
return

This assumes that when it ('notepad') opens, it has focus.  If it's possible to be already open.... you'll want some more checks and balances in the code.

The 2nd sleep is just a buffer to make sure 'notepad.exe' is fully there.  Probably can be omitted, but a good safety net.  You know. It's Windows and all.

Line 1:  Can be deleted if you don't need a hotkey.   BTW, J is for JoeViking. ?

Link to comment
Share on other sites

So I re-read your post... I think this is more what you were actually asking for.  Srry 'bout that.

Process,Wait,notepad.exe	;wait here until 'my_program.exe' is running
Sleep,8000			;wait for 8 seconds
WinActivate,ahk_exe notepad.exe	;set (make sure) my_program is the active window
send,{right}			;press the right arrow key
send,6				;press the number 6 key

(optional) Line 3 just makes sure that "Right" and "6" are being sent to the program we were waiting for.  Just in case other programs take focus during the 8-sec pause. 

  • Like 2
Link to comment
Share on other sites

You are very welcome.

Ya, there really isn't a way (that I'm aware of) to 'know' if a program has completely loaded.  It can only check that it's started/running.  And like you said, load time can vary depending on what else is working in the background. But at least there's the catch to make sure it has focus so we're not sending keys to another program that may pop up while waiting.  ...which makes line 3 a little less 'optional'. :) 

If 9000 (9 seconds) for sure works, you can always try to trim it down to 8500 or 8800 or 8602 or 8150... you get the picture.  Hey, in this fast paced world why wait 9 seconds when we can get away with just 8.602 seconds. lol

  • Like 1
Link to comment
Share on other sites

On 7/9/2019 at 12:24 AM, Retro808 said:

Looking to the AHK gurus for some help. In need of an AHK that will:

Delay 8 seconds then Send (Right Arrow Key) and then Send "6" after an exe opens. 

You could add a loop that checks if the window exists. Something like

SetTitleMatchMode, 2

Loop
{
	if WinExist("Untitled - Notepad")
	{
		WinActivate
		break
	}
}

send,{right}
send,6

Im rusty on ahk, so you might have to play with it a little. But iv used something like this before, it does work. It should remove the need for sleep... maybe? Unless the window opens and then your waiting for it to load, then you would still need sleep. Ha. 

Edited by jayjay
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...