Jump to content
LaunchBox Community Forums

autohotkey script from within Launchbox


makaveeti

Recommended Posts

Hi guys, 

I'm new here. Firstly, great work with the Launchbox application - I love it and look forward to buying a license.

I've having a slight issue with autohotkey scripts. I imported 'Streets of Rage Remake' which is a windows game. There is no exit option from the main menu of the game. To exit the game Esc must be pressed. I wrote a script in AHK to map one of my controller buttons to the Esc key. This doesn't work using a AHK script in Launchbox or when building a standalone ahk EXE. 

 

I approached the issue from a different angle and wrote the following script and tested it using a standalone AHK exe file. It's programmed to look for an active window for Streets of rage remake game and exit when button 7 is pressed whilst holding button 8 on the controller.

 

Joy7:: 

If GetKeyState("Joy8") 

{ WinClose, Streets of Rage Remake - v5.0a

}

Return

 

As a standalone AHK script, this works well. The issue is that when I paste the same code into Launchbox on the AHK script tab, it has no effect whilst I'm in the game. 

Is this a defect? Can you guys offer any advice please?

Link to comment
Share on other sites

I use an Xpadder profile to exit Streets of Rage Remake by mapping the F12 key to my Select button. I use SORR v5.1 though, I'd recommend that version, it has over 100 bugfixes and improvements over v5.0a.

Edited by Charco
Link to comment
Share on other sites

Hey Dos76, 

Correct me if I'm wrong but I think Brad is referring to the Control Automation section in the LB Options section. It's greyed out in the free version and available with a premium licence. My original post is referring to the autohotkey script tab under the manage emulators section.

Link to comment
Share on other sites

31 minutes ago, DOS76 said:

I know you are discussing ahk I'm unsure if they work from your LB if you don't have a license. I could be wrong but it could explain why the script works stand alone but not from within LB 

It could.. would be good if a LB developer could clarify this.

Link to comment
Share on other sites

AHK works without Premium. What I was getting at was Controller Automation only, which is built in with LB Premium. I honestly don't know why the script wont work in LaunchBox. I don't recall this ever happening often. It could be the way LB launches AHK, or the script doesn't like being ran from LB. @Jason Carr or another AHK person might know.

Link to comment
Share on other sites

@makaveeti , why don't you try converting your ahk script to an executable (.exe). then add your ahk exe to your LB game in the additional apps tab (right click game and choose edit to get there). set your ahk exe file to run before the game. then see if it works that way as a stand alone. in this way, the ahk will not be run using LB builtin ahk. you probably don't need to convert your .ahk file to try this, but if you don't, you'll have to make sure your full autohotkey installation can be found by your .ahk script.

Link to comment
Share on other sites

@ckp

I already tried converting the script to an exe and setting to launch before the game. This works successfully. I might have to settle for this as a last resort.

I was just trying to obtain an explanation as to why the code doesn't do anything when pasted in the LB built-in akh.

 

Link to comment
Share on other sites

You can add this simple script to the ahk tab and see if it triggers. try it as the first line without a hotkey so it runs right away and try it in an escape hotkey also to see if it runs on escape.

MsgBox I am a message without hotkey.

And put this line inside your escape key section:

MsgBox I am a message with hotkey.

At least this will give us more info.

Edited by ckp
Link to comment
Share on other sites

Try this:

; Exit
4Joy17::
   SetKeyDelay, -1, 110
   Process, Close, {{{StartupEXE}}}
Return

(4Joy17 = joystick no 4, button 17. You must change it to reflect your own joystick number and button, for example 1Joy2 = Joystick 1, button 2)

  • Like 1
Link to comment
Share on other sites

@ckp

Thanks for that recommendation dude. Good idea to try alternative code to check if it works. I'm not a coder by nature and put together my original code via alot of trial and error. Can you confirm exactly what code you want me to paste into the ahk tab please?

Link to comment
Share on other sites

sure, just put in there what you already tried but make the very first line this, before your code:

MsgBox I am a message without hotkey.

and replace your WinClose line with this:

MsgBox I am a message with hotkey.

 

run the game from LB. You should get a message popup right away. This first popup would prove autohotkey script is running and working.

close the first popup.

then exit the game that you have set for your controller to exit in your ahk script. Now you should get a popup again (but the game won't exit because its just a test). This second popup would prove if your controller hotkey is triggering.

Edit: don't forget to remove your ahk exe additional app setting before you try this.

If you get both popups, then I would think @makaveeti suggestion to use Process, Close should work instead of using WinClose

Edited by ckp
Link to comment
Share on other sites

18 minutes ago, Crush said:

Try this:

; Exit
4Joy17::
   SetKeyDelay, -1, 110
   Process, Close, {{{StartupEXE}}}
Return

(4Joy17 = joystick no 4, button 17. You must change it to reflect your own joystick number and button, for example 1Joy2 = Joystick 1, button 2)

This works in a standalone AHK exe. The code is different to my script which also works in a standalone AHK exe. Thanks for showing me.

Link to comment
Share on other sites

15 minutes ago, ckp said:

sure, just put in there what you already tried but make the very first line this, before you code:

MsgBox I am a message without hotkey.

and replace your WinClose line with this:

MsgBox I am a message with hotkey.

 

run the game from LB. You should get a message popup right away. This first popup would prove autohotkey script is running and working.

close the first popup.

then exit the game that you have set for your controller to exit in your ahk script. Now you should get a popup again (but the game won't exit because its just a test). This second popup would prove if your controller hotkey is triggering.

 

I amended the code. Tried it as a standalone EXE just to verify the code. It works as a standalone AHK exe. A message box pops up saying 'I am a message without hotkey' then when I trigger my gamepad buttons I see the message 'I am a message with hotkey'.

I pasted the code into the AHK script tab in LB and launched my game but it doesn't work ;(

Edited by makaveeti
Link to comment
Share on other sites

15 minutes ago, makaveeti said:

I pasted the code into the AHK script tab in LB and launched my game but it doesn't work ;(

So you didn't get ANY popup when using it in the ahk tab?

@Jason Carr, is the ahk tab functionality supposed to be included in the free version of Launchbox?

 

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