Jump to content
LaunchBox Community Forums
Lordmonkus

Auto Hotkey Scripts

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

Share this post


Link to post
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. 

Share this post


Link to post
Share on other sites
39 minutes ago, CtinD said:

find an answer for file renaming with AHK. 

Can't go giving away all my secrets, but I will share that one...  image.thumb.png.34110c15445f7c62c8538fcea551e488.pngRemember, when trying to figure something out, always start your searches using the "KISS Principle". :D 

Share this post


Link to post
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. 

 

 

Share this post


Link to post
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. 

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
8 minutes ago, Jayinem said:

everything is not working together thanks to JoeViking.

Sorry man.  Just trying to help.

But if "not" was supposed to "now"... glad it's working. ;) 

  • Like 1

Share this post


Link to post
Share on other sites

Lol yeah it was supposed to be now, sorry. Although, now that i turned on my lightgun the mouse is back. But I think I can figure it out. TYVM 

 

 

  • Like 1

Share this post


Link to post
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. 

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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
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...