Jump to content
LaunchBox Community Forums

Auto Hotkey Scripts


Lordmonkus

Recommended Posts

4 hours ago, Cnells2000 said:

press 1+2 simultaneously and that would send Alt+F4

2 & 1::         ;Press 2 THEN 1
   Send, !{F4}
   Return
2::2

I know at least with the I-Pac's, "1" is typically set as the modifier key.  So here you need to press 2 then 1 in a semi-simultaneous fashion.

4 hours ago, Cnells2000 said:

would i paste this in running ahk script or exit ahk script?

It would go in the Running AutoHotkey Script tab of your emulator.  The Exit AutoHotkey Script tab is for the Pause Menu.

  • Like 1
Link to comment
Share on other sites

It may need a key delay in there.

2 & 1::
   SetKeyDelay, 0, 50
   Send, !{F4}
   Return
2::2

To be clear, when you say "arcade controls", you are talking like those on and arcade cabinet. Right?  And 1 and 2 would be like Player1 Start and Player2 Start, respectively?  (Which also happen to be the numbers 1 and 2 on the keyboard)

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

20 hours ago, JoeViking245 said:

It may need a key delay in there.


2 & 1::
   SetKetDelay, 0, 50
   Send, !{F4}
   Return
2::2

To be clear, when you say "arcade controls", you are talking like those on and arcade cabinet. Right?  And 1 and 2 would be like Player1 Start and Player2 Start, respectively?  (Which also happen to be the numbers 1 and 2 on the keyboard)

found out i didnt need the emulator section. so i made an ahk and I pasted the above in the script. im getting this error now.

Untitled.jpg.1e550a8ecec981fb9231404027e00eb1.jpg

Link to comment
Share on other sites

36 minutes ago, JoeViking245 said:

Oops.  Fixed the original post.  "SetKeyDelay, 0, 50"

@JoeViking245error not popping up but its still not working. this is the toughest game ever. can you make this a hold 1 for 3 seconds and send alt+F4? and when i finally push esc when done playing to exit the ahk,exe? bc i see its still running

Edited by Cnells2000
Link to comment
Share on other sites

2 hours ago, Cnells2000 said:

can you make this a hold 1 for 3 seconds and send alt+F4?

 

1::
{
   KeyWait, 1, T3      ;wait to see if "1" is pressed for 3 seconds ("T3" = Time 3 seconds)
   if (ErrorLevel)     ;if pressed for 3 seconds
   {
      send !{F4}       ;send Alt+F4
      ExitApp          ;close this script
   }
   else                ;if held less than 3 seconds
   {
      1::1             ;send "1" (like a regular keypress)
   }
}

Since the 'press 2 then 1' script didn't work, not sure if this will either.  Also left out the 'SetKeyDelay' line.  You may [still] or may not need it.

This assumes that when you press "1" for 3 seconds, you also will be exiting the game. So after it sends Alt+F4, it will close this script ("ExitApp"). 

But this will also close whatever ahk script you made and had pasted this into.  If your script has other functions too, you may want to remove the "ExitApp" line and put it somewhere else in your script so the other functions still work.

  • Thanks 1
Link to comment
Share on other sites

On 2/18/2021 at 11:26 PM, JoeViking245 said:

 


1::
{
   KeyWait, 1, T3      ;wait to see if "1" is pressed for 3 seconds ("T3" = Time 3 seconds)
   if (ErrorLevel)     ;if pressed for 3 seconds
   {
      send !{F4}       ;send Alt+F4
      ExitApp          ;close this script
   }
   else                ;if held less than 3 seconds
   {
      1::1             ;send "1" (like a regular keypress)
   }
}

Since the 'press 2 then 1' script didn't work, not sure if this will either.  Also left out the 'SetKeyDelay' line.  You may [still] or may not need it.

This assumes that when you press "1" for 3 seconds, you also will be exiting the game. So after it sends Alt+F4, it will close this script ("ExitApp"). 

