Jump to content
LaunchBox Community Forums

Auto Hotkey Scripts


Lordmonkus

Recommended Posts

Just tried your version here (but with Left button and not middle) and it exiting TP game.

A single click on left mouse didn't exit, but pressing and holding did. Doesn't close the UI but does close the game. If you direct load into the game it closes the game and no UI left over as never opened.

Not sure why not working for you. Just checked that Escape on its own actually exits your TP games i am pretty sure it is a generic exit key.

I did all my testing outside of LB as I didn't want to mess around with my set up so might be worth checking it outside LB first and seeing if it works there.

Edited by Kiinkyfoxx
Link to comment
Share on other sites

I want to start keyboard2xinput with Windows Games /Steam. Steam games are in the Windows plattform in Launchbox.

The programm comes with a sample. I put it in Launchbox in the Windows Games AHK but k2x don´t start with a Steam game. I only changed the folders in the sample.

 

 

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

Run, "D:\keyboard2Xinput\keyboard2XinputGui.exe"
Run, "D:\Steam\Steam.exe" -applaunch %1%

isRunning := "0"
While (isRunning = "0") ; Wait until the game is launched
    RegRead, isRunning, HKCU\Software\Valve\Steam\Apps\%1%, Running
	Sleep, 500

Sleep, 5000
MouseMove, 1920, 1200
WinGetTitle, Title

While (isRunning = "1") ; Wait until the game is closed
    RegRead, isRunning, HKCU\Software\Valve\Steam\Apps\%1%, Running
	Sleep, 500

; Game stopped, stop keyboard2Xinput by sending numpad multiply key (see k2x mapping.ini)
SendInput {NumpadMult}

; change focus back to Attract-Mode
WinActivate Attract-Mode
Link to comment
Share on other sites

@Andreas84 

I could be wrong here but from memory somebody else was asking about this in this exact thread and came up with a way of it working and posted info-so might be worth a read of this thread for that.

I would start from this page and work backwards as pretty sure it wasn't "recently"

Edited by Kiinkyfoxx
Link to comment
Share on other sites

  • 2 weeks later...

Hey,

I'm trying to create a script in Autohotkey that will map the Xbox 360 controller guide button to close any emulator and launch BigBox if it not running. If the BigBox window is running then the script should select BigBox.

I can't detect the  BigBox window using WinExist.

Does anyone know where I am going wrong?
 

vk07::
  WinClose A ;
  Run %A_ScriptDir%\nircmd.exe setdefaultsounddevice "32W_LCD_TV" ;
  sleep, 2000 ;(wait 2 seconds)  


If !WinExist("Launchbox Big Box")
    Run C:\Users\Jack\LaunchBox\Core\BigBox.exe
else
    WinActivate, Launchbox Big Box
send {esc}

The script changes my audio device to the TV and should select the BigBox window if it is running and if it is not then it should launch BigBox. This should allow me to close the running game and return to BigBox or launch BigBox all through the Xbox 360 Controller guide button.

Would really appreciate any help!

Jack

Link to comment
Share on other sites

This is my finished script: it changes my sound card to TV, opens BigBox, switches to big box when in game and closes emulators using the Xbox 360 controller guide button.

It uses nircmd to switch the soundcard. It can be downloaded here, put it in the same folder as the autohotkey script:  https://www.nirsoft.net/utils/nircmd.html

Furthermore, place a shortcut to the autohotkey script in the windows startup folder so that it runs when the computer starts.

Not sure why it is appearing as very hard to read gray text.

vk07::
  Run %A_ScriptDir%\nircmd.exe setdefaultsounddevice "32W_LCD_TV" ;

if !WinExist("ahk_exe BigBox.exe") 
	Run C:\Users\Jack\LaunchBox\Core\BigBox.exe   
else 
	WinActivate, ahk_exe BigBox.exe
send {esc}

WinClose, ahk_exe retroarch.exe

WinClose, ahk_exe Dolphin.exe

WinClose, ahk_exe pcsx2.exe
Edited by jacks897
added xbox 360 guide button
Link to comment
Share on other sites

Hoping i can get someones expertise in creating a AHK Script for me please for Time Crisis 5 to use with a Aimtrak Gun. I don't know if the script can contain everything or if i need one to launch and one for inputs etc. Here's what i'm using atm

#SingleInstance, force

Run, DemulshooterX64.exe -target=es3 -rom=tc5
run, "C:\Users\ace_j\Desktop\TC5\Binaries\Win64\TimeCrisisGame-Win64-Shipping.exe" -NOINI -Language=JPN -playside=1


Escape::
    Process,Close,TimeCrisisGame-Win64-Shipping.exe
    Run,taskkill /im "TimeCrisisGame-Win64-Shipping.exe" /F
    ExitApp
return

And this is what id like to do so any help appreciated and want to learn please.

1. My PC resolution is 1920x1080 but scaled to 150% the game needs to launch at 100% and the PC to go back to 150% on exiting otherwise Demulshooter is out of sync need help to do this please

