Jump to content
LaunchBox Community Forums

Auto Hotkey Scripts


Lordmonkus

Recommended Posts

You're welcome.

FileMove in AHK lingo is synonymous with "file rename'.  Basically you're 'moving' the file from folder "A" to folder "B" .  In this case, we're "moving" it to the same folder (from "A" to "A") but with a different name.  AKA, renaming it.

And then in the next step, using FileCopy we're making a copy of the games config file (thus keeping the original in tact [just in case]), and copying it to the default config folder, while at the same time renaming it to "qt-config.ini".

(BTW, RockStar - Silver Ice.  The only way to go. :))

Link to comment
Share on other sites

21 minutes ago, JoeViking245 said:

You're welcome.

FileMove in AHK lingo is synonymous with "file rename'.  Basically you're 'moving' the file from folder "A" to folder "B" .  In this case, we're "moving" it to the same folder (from "A" to "A") but with a different name.  AKA, renaming it.

And then in the next step, using FileCopy we're making a copy of the games config file (thus keeping the original in tact [just in case]), and copying it to the default config folder, while at the same time renaming it to "qt-config.ini".

(BTW, RockStar - Silver Ice.  The only way to go. :))

? what the?....how on earth did you ever learn that? I seriously couldn't find an answer for file renaming with AHK. 

Link to comment
Share on other sites

I could use some help I already made a thread here about it. If you read through it you'll know I already tried everything when it comes to using additional apps in Launchbox. Nomousy works to make the mouse cursor disappear in games but when I add nomousy.exe (which is the script without any additional parameters to make the cursor reappear) it does it immediately during the game instead of after the game even if i set it for wait for exit or run it after the application. So basically using additional apps is out I need a script that would say run nomousy.exe /hide when the game launches and to run nomousy.exe when the game exits. 

 

 

Link to comment
Share on other sites

Basically I need to know how to make a script that tells one .exe to work after another .exe closes. I've tried several things  like this

run nomousy.bat (the script that makes the mouse cursor invisiable)

