Jump to content
LaunchBox Community Forums

Auto Hotkey Scripts


Lordmonkus

Recommended Posts

Back again with a new problem, I was able to use the Exit AHK to exit Supermodel but I tried using the exact same AHK to exit TeknoParrot but it does not work, Does anyone have a Exit AHK script that works for TeknoParrot in Bigbox?

 

~1 & 2::

Duration=0

Loop

{	Duration ++

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

		Break

	If Duration > 2

	{	

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

		break

	}

	Sleep, 1000

}

return

 

Thanks again

Edited by Visivopro
Link to comment
Share on other sites

On 4/10/2020 at 1:13 AM, Visivopro said:

Back again with a new problem, I was able to use the Exit AHK to exit Supermodel but I tried using the exact same AHK to exit TeknoParrot but it does not work, Does anyone have a Exit AHK script that works for TeknoParrot in Bigbox?

 


~1 & 2::

Duration=0

Loop

{	Duration ++

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

		Break

	If Duration > 2

	{	

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

		break

	}

	Sleep, 1000

}

return

 

Thanks again

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

Link to comment
Share on other sites

  • 2 weeks later...
6 minutes ago, Mordr3d said:

Hello everyone.
Sorry for my English, I am using the Google translator.
Please, does anyone know the script to be able to put Demul in full screen in Launchbox ??
I've tried some but they don't work for me.
Thanks in advance.

Demul should not need it. There is a fullscreen check box in the settings under >Config>Video

Link to comment
Share on other sites

1 minute ago, Retro808 said:

Demul no debería necesitarlo. Hay una casilla de verificación de pantalla completa en la configuración en> Configuración> Video

Yes I know. But with that box active I don't get full screen.
Nor when I test the rom, directly from the emulator.
Thanks for answering.

Link to comment
Share on other sites

Hello all! I hope life is treating you guys well. I hope the stay at home order isn't wearing on your sanity. 

I'm getting here with an ahk/gamepad question. However it's not a game related question. Hopefully when YOU are reading this, you see the value in this and a lesson for me and someone else to learn from. Without further ado, here's my novel question. 

I'm hoping YOU may have the answer or at least the insight to point me in the right direction. I'm looking to have my HTPC remote send movement from the right joystick with presses of the UP, DOWN, LEFT & RIGHT buttons of my remote. The buttons just send the keyboard arrow keys, so that it's native keyboard input. My idea is using vJOY. I only want it to send the right joystick (U,D,L,R) movement when I am using the Netflix app from the Microsoft Store. I no issue with launching and exiting apps using AHK. What I'm wondering is, is it possible to "load" a vJOY profile through ahk then unload it with my exit hotkey? It seems plausible and easy enough.... For someone with experience and knowledge of the program. I've never used vJOY, 'cause TBQH, it went right over my head when I was trying to understand what I could do with vJOY and never bothered trying again, thinking I'd never need to use a virtual joystick... Until now. On a final note, I have also started attempting to educate myself with the AHK Xinput wrapper. Sadly, from my understanding, AHK cannot emulate/send joypad input with standard key presses. Correct me if I'm wrong and help she's some light on this for me. Take care and I look forward to some input. Ok...I could help myself with that one. I love a good pun. They're the best dad jokes.

Link to comment
Share on other sites

29 minutes ago, CtinD said:

Hello all! I hope life is treating you guys well. I hope the stay at home order isn't wearing on your sanity. 

I'm getting here with an ahk/gamepad question. However it's not a game related question. Hopefully when YOU are reading this, you see the value in this and a lesson for me and someone else to learn from. Without further ado, here's my novel question. 

I'm hoping YOU may have the answer or at least the insight to point me in the right direction. I'm looking to have my HTPC remote send movement from the right joystick with presses of the UP, DOWN, LEFT & RIGHT buttons of my remote. The buttons just send the keyboard arrow keys, so that it's native keyboard input. My idea is using vJOY. I only want it to send the right joystick (U,D,L,R) movement when I am using the Netflix app from the Microsoft Store. I no issue with launching and exiting apps using AHK. What I'm wondering is, is it possible to "load" a vJOY profile through ahk then unload it with my exit hotkey? It seems plausible and easy enough.... For someone with experience and knowledge of the program. I've never used vJOY, 'cause TBQH, it went right over my head when I was trying to understand what I could do with vJOY and never bothered trying again, thinking I'd never need to use a virtual joystick... Until now. On a final note, I have also started attempting to educate myself with the AHK Xinput wrapper. Sadly, from my understanding, AHK cannot emulate/send joypad input with standard key presses. Correct me if I'm wrong and help she's some light on this for me. Take care and I look forward to some input. Ok...I could help myself with that one. I love a good pun. They're the best dad jokes.

I have not used vJOY, but I am an avid user of JoyToKey, which probably does mostly the same?
Anyway, in it you can associate applications with profiles:
Screenshot_10.thumb.png.bf2e8f7323e818db922b493afef1928b.pngOnce set up, it will automatically switch to the correct profile, when an application is active.

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

