Jump to content
LaunchBox Community Forums

Auto Hotkey Scripts


Lordmonkus

Recommended Posts

On 4/15/2018 at 1:37 AM, jayjay said:

This is the same script as the one I posted above. Except with no dpad or mouse wheel, only has the mouse pointer and 3 buttons. Also uses the left analogue not right. If you need to change anything compare this script with the one above. I tested it and it works through LB.

Thanks, I will try this out and see how well it works.  

Link to comment
Share on other sites

  • 3 weeks later...

Just wrote this script for someone who was having issues in the Emulation thread, with the new Dolphin master file that is having issues with the program windows staying on top of the emulated window.  This script will search for the main Dolphin 5.0 window and minimize it, allow just the emulated game/window to be in fullscreen.  Figured I'd post it here too since this thread is solely related to AHK script :)

SetTitleMatchMode 1
SetTitleMatchMode Fast
WinWait, Dolphin 5.0, , 10
if ErrorLevel
{
    MsgBox, WinWait timed out.
    return
}
else
    WinMinimize  ; Minimize the window found by WinWait.

 

  • Thanks 2
Link to comment
Share on other sites

3 hours ago, CDBlue said:

Just wrote this script for someone who was having issues in the Emulation thread, with the new Dolphin master file that is having issues with the program windows staying on top of the emulated window.  This script will search for the main Dolphin 5.0 window and minimize it, allow just the emulated game/window to be in fullscreen.  Figured I'd post it here too since this thread is solely related to AHK script :)


SetTitleMatchMode 1
SetTitleMatchMode Fast
WinWait, Dolphin 5.0, , 10
if ErrorLevel
{
    MsgBox, WinWait timed out.
    return
}
else
    WinMinimize  ; Minimize the window found by WinWait.

 

This isn't really necessary if you use DolphinWx.exe which is included in the program's folder. However, this script seems to work pretty well too :) Thank you for sharing! 

Link to comment
Share on other sites

Yeah, I figured why not write one.  Saw a few people having issues with Dolphin.exe since they made that version use the qt GUI, and moved the old wx gui to the DolphinWx.exe.  Eventually, I think the plan is to drop support all together for the old Wx gui and go just with the qt version.  Hopefully they will fix the issue of the qt version staying on top of the emulator window when dolphin is launched from launchbox, but in the mean time I figured this might be helpful to some people :)

Link to comment
Share on other sites

  • 2 weeks later...
On 18/05/2018 at 7:51 PM, RogerioX said:

Is there a way to make it so pcsx2 closes when i hold back, start, l1 and r1 for 2 seconds?

There might be a way with a timer and a loop or something. Im not sure. You could try this though:

Joy5::
if GetKeyState("Joy6")
if GetKeyState("Joy7")
if GetKeyState("Joy8")
Goto, close
Return

Joy6::
if GetKeyState("Joy5")
if GetKeyState("Joy7")
if GetKeyState("Joy8")
Goto, close
Return

Joy7::
if GetKeyState("Joy5")
if GetKeyState("Joy6")
if GetKeyState("Joy8")
Goto, close
Return

Joy8::
if GetKeyState("Joy5")
if GetKeyState("Joy6")
if GetKeyState("Joy7")
Goto, close
Return



close:
{
	keywait, joy8, t2
	if errorlevel <> 0
	{
		Process, Close, {{{StartupEXE}}}
        }
}

I copy and pasted this from a couple of other scripts on this site. Basically you would have to press back, start, l1 and r1. And then hold down start for 2 seconds to exit. I know its not holding all 4 buttons but unless someone else would be kind enough to come up with something, its better than nothing right? Sorry I don't really have the time to look into it.

  • Thanks 2
Link to comment
Share on other sites

No that works, man. I just want to make sure that resetting the emulator doesn't happen by accident. I'll try it out.

One last thing. Does holding start for two seconds only work if the other buttons are held down too?

EDIT- just tested it and it works pretty good. you're a life saver. I could never play my other emulators besides retroarch because I always play away from the pc, so you really made it much better. thanks.
The way this works as tested is that you have to press all the buttons and hold start. if you hold start and press all the buttons after two seconds, it doesn't work. which lessens the chance of an accident happening.
Some game might require you to hold start or something. you never know. 

Anyway. thanks a lot, dude. you're awesome. my dc emu and other more recent nintendo emus will get this too. 