2. I've edited the games input file and my left and right buttons act as the peddles in game (set as mouse right and mouse middle) which is perfect.

I've also changed coin and crosshair to 1& 5. Off screen my left and right buttons are GP Button 1 and GP Button 5 i would like these to be able to input 1 and 5 (keyboard) please. So off screen they can enter coins and turn the cross hair on and off. I tried to edit this in the games input file to register but had no luck!!! Maybe i was typing it wrong etc. I also believe that GP Button 1 etc can be seen as Joy 1 Button 1 and Joy 1 button 5 so help very much needed please.

3. Lastly to cycle through weapons please This is set as o on the keyboard and was thinking of a combination of holding right button (which is mouse middle on screen) and pressing the trigger (which is mouse left) to act as o to cycle and then the same on the left side as well as you have left and right peddles so that would be left trigger (which is mouse right on screen) and trigger (mouse left)

This to me makes sense as your hiding by holding the left or right button and then you can cycle through weapons etc

Sorry for the long message and hoping someone doesn't mind helping me with a AHK script to get this all working and ill happily share the script and all info on editing the actual game input file

 

thanks a lot

 

Johno

IMG_0977.JPG

Link to comment
Share on other sites

6 hours ago, Johno1980 said:

Hoping i can get someones expertise in creating a AHK Script for me please for Time Crisis 5 to use with a Aimtrak Gun. I don't know if the script can contain everything or if i need one to launch and one for inputs etc. Here's what i'm using atm

#SingleInstance, force

Run, DemulshooterX64.exe -target=es3 -rom=tc5
run, "C:\Users\ace_j\Desktop\TC5\Binaries\Win64\TimeCrisisGame-Win64-Shipping.exe" -NOINI -Language=JPN -playside=1


Escape::
    Process,Close,TimeCrisisGame-Win64-Shipping.exe
    Run,taskkill /im "TimeCrisisGame-Win64-Shipping.exe" /F
    ExitApp
return

And this is what id like to do so any help appreciated and want to learn please.

1. My PC resolution is 1920x1080 but scaled to 150% the game needs to launch at 100% and the PC to go back to 150% on exiting otherwise Demulshooter is out of sync need help to do this please

2. I've edited the games input file and my left and right buttons act as the peddles in game (set as mouse right and mouse middle) which is perfect.

I've also changed coin and crosshair to 1& 5. Off screen my left and right buttons are GP Button 1 and GP Button 5 i would like these to be able to input 1 and 5 (keyboard) please. So off screen they can enter coins and turn the cross hair on and off. I tried to edit this in the games input file to register but had no luck!!! Maybe i was typing it wrong etc. I also believe that GP Button 1 etc can be seen as Joy 1 Button 1 and Joy 1 button 5 so help very much needed please.

3. Lastly to cycle through weapons please This is set as o on the keyboard and was thinking of a combination of holding right button (which is mouse middle on screen) and pressing the trigger (which is mouse left) to act as o to cycle and then the same on the left side as well as you have left and right peddles so that would be left trigger (which is mouse right on screen) and trigger (mouse left)

This to me makes sense as your hiding by holding the left or right button and then you can cycle through weapons etc

Sorry for the long message and hoping someone doesn't mind helping me with a AHK script to get this all working and ill happily share the script and all info on editing the actual game input file

 

thanks a lot

 

Johno

 

Ignore the resolution stuff as solved by checking the dpi in the Demulshooterexe  simple when you know how lol 

just need some help with my buttons please to finish my AHK script 

 

thank you 

Link to comment
Share on other sites

27 minutes ago, Wanderer189 said:

I no nothing about AHK, can someone tell me what I need to run a batch file? I am wanting to run a batch file using a AHK script within LB/BB before an emulator starts. 

Quote

Run, FileNameToRun

If the bat file is in the same directory as the AHK, just the filename name is enough. If the bat file is in a different directory, you need the full path + filename.

More Info

 

  • Thanks 1
Link to comment
Share on other sites

Could anyone help me with a script? I'm loading up Cxbx-R and all my roms are zipped, so LB/BB sees the name of the game like Futurama for example and extracts the image. The problem is that launchbox tries to parse the rom name but on all xbox discs the executable is called default.xbe and not futurama.xbe. So I was thinking I could use a script that either renames the default.xbe to the rom name or sends a command to the emulator telling it to just run default.xbe instead. Is this possible?

Something like:

if default.xbe exists then rename to romname and run

Edited by Monyet
Link to comment
Share on other sites

I was wondering if anyone could come up with a script (if even possible) to change the location of a game's drive it's on when launching then it's gone when the game closes? It might sound crazy but there was a game I played recently that did that it used the W: Drive. I didn't think anything of it at the time but now that I need it I can't find it. The reasoning for me wanting to do this is I only have 256 GB drive of SSD and 1 TB  regular HDD, and several TBs of regular external hard drives. This would allow me to hopefully mount any game on those other drives to the SSD which would improve performance. 