1 hour ago, proghodet said:

I have not used vJOY, but I am an avid user of JoyToKey, which probably does mostly the same?
Anyway, in it you can associate applications with profiles:
Screenshot_10.thumb.png.bf2e8f7323e818db922b493afef1928b.pngOnce set up, it will automatically switch to the correct profile, when an application is active.

Thank you for the quick reply. I have used joy2key numerous times in the past. However that doesn't fit the bill. I need keypresses to emulate joystick input

Link to comment
Share on other sites

A certain game I have requires an additional app for me to make it fullscreen. For the additional app to work I have to hit F3 each time I launch the game. How do I make a script that hits F3 for me each time I run the game? 

Link to comment
Share on other sites

3 hours ago, Jayinem said:

A certain game I have requires an additional app for me to make it fullscreen. For the additional app to work I have to hit F3 each time I launch the game. How do I make a script that hits F3 for me each time I run the game? 

this is quite simple. 

 

Run, "path to your game executable'
run, "path to fullscreen excutable"
Sleep, 1000  ; 1 second delay for pressing  f3, adjust as needed
send{F3}
return
esc::exitapp ;escape exits the script. Alternatively, you can just take the "esc::" off and it will automatically close. I added the esc key to end it so you can see if its working and edit it on the fly. Once it is to your liking, you can remove the esc key.

you can also do a winwait if you know how to get the window name using windowspy

 

Edited by CtinD
added a exit line to the launcher
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

So ive recently ran into some trouble using the generic shutdown ahk

Process, Close, {{{StartupEXE}}}

Its left me with cases of saves not being written.  It led me to change to using

WinClose, ahk_exe

which has solved the issue.  The problem im now running up against is using it with dolphin.  Upon exiting with the aforementioned, I get a small square in the center of my screen as the Dolphin window shrinks down with the "shutting down" overlay on it.   Normal dolphin behavior, and exactly what you'd want to see to know it is in fact shutting down properly.

Of course this is also absolutely ghastly to a clean polished shutdown experience.

How can i add to the running ahk script and exit script to continue to use WinClose, but also hide that window?   Best i can tell it uses the same title, class, exe.  I gather theres a way to do it by dimensions but either way its a bit above my simple paygrade :P

Link to comment
Share on other sites

3 hours ago, klepp0906 said:

So ive recently ran into some trouble using the generic shutdown ahk


Process, Close, {{{StartupEXE}}}

Its left me with cases of saves not being written.  It led me to change to using


WinClose, ahk_exe

which has solved the issue.  The problem im now running up against is using it with dolphin.  Upon exiting with the aforementioned, I get a small square in the center of my screen as the Dolphin window shrinks down with the "shutting down" overlay on it.   Normal dolphin behavior, and exactly what you'd want to see to know it is in fact shutting down properly.

Of course this is also absolutely ghastly to a clean polished shutdown experience.

How can i add to the running ahk script and exit script to continue to use WinClose, but also hide that window?   Best i can tell it uses the same title, class, exe.  I gather theres a way to do it by dimensions but either way its a bit above my simple paygrade :P

I have been having a similar issue with the Steam closing down pop up on Windows games. 

I use 

Winset, AlwaysOnTop, On, LaunchBox

But this is in a separate AHK that runs rather than through the Emulator tab one, however it might be worth a try.