WinwaitClose ("ahk_exe demul.exe"")

run nomousy.exe (the .exe that makes the mouse cursor reappear) 

 

but the mouse just goes invisible for a second then reappears immediately. 

Link to comment
Share on other sites

For inside of a batch (.bat) file

REM your start mousy command here
start /w "" demule.exe
REM your quit mousy command here

For inside of an AHK script

; your start mousy command here
RunWait, demule.exe
; your quit mousy command here

Both of these will run demule.exe, and then ONLY after it closes/exits, run the "your quit mousy command here".

  • Like 1
Link to comment
Share on other sites

38 minutes ago, JoeViking245 said:

For inside of a batch (.bat) file


REM your start mousy command here
start /w "" demule.exe
REM your quit mousy command here

For inside of an AHK script


; your start mousy command here
RunWait, demule.exe
; your quit mousy command here

Both of these will run demule.exe, and then ONLY after it closes/exits, run the "your quit mousy command here".

 

What i get confused on is if it's in Launchbox does the script still need to give the path to both demul and/or nomousy or not? If not how will it know where they are? 

It couldn't find demul without the path, then I added the path and added it to launchbox like you said, but it runs demul twice and nomousy doesn't work. 

I'm also confused on if this script is going to take over running the emulator, how would I add that launchbox and be able to run my game too? Would I change the emulator to this ahk? 

 

Edited by Jayinem
Link to comment
Share on other sites

Oh I'm getting closer to make it more confusing these are primarly lightgun games because I have a lightgun, and for the lightgun to work it requires a script called Demulshooter. So what I did was move nomousy.bat and nomousy.exe to the same folder and demul.exe and ran the script from there

run, DemulShooter.exe -target=demul07a -rom=xtrmhnt2
run, demul.exe -run=awave -rom="xtrmhnt2"
run nomousy.bat
RunWait, demul.exe
run, nomousy.exe

 

this is all one ahk, the game launched fullscreen but wouldn't exit (I think because I need to add an exit script too) and maybe because I'm not exiting properly, the last line isn't working because the cursor does not reappear after closing. 

Edit: everything is not working together thanks to JoeViking. This is my final script. Now I can just compile it to an .exe and throw it on Launchbox, done. Thank you. 

run, DemulShooter.exe -target=demul07a -rom=xtrmhnt2
run nomousy.bat
RunWait, demul.exe -run=awave -rom="xtrmhnt2"
run, nomousy.exe

; This section closes Demul when pressing Escape
$Esc::
{
    Send !{F4}
}
 

 

 

Edited by Jayinem
Link to comment
Share on other sites

One more question if you don't mind, I'm trying to figure out #SingleInstance. Because Demulshooter (app that supports lightgun games)  if you launch one game then another that uses it you always get a pop up "An older instance of this script is already running, Do you want to replace it with this script?" and it seems to effect Demulshooter from allowing the lightguns to work. So how do I use #Singleinstance, or whatever other script to avoid this interruption? thanks again. 

Link to comment
Share on other sites

I don't think that pop up has got anything to do with Demulshooter, but is to do with the ahk/exe you made--but that depends on which pop up you are getting, from the wording you have used I assume (always a dangerous thing to do) that it is image 2.

You can get this popup from Demulshooter

image.png.9bbb80f4d6da94864a60fb3af28019a6.pngBut this pop up only occurs when the scenario above has happened, which is normally caused by user error.

If you mean a pop up like this (Disclaimer-I don't normally get this pop up I had to change my ahk to make it happen)

image.png.8f59e06ac91926a17598bf4cb06a80f2.png

Then that is caused be the ahk/exe.

As it states use #SingleInstance-link to how to use it is below (good old Google)

https://www.autohotkey.com/docs/commands/_SingleInstance.htm

Basically-pick which option you want and stick it in the autoexec part of the ahk (the top) - see below for more info (again good old Google)

https://www.autohotkey.com/docs/Scripts.htm#auto

Having just tested your ahk/exe from above (without #SingleInstance added) the reason you get that pop up if you run the same ahk/exe again is because it contains a hotkey and you don't close it at any point. The two links below will help with that (again good old Google)

https://www.autohotkey.com/docs/commands/Exit.htm

https://www.autohotkey.com/docs/commands/ExitApp.htm

In theory doing SingleInstance or closing the ahk/exe wlll work for you, I have no idea if there is a "best practice" in ahk, but i imagine you would normally want to close ahk/exe when finished with them rather than leaving open. However there might be times you want it to stay open but I think that is when #Persistent is used-see link

https://www.autohotkey.com/docs/commands/_Persistent.htm

I hasten to add I only started using all this recently and therefore this is all learned from lots and lots and lots of Google searches, and even more trial and error-so it might be one of the ahk grown ups (Viking246 or JayJay) will be able to explain it better.

  • Like 1
Link to comment
Share on other sites

Thanks, I just got confused on #SingleInstance because on the ahk site it shows #SingleInstance [ForceIgnorePromptOff] So I thought I was supposed to use those [ ] brackets, but I am not. 

I still am having problems with nomousy unfortunately. The worst part is it works sometimes but othertimes the mouse cursor remains. I think AHK is getting confused with Runwait, because it seems sometimes it does wait until the app closes to run nomousy.exe, othertimes it goes ahead and runs it right away so the mouse cursor reappears in the game before it closes.  I have no idea how to make it work consistantly.  I know this is the case because if I remove the runwait nomousy.exe the mouse cursor will indeed disappear, but of course it will remain after game closes.  I'm not sure why this is so difficult to run a very basic executable. 

This is my script

#SingleInstance Force
run, DemulShooter.exe -target=demul07a -rom=sprtshot
Run, demul.exe -run=awave -rom="sprtshot"
run, nomousy.bat

; This section closes Demul when pressing Escape
$Esc::
{
    Send !{F4}
}

Runwait, nomousy.exe

 

Ocassionally the mouse will disappear and reappear on close like I want, but over half the time it will just remain.  Maybe the script is running too many things idk. 

 

Edit: I think it's finally working properly. All I did was remove the commas after run and for some reason that fixed it. I didn't think it mattered.  Thanks to klinkyfoxx and JoeViking for the help. 

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

Is there any autohotkey scripts can can change the controller # that Windows sees? The reason is I have a steering wheel that takes over player 1 always, and that usually works fine I can usually still assign my controllers to emulators even if they aren't player 1. But when I try to play some PC games, they will only read player 1 or you can't use a controller. So I'm just seeing other than disconnecting the wheel is there a way to change the controller #? 

Edited by Jayinem
Link to comment
Share on other sites

 

On 6/30/2017 at 9:33 PM, Retro808 said:

AHK script for Xarcade tankstick users to exit emulators that do not have internal binding options since Xarcade simulates key strokes. It is modified from the script in this post

Script is set to use Player 4 start button and Player 2 start button as exit. Hold P4 and P2 for more than 2 seconds. Simply change "4" and/or "2" to the key of choice if you desire to use an alternate button key. This is using default Xarcade layout. 

Also you can lengthen or shorten the duration you have to hold the combo by changing "Duration > 2" (this is seconds)

 



~4 & 2::

Duration=0

Loop

{	Duration ++

	If !GetKeyState("4","P") || !GetKeyState("2","P")

		Break

	If Duration > 2

	{	

        Process, Close, {{{StartupEXE}}}

		break

	}

	Sleep, 1000

}

return

 

Can you modify this to work with the latest tankstick? It uses mouse button 3 as the exit button.

Also how do you exit out of retroarch?

thanks

Edited by Krakatoa
Link to comment
Share on other sites

  • 2 weeks later...
41 minutes ago, Krakatoa said:

Does anyone have a script to exit technoparrot?

There is one in this thread. Not sure where (but I would say nearer the end than the start so work backwards) but pretty sure I adapted someone's attempt/answered this question by someone else before. 

Unless you have already tried that one and it didn't work in which case apologies

Edited by Kiinkyfoxx
Link to comment
Share on other sites

On 4/11/2020 at 2:28 PM, Kiinkyfoxx said:

Hi,

I only use TP for a handful of games but I think Escape is a generic exit key

So change Process, Close, {{{TeknoparrotUi.exe}}}

to

Send, {Esc}

I adapted your AHK with the above line and it worked on the 3 games I checked - (the only one I have an issue with on my system is Mario Kart, because that leaves an extra command window, but this can be closed by adding WinClose, "Name of Window on your system" if you have same issue)

Hope this works for you.

Regards

Can you post your script please? I can't get it to work.

Link to comment
Share on other sites

7 hours ago, Krakatoa said:

Can you post your script please? I can't get it to work.

I don't have one generic exit ahk for Tecknoparrot.

I use different ones for different systems as they do different things. 

Some games are light gun based and some are joystick based and they use different closing routines and close other programmes as well so my script won't help you much. 

However I am happy to help you with a script for you. 

You say that previous one didn't work which is strange as worked when tested here. 

What key or keys are you wanting to use to close Tecknoparrot? 

Link to comment
Share on other sites

4 hours ago, Kiinkyfoxx said:

I don't have one generic exit ahk for Tecknoparrot.

I use different ones for different systems as they do different things. 

Some games are light gun based and some are joystick based and they use different closing routines and close other programmes as well so my script won't help you much. 

However I am happy to help you with a script for you. 

You say that previous one didn't work which is strange as worked when tested here. 

What key or keys are you wanting to use to close Tecknoparrot? 

Thanks for agreeing to help. This is the script I am using.

~MButton::

Duration=0

Loop

{	Duration ++

	If !GetKeyState("MButton","P")
		Break

	If Duration > 1

	{	

        Send, {Esc}

		break

	}

	Sleep, 1000

}

return

I use a tank stick so Mouse button 3 is my exit. The script works on all the other emulators, the only change made for teknoparrot was to change "Process, Close, {{{StartupEXE}}}" to "Send, {Esc}"

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