Edited by RogerioX
  • Like 1
Link to comment
Share on other sites

Looking for some help:

The universal close emulator AHK works fine for CEMU, but for RPCS3, it doesn't appear to work. I think what is happening is because it has a launcher, and then it opens up the game in a second window, that it is only closing out of the launcher and not the launcher + game. Anyone have any ideas?

Link to comment
Share on other sites

lol. @JamesBond@ge. There are plenty of others here that are better than me, even some of the mods are. But I suspect they don't want the hassle when things don't work. Which is fair enough.

 

@TechTonic. Open RPCS3, go to configuration settings. Open "emulator" tab and select "Exit RPCS3 when process finishes". Although the "universal close emu ahk" works fine for me with it selected or not.

Edited by jayjay
Link to comment
Share on other sites

Hi I am wondering if this can be solved with AHK? does anyone have experience with loading an additional app before the emulator loads? I am loading an app (touchmote ) that is causing mame to lose focus(which means I need to alt tab back into mame) any idea on how to solve this?

Link to comment
Share on other sites

Sleep, 625
SetKeyDelay, -1, 110
Send {Click 35, 380}
Sleep, 10
SetKeyDelay, -1, 110
Send {Click 40, 80}
Sleep, 10
SetKeyDelay, -1, 110
Send {F11}
Return

I tried to use this script for phoenixemuproject for Jaguar as there is no command line argument for choosing platform, booting up and fullscreen.

I only tested this with Alien vs Predator so I'm not sure if it really work.

Edit:Nope, it fail. Still worth trying.

Edited by Mayora13
Link to comment
Share on other sites

Sorry if this has been asked before, I have done a fair bit of searching and havent found a simple answer to this question:

How do I automatically kill AutoHotKey after I finish playing a game?

I have the script run and it works perfectly, the key remaps are a dream! But when I exit the game and go back to BigBox the script is still running which is obviously not good.

I know I can add the ExitApp command and bind it to a key but thats not a clean solution as I want it to kill the app automatically.

Link to comment
Share on other sites

@elements604 do u load touchmote with specific games or with a whole platform? Also can u tell me the exact window title for your mame include upper case letters etc.  

 

@Traffik what are u using the script on? An emulator or windows games etc? Would be easier to give u an example if i knew what .exe ur using. Retroarch.exe or etc etc And also can u post ur script up. 

 

Cant guarentee i'll get back to either of u quickly but will when i get the time... unless someone else wants to chime in. 

Edited by jayjay
Link to comment
Share on other sites

  • 2 weeks later...
On 10/13/2017 at 7:24 AM, Adoril said:

Using the process,close script with higan causes issues with the higan not having chance to update the save.ram file. 

At the moment the only solution I've found is to use the 

ESC::

send !{f4}

But this only works if higan is not full screen. When I try and map the full screen toggle button to the AHk script it doesn't work, higan just ignores it. Is there any way to write a script to get around it?

 

I'm having this same problem. Bashing my head against the AHK docs with no real results. BUT I GOT IT TO WORK!!!!!!  OK, here's the code.  It's nice and short:

Esc::
WinActivate, ahk_exe higan.exe
WinWaitActive, ahk_exe higan.exe
WinKill
Return

This will ensure it's only closing higan and nothing else.

Edited by strizzuth
  • Like 2
Link to comment
Share on other sites

  • 3 weeks later...

Hey guys, I am trying to come up with a full TATE/Portrait solution with the BigBox theme I have. Certain emulators etc need to be horizontal screen and not portrait in order to function correctly. I was thinking auto hot key might be the trick. I have iRotate installed and I think this will do everything I need. I just need to send the keystrokes and I have basically no understading of AHK. This is what I am thinking:

 

; This section closes nullDC when pressing Escape
$Esc::
{
    Process, Close, {{{StartupEXE}}}
        $^!Right::
}

 

Basically, I'm  trying to send CTRL ALT RIGHT on ESC so that the screen will go back to portrait for BigBox

 

Also, I'd like to add CTRL ALT UP at the start of the scipt to set the screen orientation to horizontal on start up of emulator.

 

Thanks for any and all help!

Link to comment
Share on other sites

10 hours ago, nlen83 said:

snip

Might need more information.

 

What emulator are you using.

Is it for every game on the emulator or just specific games. Im assuming its every game on the emulator.

When using the emulator on its own (not through launchbox) does esc exit the emulator. Im assuming it does.