(Also make sure to put SetTitleMatchMode, 2 at the very top of the AHK tab

This works to keep the LaunchBox game shutdown screen on top of the pop up, it might be worth using "LaunchBox Game Startup" instead of "LaunchBox" if you end up back at the game selection screen rather then the shutdown screen.

So would look like this (assuming Esc is exit key) ???????? being the name of the process to close

SetTitleMatchMode, 2

$Esc::

WinClose, ahk_exe ?????????

Winset, AlwaysOnTop, On, LaunchBox

Hopefully that works

Link to comment
Share on other sites

the above sort of works.  it still appears but it disappears a bit quicker.  Seems like this may be a situation solved by either the dolphin dev hiding that atrocious window, or having to close the process (which to be fair is done by default with LB to address the same issue with pcsx2 without any report of it causing problems) so it very well may not present one with dolphin (as far as sram saves go).

Dont know as i havent tested yet.   But if it flushes immediately then its irrelevant.  Thats the ideal, but some platforms write to sram for scratch and thus flushing immediately would be constantly writing.  Not ideal especially for folks running off ssds and the like.   Seems its up to the platform and as such emulators implementation as to how its handled.

Me, im just trying to be proactive so I dont inadvertently lose a save in the future then go awww i should have used winclose instead of closing the process.

Thank you for sharing that ^

Edited by klepp0906
Link to comment
Share on other sites

I have changed the above to work with CXBX-reloaded which on shut-down flashed the emulator before the Game Over screen flashed up-so in theory similar issue to yours

Might be worth trying as below, as it actually makes more sense in this order

$Esc::

Winset, AlwaysOnTop, On, LaunchBox Game Startup

WinClose, ???????

 

This was using SetTitleMatchMode, 3 but that was due to an issue with my system, it may work as 2 for you, I don't use Dolphin so I am afraid I cannot test it to check it works before posting.

Cheers

Link to comment
Share on other sites

  • 3 weeks later...

I am struggling. Here is a link to my post at the AHK forums....so I am not being redundant.

I am confused with the order of operations. If I could have 2 basic scripts to start off with, one that when launched, checks for a single file, if its present, it moves the file to an external directory then proceeds to launch gta v. The other, checks for the same file and if it's absent, copies it to the GTA V directory then launches GTA V. I could add all the other files/folders if I just had something for starters.

Link to comment
Share on other sites

@CtinD You should prob make a backup of the clean and modded files, just in case. My ahk is a bit rusty but this is a bit easier to read than your reply at ahk forums.

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

modFile := A_ScriptDir "\gtaFile.txt" ;the file you want to check exists
modDir := A_ScriptDir "\mods" ;the directory to move the files too	

if FileExist(modFile)
{
	FileMove, %modFile%, %modDir%\gtaFile.txt, false
	FileMove, %A_ScriptDir%\mod file 1.txt, %modDir%\mod file 1.txt, false
}

sleep 1000 ;might be worth waiting
run gta5.exe

To test this script create a new folder, inside this folder create the following files:

^this script.

A txt file named "gtaFile.txt".

A txt file name "mod file 1.txt"

A folder named "mods"

Click on the script and txt files should move into the mod folder.

Just a warning, The word "false" at the end of each filemove command means "overwrite". Set to true if you want to overwrite the files or false if not.

Edit: the "run gta5.exe" will error so remove it to test the script.

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

5 minutes ago, jayjay said:

@CtinD You should prob make a backup of the clean and modded files, just in case. My ahk is a bit rusty but this is a bit easier to read than your reply at ahk forums.


#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

modFile := A_ScriptDir "\gtaFile.txt" ;the file you want to check exists
modDir := A_ScriptDir "\mods" ;the directory to move the files too	

if FileExist(modFile)
{
	FileMove, %modFile%, %modDir%\gtaFile.txt, false
	FileMove, %A_ScriptDir%\mod file 1.txt, %modDir%\mod file 1.txt, false
}

sleep 1000 ;might be worth waiting
run gta5.exe

To test this script create a new folder, inside this folder create the following files:

^this script.

A txt file named "gtaFile.txt".

A txt file name "mod file 1.txt"

A folder named "mods"

Click on the script and txt files should move into the mod folder.

Just a warning, The word "false" at the end of each filemove command means "overwrite". Set to true if you want to overwrite the files or false if not.

Edit: the "run gta5.exe" will error so remove it to test the script.

This is excellent! So, I have been helped by 3 people so far and with what I have been given, I can imagine how it will be accomplished. Then I got the idea of making it scan the "mod" folder and output an ini or txt file with folders and files being preserved like: 

folder\folder1\mod.dll

folder\folder2\mod32.dll

folder\mod1.dll

the first folder being the root of the directory. Then the script would use that as a checklist. Isn't that an "iniread" or something like that?

So I am not the most skilled scripter. However when toying around with other's scripts and seeing the patterns, I am capable of making things work. I want to release this to the world, there are too many convoluted methods and not enough hdd space. It would be so simple to create additional mod folders, while keeping them all centralized and tidy. So, any time a user wants to add a new/different set of mods, they would just copy the script, create a new folder like "GTAV DOJ" edit the launcher and it would do the rest. Would it be better to copy or move though? Copying to the GTA V folder ensures nothing gets lost. Moving is faster and ensures settings would be retained. 

One last note and it may be a lot, but I was thinking if I am wanting to (eventually) add support for multiple mods, wouldn't it be good to have it scan the gta v folder (clean install)? Let that be the "clean" launcher, then the other launchers would use the same .ini or .txt to know what belongs and doesn't? IDK, tons of ideas without enough knowledge or experience.

Link to comment
Share on other sites

I would use copy and always have a backup of the original files in case mistakes are made. Being sure you can always recover from an error is more important than hdd space.

Im just a hobbyist coder as well, if I can help it I try not to mess with other peoples files as much as possible. But iv learnt not to try and be clever with it, keeping it simple is best.

If i was making this for myself I would keep the files in their own directories:

Root/Mods/Mod 1/files

Root/Mods/Mod 2/files

Original Backup/files

an so on.

Every time I launched a mod I would have something like this:

if (modFile overwrites originalFile)
{
	if (BackUp directory does not contain originalFile)
	{
		Backup originalFile
	}	
}

FileCopy, blah, blah, true

This way you should always have a backup of the original files no matter what mod has been launched.

 

 

 

  • Like 1
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...