But this will also close whatever ahk script you made and had pasted this into.  If your script has other functions too, you may want to remove the "ExitApp" line and put it somewhere else in your script so the other functions still work.

Yes You were right it did'nt work. i appreciate your @JoeViking245help on this but i guess ill just have to break out the keyboard when playing this one. thank you

  • Like 1
Link to comment
Share on other sites

Not entirely certain as to where I should post this due to the nature of my question, I am posting here because I feel this is the best spot though because of how my posting ends...

There are tools like IObit uninstaller that checks against your installed apps to alert you of available updates (should you set it to do so). Which got me to thinking and now I am looking for a utility (or AHK script) that does the same thing. I have done a fair bit of googling but cant find anything like this, most likely my wording ?. It would be nice to have a little utility that run in the notification tray or as a task or just when ran from double clicking where with it you can either:

  • A) tell it the emus you are using by directing it to your emu's directory - or -
  • B) there could be a drop down box and a way to tell it each of the emus' update address(es) - or -
  • C) anything that comes close, the first two were just ideas of features I am looking for.

Even if it isn't meant for just emus but just programs of our choice that we would want it to be checking updates for. 

I am completely open to trying out ahk scripts, as I imagine that this is quite possible with a little bit of scripting "sorcery". I am not even close to being proficient at coming up with scripts this sophisticated on my own. 

Honestly, the more I think of this as I am typing this out.. the more I feel that AHK is the way and it wouldn't even need a schedule, it can just be ran with a hotkey or running the script. IDK If it is doable, but if it is... I only need a basic example and can build from that. Meaning if I can have a single chunk of code that I would:

  1. Name the emu
  2. Set the emu's update URL
  3. set the download path and to append the date at the end
  4. if there is an update automatically download and give a pop up box saying the downloads are complete requiring the ok button to be complete

I hope I am not being too needy. I hate asking for help tbh.

 

Link to comment
Share on other sites