Do you have irotate run on computer start up or only when you start a emulator or ???. Im assuming start up.,

 

Just to note... When using ahk through LB... when you close the emulator LB kills the ahk script. So any commands after emulator exit are not executed. So the script you posted above is unlikely to work correctly. Its a race condition.

 

With my assumptions you could try the following:

 

Go to directory Launchbox\Metadata\Temp, Create a txt file. Rename the txt file to Rotate.ahk (or whatever you want but the file extension needs to be .ahk.

 

Right click on Rotate.ahk. EDIT.

 

Copy and paste the following:

#SingleInstance force

Send {ctrl down}{alt down}{up down}{ctrl up}{alt up}{up up}
return

esc::
{
Send {ctrl down}{alt down}{right down}{ctrl up}{alt up}{right up}
Exitapp
}

Save it.

 

In Launchbox go to the emulator autohotkey script tab.

Copy and paste the following:

SetWorkingDir %A_ScriptDir%
run, Autohotkey.exe "Rotate.ahk"

 

This might not work as you want just yet. It might rotate the screen to quickly or maybe not at all. If it doesn't work correctly reply with whats happening and the more info.

 

Edit... Actually... duh... what might work...  if esc doesn't close the emulator on its own you could use the script you posted, slightly changed, add it to LB emulator ahk script tab. I dont know the short hand for sending keystrokes so change it if you feel the need:

 

Send {ctrl down}{alt down}{up down}{ctrl up}{alt up}{up up}

 

$Esc::

{

Send {ctrl down}{alt down}{right down}{ctrl up}{alt up}{right up}

Process, Close, {{{StartupEXE}}}

}

 

Edited by jayjay
Link to comment
Share on other sites

I'll give it a try today, thank you! I had the beginnings of that going yesterday, code wise, but i think the syntax was a little off as it left the pc thinking i was still holding a button. 

This is going to be for nullDC and PCSX2 currenlty. I'd also like to do this for a few Steam games if its possible.

 

Anyways, i will let you know a bit later today....really appreciate the assistance!

Edited by nlen83
typos
Link to comment
Share on other sites

16 hours ago, jayjay said:

Might need more information.

 

What emulator are you using.

Is it for every game on the emulator or just specific games. Im assuming its every game on the emulator.

When using the emulator on its own (not through launchbox) does esc exit the emulator. Im assuming it does.

Do you have irotate run on computer start up or only when you start a emulator or ???. Im assuming start up.,

 

Just to note... When using ahk through LB... when you close the emulator LB kills the ahk script. So any commands after emulator exit are not executed. So the script you posted above is unlikely to work correctly. Its a race condition.

 

With my assumptions you could try the following:

 

Go to directory Launchbox\Metadata\Temp, Create a txt file. Rename the txt file to Rotate.ahk (or whatever you want but the file extension needs to be .ahk.

 

Right click on Rotate.ahk. EDIT.

 

Copy and paste the following:


#SingleInstance force

Send {ctrl down}{alt down}{up down}{ctrl up}{alt up}{up up}
return

esc::
{
Send {ctrl down}{alt down}{right down}{ctrl up}{alt up}{right up}
Exitapp
}

Save it.

 

In Launchbox go to the emulator autohotkey script tab.

Copy and paste the following:


SetWorkingDir %A_ScriptDir%
run, Autohotkey.exe "Rotate.ahk"

 

This might not work as you want just yet. It might rotate the screen to quickly or maybe not at all. If it doesn't work correctly reply with whats happening and the more info.

 

Edit... Actually... duh... what might work...  if esc doesn't close the emulator on its own you could use the script you posted, slightly changed, add it to LB emulator ahk script tab. I dont know the short hand for sending keystrokes so change it if you feel the need:

 

Send {ctrl down}{alt down}{up down}{ctrl up}{alt up}{up up}

 

$Esc::

{

Send {ctrl down}{alt down}{right down}{ctrl up}{alt up}{right up}

Process, Close, {{{StartupEXE}}}

}

 

Ok, @jayjay I did the edit you added later and it does exactly as it should. My issue now is, it seems as though in the quickness of rotation, the app, in this case, nullDC assumes the resolution is portrait still, thus causing it to not go in to a normal fullscreen, it assumes the max resolution in one direction is as it was just milliseconds before, if that makes sense. 

Any ideas for that?

Thanks a ton btw!!

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