Edited by Jayinem
Link to comment
Share on other sites

@Jayinem Sounds like your game is on an external HDD and when you unplug the drive then plug it back in, it doesn't [always] connect using the same drive letter.  Sometimes it's W:\  and sometimes it U:\.   What you need to do is tell Windows that when external HDD (1) in plugged in, always assign it to drive W:\.   When external HDD (2) is plugged in, always assign it drive letter T:\.   and so on.   A search on one of those popular internet search engines should help.  "force external hhd letter"

Link to comment
Share on other sites

1 hour ago, JoeViking245 said:

@Jayinem Sounds like your game is on an external HDD and when you unplug the drive then plug it back in, it doesn't [always] connect using the same drive letter.  Sometimes it's W:\  and sometimes it U:\.   What you need to do is tell Windows that when external HDD (1) in plugged in, always assign it to drive W:\.   When external HDD (2) is plugged in, always assign it drive letter T:\.   and so on.   A search on one of those popular internet search engines should help.  "force external hhd letter"

Not exactly. I am trying to force games to C : Drive where my SSD is so they will have faster speeds, better loading times etc.... I was able to accomplish this and even figured out how to remove the files from the C : Drive upon hitting escape key.  So in essence I am "mounting" games on C : drive to get the benefits of the SSD while not having to keep them all on my SSD which I have limited space. 

 

 

#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.
#SingleInstance Force

FileCopyDir, E:\SUPERHOT MIND CONTROL DELETE, C:\GameLaunch\Game
run C:\GameLaunch\Game\SHMCD.exe
Return

$Escape::
    Process,Close,SHMCD.exe
    Run,taskkill /im "SHMCD.exe" /F
    FileRemoveDir, C:\GameLaunch\Game, 1
    sleep 100
    ExitApp
return

This is tested and works. Now I can "mount" any game I want on my other non-SSD Internal drive or even games from external to the SSD which is on C : I need to make a similar script to this for a lot of games and that will take awhile.  What I did here was create the directory on C : C:\GameLaunch\Game and I will use this for every game and wipe \Game where the files will be each time.  That way every time I launch another game the space is not adding up it's resetting it. 

 

Only bad thing is at least one game I'm trying Persona 4 Golden takes awhile to copy all the files over to C : before it will launch. I assume this will happen with other games as well. 

Edited by Jayinem
Link to comment
Share on other sites

Call this a "One and Done".

Compile this to an exe.

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

GameFullPath := %1%                ;E:\SUPERHOT MIND CONTROL DELETE\SHMCD.exe
SplitPath, GameFullPath,, dir      ;E:\SUPERHOT MIND CONTROL DELETE
SplitPath, GameFullPath,game       ;SHMCD.exe

FileCopyDir, %dir%, C:\GameLaunch\Game
run C:\GameLaunch\Game\%game%
Return

$Escape::
    Process,Close,SHMCD.exe
    Run,taskkill /im %game% /F
    FileRemoveDir, C:\GameLaunch\Game, 1
    sleep 100
    ExitApp
return

Create a new emulator in LB pointing to the above exe.

Uncheck these boxes.image.png.7f60fa760527c77244bc9002d7a24923.pngEdit the game(s) to use this emulator.

Not tested. But looks good on 'paper'. ;) 

Link to comment
Share on other sites

It has lots of problems. Sometimes it won't create the directory, sometimes it won't launch the game, sometimes it won't erase the directory. I can't find any rhyme or reason for any of it. 

For the game Samurai Shodown it took 5 minutes before it launched the game. So it's not exactly worth the time it saves on loading to wait 5 minutes. Tekken 7 I cannot get it to launch at all. 

Edited by Jayinem
Link to comment
Share on other sites

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

GameFullPath := %1%                ;E:\SUPERHOT MIND CONTROL DELETE\SHMCD.exe
SplitPath, GameFullPath,, dir      ;E:\SUPERHOT MIND CONTROL DELETE
SplitPath, GameFullPath,game       ;SHMCD.exe

FileCopyDir, "%dir%", C:\GameLaunch\Game  ;added quotes just in case
sleep 1000                                ;pause 1 second for whatever reason
run "C:\GameLaunch\Game\%game%"           ;added quotes for games that have spaces in them
Return

$Escape::
    WinClose, ahk_exe "%game%"         ;a better option
     ; Process,Close,"%game%"            ;fixed my oops and added quotes for games with spaces in the name
     ; Run,taskkill /im "%game%" /F      ;added quotes for games with spaces in the name
    sleep 1000                         ;give it a sec to close down
    FileRemoveDir, C:\GameLaunch\Game, 1
    sleep 100
    ExitApp
return

I assume all these games are executable's (vs needing their own external emulator).

I'm guessing the 'rhyme or reason'  is some paths and/or game_names had spaces in them.  Added quotes here and there.

Changed the game close process and added a pause before deleting.

But ya, if the game files/folders are large, it's almost self defeating.

Still not tested, but does look a little better. :D

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