Total noob to AHK and hoping someone can point me in the right direction for a little help. I am using reWASD with certain emulators (basically anything that isn't Retroarch). Based on the super helpful folks in this thread, I have learned much and almost got it working as I would like. There are two slight issues:

1. It opens fine, but I need to mouse click on the game screen to focus for the reWASD input to work. Xpadder exhibited the same behavior, Likely there is something I am unaware of I need in my script. I did observe that this does not happen if I have game start screens off, but I like them and hope there is a way to work with it here.

2. When closing games, it is two presses of escape with this script. This one is not a deal breaker, but it would be nice for a single press. It does close the game and reWASD though. Strangely, it was not working when I tried Xpadder instead. 

 

Here's my current script:

Run, C:\Users\brent\Desktop\reWASD\reWASD.exe /m
$Esc::
{
  WinClose, ahk_exe reWASD.exe
  ExitApp
}

Edited by TinyTsuruta
clarified info
Link to comment
Share on other sites

@TinyTsuruta 

  1. Is it safe to assume that the "/m" is a command line parameter for reWASD [itself] to open (run) minimized?  It sounds like it might be holding focus.  Maybe try AHK's "Min" option.
  2. The $Esc:: hotkey may be conflicting with the exit routine of the emulator.  Try including WinClose for the emulator as well.

 

Run, C:\Users\brent\Desktop\reWASD\reWASD.exe,,Min
$Esc::
{
   WinClose, ahk_exe reWASD.exe
   WinClose, ahk_exe mame64.exe
   ExitApp
}

 

Link to comment
Share on other sites

32 minutes ago, JoeViking245 said:

@TinyTsuruta 

  1. Is it safe to assume that the "/m" is a command line parameter for reWASD [itself] to open (run) minimized?  It sounds like it might be holding focus.  Maybe try AHK's "Min" option.
  2. The $Esc:: hotkey may be conflicting with the exit routine of the emulator.  Try including WinClose for the emulator as well.

 



Run, C:\Users\brent\Desktop\reWASD\reWASD.exe,,Min
$Esc::
{
   WinClose, ahk_exe reWASD.exe
   WinClose, ahk_exe mame64.exe
   ExitApp
}

 

Thanks @JoeViking245 ! I tried that with reWASD and it will not launch. It does work with XPadder though, at least opening. Xpadder is staying running on game close though. I also noticed with reWASD, it would show the app as closed and not running, but my controllers are "stuck" with the settings until a restart. Now wondering if I should just stick with Xpadder, assuming I can get it to close with games!

As for the /m, I have no idea what it means other than the code snippets in the forums for it had it for Xpadder so I transferred it over. Apologies for my ignorance!

Edited by TinyTsuruta
Link to comment
Share on other sites

21 hours ago, TinyTsuruta said:

I tried that with reWASD and it will not launch

That's odd that it worked before, but not when adding  ",,Min".

Briefly looking at the reWASD site, it looks like you can associate a game (or in your case an emulator?) to a specific configuration.  Then with reWASD running in the background (sitting 'idle'), when you load a game (emulator) it then loads the corresponding configuration.  I would assume with it setup like that, that when you close the game (emulator), it unloads the configuration and goes back idle.  Or goes back to a "default" configuration if setup that way (which is what you don't want).

Ahhhh... there it is. Or pretty close.  Item #4 in their FAQ's.  https://forum.rewasd.com/forum/rewasd/technical-questions-aa/30703-need-some-help-start-from-this-faq

Link to comment
Share on other sites

4 minutes ago, JoeViking245 said:

That's odd that it worked before, but not when adding  ",,Min".

Briefly looking at the reWASD site, it looks like you can associate a game (or in your case an emulator?) to a specific configuration.  Then with reWASD running in the background (sitting 'idle'), when you load a game (emulator) it then loads the corresponding configuration.  I would assume with it setup like that, that when you close the game (emulator), it unloads the configuration and goes back idle.  Or goes back to a "default" configuration if setup that way (which is what you don't want).

Ahhhh... there it is. Or pretty close.  Item #4 in their FAQ's.  https://forum.rewasd.com/forum/rewasd/technical-questions-aa/30703-need-some-help-start-from-this-faq

Thanks! I tried that approach, and it works with standard games and 2/3 of emus, but reWASD is a little different than other similar apps as it watches for exe files and activates only when they are in focus, not just running. I ran into issues with TeknoParrot and other more recent arcade games that sometimes have an XML or other file type as the actual game launching file is what must be in focus (literally- it goes in and out with TeknoParrotUI being on top). I came up with an alternate approach yesterday that is working nicely. I set reWASD to unmap all native controls and leaving it always on. I then set up two sets per controller (for now). Note, the initial unmap is the key here to ensure input is always recognized as the type intended. 

The first mapping in the set is a virtual XB 360, same as I just unmapped at the native level. The reason for this is to entirely eliminate lag and triggering the wrong input type (I have experienced this a little with XPadder, but not too bad). 

The second mapping is a full 360 controller mapped to keyboard strokes to match my iPac. 

I switch between these two with the home button and it is seamless. We put this through the paces with two controllers for about 6 hours last night and not a single misfired keystroke. Worst case scenario was click the home button once and they worked. Non tech-inclined GF even had no issues. This is easier than using AHK or the like and I never have to think about it again. I also believe I can force my joysticks to act like Xinput when in keyboard mode with full trackball functionality (not sure if that us an iPac thing or a Rec Room Masters Xtension thing- I think iPac?). Will add a shift key a la home on the iPac too now that I have my head wrapped around this thing.

Have used XPadder and Joy2Key on and off for years, and I am loving reWASD in comparison. All a matter of taste!

  • Game On 1
Link to comment
Share on other sites

Thanks I've searched the forum in the link in the past, but never asked the question.  I am hoping to get some help

I bought Contra Anniversary Collection on Steam. It contains 7 Contra games in it. When you open the game, it brings you to a page where you can select one of the 7 games (Contra, Super C, Contra Hard Corps, etc). So it's essentially a frontend within the game, I guess.

I would like each of these games to show separate on launchbox. I dont want to just have Contra Anniversary Collection to show up in Launchbox/Big Box, I want each game to be there. So I manually added Contra, Super C, Hard Corps, etc into launchbox with the launch path for each being the shortcut to Contra Anniversary Collection (since that is the game where each individual games are).

I would like to see if there is a way to go into Bigbox,  select to play the individual game and then have AHK select the individual game for me. So it automatically launches the specific title within the Collection for me.

Right now, if I select Super C on Bigbox...it takes me to the frontend of the Contra Anniversary Collection game and then I manually select Super C myself...I would like to see if I can get AHK to launch Super C automatically

Link to comment
Share on other sites

8 minutes ago, hyunchris said:

Thanks I've searched the forum in the link in the past, but never asked the question.  I am hoping to get some help

I bought Contra Anniversary Collection on Steam. It contains 7 Contra games in it. When you open the game, it brings you to a page where you can select one of the 7 games (Contra, Super C, Contra Hard Corps, etc). So it's essentially a frontend within the game, I guess.

I would like each of these games to show separate on launchbox. I dont want to just have Contra Anniversary Collection to show up in Launchbox/Big Box, I want each game to be there. So I manually added Contra, Super C, Hard Corps, etc into launchbox with the launch path for each being the shortcut to Contra Anniversary Collection (since that is the game where each individual games are).

I would like to see if there is a way to go into Bigbox,  select to play the individual game and then have AHK select the individual game for me. So it automatically launches the specific title within the Collection for me.

Right now, if I select Super C on Bigbox...it takes me to the frontend of the Contra Anniversary Collection game and then I manually select Super C myself...I would like to see if I can get AHK to launch Super C automatically

This does seem quite redundant, the games in the contra collection are the same roms you likely already have, for the systems they were originally on. So why not just use those?

Link to comment
Share on other sites

27 minutes ago, neil9000 said:

This does seem quite redundant, the games in the contra collection are the same roms you likely already have, for the systems they were originally on. So why not just use those?

I dont actually use ROMs. All the games on my PC were bought. 

Link to comment
Share on other sites

8 minutes ago, hyunchris said:

I dont actually use ROMs. All the games on my PC were bought. 

I dont have the contra collection on PC, only on Nintendo switch, but i have seen other collections, like the megadrive/genesis one just has the roms in a folder, have you checked if this is the case with this collection?

Link to comment
Share on other sites

Hi all, I am looking for a (hopefully simple) solution to perplexing (to me) problem.

Ok, so I have a script that is always running in my system tray with multiple different hotkeys set to launch various apps, exit apps and additional (sister) scripts. Well, I recently picked up a nice media center keyboard by Microsoft that gives me the ability to set macros, launch programs, files and/or scripts.... I was trying to setup one of the programmable keys to use a macro as one of my hotkeys. This did not work regardless of what I've tried. Well, there is always more than one way to skin a cat and so I returned to my old (but never figured out) idea of creating a hotkey "launcher" of sorts. Basically what I am trying to achieve is when I launch this ahk script, I want it to send "ctrl+alt+v" and then close the script, it will then launch what I have set to launch in my always-on script. None of what I've tried has worked. I don't get any errors but it also doesn't launch my program. Here is what I have currently in my test script:

 

#SingleInstance Force
send ~$^!Y
return

I have tried it with/out the "tilde" (~) and "$" to no avail. What am I missing? 

I suppose I can create a script containing the "chunk of 'code'" in my always on script, but this is something I have attempted in the past and failed at, so I would like to try to resolve this. 

Thanks in advance. 

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