Jump to content
LaunchBox Community Forums

Auto Hotkey Scripts


Lordmonkus

Recommended Posts

11 hours ago, nlen83 said:

Ok, @jayjay I did the edit you added later and it does exactly as it should. My issue now is, it seems as though in the quickness of rotation, the app, in this case, nullDC assumes the resolution is portrait still, thus causing it to not go in to a normal fullscreen, it assumes the max resolution in one direction is as it was just milliseconds before, if that makes sense. 

Any ideas for that?

Thanks a ton btw!!

If im understanding you properly its the first rotation that is the problem at the moment and maybe because the rotation happens to quickly. It might not be because it happens to quickly but hopefully it is.

#SingleInstance force
SetTitleMatchMode, 2

Loop
IfWinActive, nullDC
{
Send {ctrl down}{alt down}{up down}{ctrl up}{alt up}{up up}
Break
}
Return
 

$Esc::
{
Send {ctrl down}{alt down}{right down}{ctrl up}{alt up}{right up}

Process, Close, {{{StartupEXE}}}
}

The idea with this is:

We have a loop that will keep looping until it finds a window which contains the word nullDC (is case sensitive) anywhere in the title bar. When a window which contains nullDC becomes active it then sends the keystrokes. 

See how that goes.

 

Edit:

To check if its not a issue with the timing of the rotation, try the following if the above script doesn't work correctly.

#SingleInstance force
SetTitleMatchMode, 2

Loop
IfWinActive, nullDC
{

Sleep, 5000  ;wait 5 seconds before rotation
Send {ctrl down}{alt down}{up down}{ctrl up}{alt up}{up up}
Break
}
Return


$Esc::

{

Send {ctrl down}{alt down}{right down}{ctrl up}{alt up}{right up}

Process, Close, {{{StartupEXE}}}

}

 

Edited by jayjay
Link to comment
Share on other sites

18 hours ago, jayjay said:

 


#SingleInstance force
SetTitleMatchMode, 2

Loop
IfWinActive, nullDC
{

Sleep, 5000  ;wait 5 seconds before rotation
Send {ctrl down}{alt down}{up down}{ctrl up}{alt up}{up up}
Break
}
Return


$Esc::

{

Send {ctrl down}{alt down}{right down}{ctrl up}{alt up}{right up}

Process, Close, {{{StartupEXE}}}

}

 

This has done the trick!! I'm on the right path now! 

Now my issue is redream (The Dreamcast emulator) is amazing and i'd rather use that. This script you wrote works flawless for nullDC but not for redream. What I did is I setup redream in launchbox and its functioning fine, I just changed out the IfWinActive, nullDC to redream. I was able to catch the error that flashes and I thought I would share it with you.  

This has been an ONGOING project for an easy year now with spare time, I cannot tell you how much I appreciate your input. @jayjay

error.png

 

 

EDIT: SCRATCH THAT! It was my fault in the way I pasted something. It works flawless. So damn exciting! =D

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

Script that removes the windows top Frame, making older games run in borderless windowed.  The Hotkey is F12 to activate it once the game is running and the script is loaded.

ToggleFakeFullscreen()
{
CoordMode Screen, Window
static WINDOW_STYLE_UNDECORATED := -0xC40000
static savedInfo := Object() ;; Associative array!
WinGet, id, ID, A
if (savedInfo[id])
{
inf := savedInfo[id]
WinSet, Style, % inf["style"], ahk_id %id%
WinMove, ahk_id %id%,, % inf["x"], % inf["y"], % inf["width"], % inf["height"]
savedInfo[id] := ""
}
else
{
savedInfo[id] := inf := Object()
WinGet, ltmp, Style, A
inf["style"] := ltmp
WinGetPos, ltmpX, ltmpY, ltmpWidth, ltmpHeight, ahk_id %id%
inf["x"] := ltmpX
inf["y"] := ltmpY
inf["width"] := ltmpWidth
inf["height"] := ltmpHeight
WinSet, Style, %WINDOW_STYLE_UNDECORATED%, ahk_id %id%
mon := GetMonitorActiveWindow()
SysGet, mon, Monitor, %mon%
WinMove, A,, %monLeft%, %monTop%, % monRight-monLeft, % monBottom-monTop
}
}

GetMonitorAtPos(x,y)
{
;; Monitor number at position x,y or -1 if x,y outside monitors.
SysGet monitorCount, MonitorCount
i := 0
while(i < monitorCount)
{
SysGet area, Monitor, %i%
if ( areaLeft <= x && x <= areaRight && areaTop <= y && y <= areaBottom )
{
return i
}
i := i+1
}
return -1
}

GetMonitorActiveWindow(){
;; Get Monitor number at the center position of the Active window.
WinGetPos x,y,width,height, A
return GetMonitorAtPos(x+width/2, y+height/2)
}
F12::
ToggleFakeFullscreen()
Return

  • Like 1
Link to comment
Share on other sites

On 7/6/2018 at 6:10 PM, nlen83 said:

#SingleInstance force SetTitleMatchMode, 2  Loop IfWinActive, nullDC { Sleep, 5000 ;wait 5 seconds before rotation Send {ctrl down}{alt down}{up down}{ctrl up}{alt up}{up up} Break } Return $Esc:: { Send {ctrl down}{alt down}{right down}{ctrl up}{alt up}{right up} Process, Close, {{{StartupEXE}}}  }

@jayjay Is there anyway I can encorporate this to a windows game? Would I need to make an actual autohotkey file and specify it in the game properties under launch box? Any advice is appreciated as usual. The script you put together works perfectly with redream and pcsx2 btw.

Edited by nlen83
Link to comment
Share on other sites

On 7/10/2018 at 12:21 AM, dnm said:

Hi all; 

I need a  script "ALT"+"ENTER" for fullscreen of this X68000 emulator: xm6g.exe; I've no idea what to do ?

Can try this:

SetTitleMatchMode, 2

WinWaitActive, XM6
Sleep, 1000
Send {Alt down}{Enter down}{Alt up}{Enter up}

WinWaitActive means wait for a window to become active. The XM6 is the window title. Have a look at the window title  for  xm6g.exe, if it contains XM6 you should be good, if not replace XM6 with a word that is within the window title bar, it is case sensitive.

Sleep, 1000 means wait 1 second before sending the keystrokes. You may need to increase this depending how quick xm6g.exe window appears. 2000 is 2 seconds, 3000 is 3 seconds and so on.

 

On 7/10/2018 at 4:40 AM, nlen83 said:

@jayjay Is there anyway I can encorporate this to a windows game? Would I need to make an actual autohotkey file and specify it in the game properties under launch box? Any advice is appreciated as usual. The script you put together works perfectly with redream and pcsx2 btw.

We can try:

Choose a directory you want to save the scripts to.

Go to your launchbox installation files... C:/Users/your username/Launchbox/Autohotkey, or wherever you have it installed. COPY (dont move, copy and paste) Autohotkey.exe to your chosen directory.

Rename the new Autohotkey.exe to whatever you want, for this example, i'll call it "my script.exe".

Create a txt file in the same directory as "my script.exe". Rename the txt file to "my script.ahk". Both the .exe and .ahk need to be named the same.

Right click on "my script.ahk", click edit.

Copy and paste the following:

#SingleInstance force
SetTitleMatchMode, 2

WinWaitActive, NullDC
Sleep, 5000  ;wait 5 seconds before rotation
Send {ctrl down}{alt down}{up down}{ctrl up}{alt up}{up up}
Return


$Esc::
{
WinGetActiveTitle, WindowTitle
WinGet, PName, ProcessName, %WindowTitle%

Send {ctrl down}{alt down}{right down}{ctrl up}{alt up}{right up}

Process, Close, %PName%

Exitapp
}

Note: Instead of a loop, like the previous scripts, we can use winwaitactive, it gives us the same result and is prob better than having a loop.

In this script change NullDC to a word within the games window title bar and change the sleep 5000 if needs be. 

Click File, Save.

In Launchbox, find the game you want to rotate. Right click on it, edit.

Go to the "additional apps" tab.

Click "add application"

Give it any name.

Click "browse" and find "my script.exe"

Check the "run before main application" box.

Click OK

See how that goes.

 

 

Link to comment
Share on other sites

On 7/6/2018 at 12:01 AM, jayjay said:

 

Edit:

To check if its not a issue with the timing of the rotation, try the following if the above script doesn't work correctly.


#SingleInstance force
SetTitleMatchMode, 2

Loop
IfWinActive, nullDC
{

Sleep, 5000  ;wait 5 seconds before rotation
Send {ctrl down}{alt down}{up down}{ctrl up}{alt up}{up up}
Break
}
Return


$Esc::

{

Send {ctrl down}{alt down}{right down}{ctrl up}{alt up}{right up}

Process, Close, {{{StartupEXE}}}

}

 

@jayjay Thanks a ton, I will give this a shot this week. 

Link to comment
Share on other sites

Q: I run Pinball Arcade tables via Fre Cam Mod. Either I run them as a shortcut (no emulator), or I run them as an Emulator, with an extra param for the given table. So far either option 2 dosnt work, or the autoexit script for it dosnt work... (Tried the alt+f4 one, and the most common too).

Any input or solution would be great, like is there a way to run those AHK script inside of Launchbox but for "window" games?

Regards,

Link to comment
Share on other sites

I don't know too much about your specific 'problem' that you need solving, but you can certainly run an AHK script, or batch file with Windows games by importing them as an "Additional Application" and then combining it (or them) with your Windows shortcut. You can then set the AHK script or batch file to "run before" the main application. It is a manual process and a little more time consuming than the built in LaunchBox AHK thing that works with emulators.

Edited by JamesBond@ge
  • Like 1
Link to comment
Share on other sites

Heya folks, I've been trying to cannibalize an AHK script from Rocketlauncher to move CemU's Gamepad View window to my second monitor upon startup but I'm having trouble getting it to function.

CemU starts up, the Escape exit script I have works fine, but the window doesn't move at all. The script is here:

FadeInExit()

; Attempt to move Gamepad to New Window
SysGet, Mon2, Monitor, 2 ; Get second Monitor Info X and Y
WinGetPos, Padx, Pady, Padw, Padh, GamePad View ; Get the GamePad's Width and Height Probably not necessary as we maximize below
WinMove, GamePad View,, %Mon2Left%, %Mon2Top%, Padw, Padh ; Move Window to second monitor
WinMaximize, GamePad View ; Maximize window to fill Monitor
WinSet, Style, -0xC00000, GamePad View  ; Remove the title bar

primaryExe.Process("WaitClose")

So far I've tried removing the FadeInExit() and PrimaryExe.Process lines, as they're clearly some part of RocketLauncher. I've also axed the variables for getting the size as the author himself says they're unneeded, and I tried adding a sleep delay to the start of the script. No changes, nothing happens on every start. Any ideas?

Edited by DjBlades
Link to comment
Share on other sites

  • 2 weeks later...
On 7/1/2017 at 6:38 AM, ckp said:

In case you want to start Xpadder.exe with an emulator's games and then exit Xpadder when exiting the game, you can add this ahk code to your emulator's AutoHotkey Script tab:


Run, C:\Xpadder\Xpadder.exe /m
$Esc::
{
        Run, C:\Xpadder\Xpadder.exe /C
	Process, Close, {{{StartupEXE}}}
}

Just change the path to where you put your Xpadder.exe file.

hy, i have changed xpadder with joytokey .... but the script not close when exit what can i do?

Link to comment
Share on other sites

Hi folks

 

Just looking to see if anyone can help me with ParaJVE (Vectrex emulator that runs under Java), and Xpadder. I want Xpadder to start when I launch a Vectrex game, and I want Xpadder to close when I quit the emu and return to LB. The script from early on in this thread certainly boots Xpadder, but it won't close it after I quit ParaJVE. Script here:

 

Run, C:\Xpadder\Xpadder.exe /m
$Esc::
{
        Run, C:\Xpadder\Xpadder.exe /C
	Process, Close, {{{StartupEXE}}}
}

Obviously I've altered the paths to Xpadder to suit my own installation. I have a feeling that Launchbox isn't recognizing when ParaJVE has closed, and therefore isn't executing the secondary part of the script to close Xpadder. I can manually close Xpadder via the command prompt with the above command, so the syntax is fine, it's just LB doesn't know when to execute it I feel. I'm wondering if it's possible to maybe alter the script to check for an instance of Java running, and if so, fine, if not, exit Xpadder?

Link to comment
Share on other sites

6 hours ago, launcherbox said:

Hi folks

 

Just looking to see if anyone can help me with ParaJVE (Vectrex emulator that runs under Java), and Xpadder. I want Xpadder to start when I launch a Vectrex game, and I want Xpadder to close when I quit the emu and return to LB. The script from early on in this thread certainly boots Xpadder, but it won't close it after I quit ParaJVE. Script here:

 


Run, C:\Xpadder\Xpadder.exe /m
$Esc::
{
        Run, C:\Xpadder\Xpadder.exe /C
	Process, Close, {{{StartupEXE}}}
}

Obviously I've altered the paths to Xpadder to suit my own installation. I have a feeling that Launchbox isn't recognizing when ParaJVE has closed, and therefore isn't executing the secondary part of the script to close Xpadder. I can manually close Xpadder via the command prompt with the above command, so the syntax is fine, it's just LB doesn't know when to execute it I feel. I'm wondering if it's possible to maybe alter the script to check for an instance of Java running, and if so, fine, if not, exit Xpadder?

Ok, just for the sake of completion and if anyone else ever has this problem, I've figured it out. Basically, the best I can deduce is that because the version of AHS within Launchbox closes when LB closes, it's not persistent (meaning the second the emulator is closed, AHS closes too, leaving it unable to fulfill tasks post emulator shutdown). How I got around this is as follows:

 

1) We need to run AHS independently of LB, so we can control it beyond emulator shutdown. So first, you need to create your own .txt file, and give it a name like myscript.ahk. You then edit this file (I use Notepad++), and I inserted this code:

#SingleInstance, Force
#Persistent
SetTitleMatchMode, 2
DetectHiddenWindows, On
 
SetTimer, ProcessCheckTimer, 2000
Return
 
ProcessCheckTimer:
Process, Exist, javaw.exe
pid1 := ErrorLevel
If (!pid1)
         {
	 Run, F:\Tools\Xpadder-v2014.01.01\Xpadder\Xpadder.exe /C
         ExitApp
         }



*the path to Xpadder will need to be adapted to your own installation path

 

In essence, what's happening here is that the process javaw.exe is being checked to see if it's running (ParaJVE runs under Java), and when it's not found to be running (as in when you exit the emu), the Xpadder shutdown command is ran. 

2) You need to then use Additional Apps to run Xpadder BEFORE the emu starts by creating a run before app profile under Additional Apps

3) You then create a second instance of an Additional App profile, and for the application .exe path, you point it towards you myscript.ahs. You will also need to associate AHS files within windows, with the AHS application itself found in the Launchbox installation folder.

 

So you basically have told LB to boot Xpadder before the emu starts. You're then telling it to run your new script when the application ends, and this script takes care of shutting down ParaJVE for you, and it all closes nicely. This is probably very convoluted, I don't really know, I've no experience with scripting, but for whatever reason, ParaJVE does not play nicely with LB when you need LB to recognise the emu has shut down. 

  • Thanks 1
Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...
On 6/11/2018 at 2:49 PM, Link138 said:

Hey, folks. I've got several Saturn emulators working well through LaunchBox (both RA cores working well), but I also want to use the newer Yaba Sanshiro emulator so I can pump up the internal resolution of some 3D games, like Shining Force 3.

The problem is every time I launch a game in Yaba Sanshiro through Launchbox the game is displayed only in the lower-left hand corner of the screen, only about 25% of the screen is used. The rest is black. If I alt+enter twice I can get it to run fullscreen no problem, but when I'm playing on the couch I don't have a keyboard next to me.

Anyone have any ideas on what I can do to force Yaba Sanshiro to display in fullscreen from Launchbox?

Thanks for any help!

I am having the same issue with Yaba Sanshiro emulator going to fullscreen. Has anyone found a solution to this problem? Thank you!

Link to comment
Share on other sites

Hmm I had that version running without issues the other day, but I switched back to using RetroArch due to the simplification of using cores for an already-setup emulator.  That being said, make sure you have the latest version of that version of Yabause installed (http://www.uoyabause.org/static_pages/download) and then in the video options make sure you have the correct full screen resolution for you monitor selected in the drop down, and the make sure Start in Fullscreen ticked off.  I don't recall having to do anything else, except checking those settings.  You can of course create a AHK script to force pressing alt-enter twice when you launch the emulator, but you shouldn't have to if you have the settings set correctly in the emulator.... or at least I didn't have to.

Link to comment
Share on other sites

25 minutes ago, CDBlue said:

Hmm I had that version running without issues the other day, but I switched back to using RetroArch due to the simplification of using cores for an already-setup emulator.  That being said, make sure you have the latest version of that version of Yabause installed (http://www.uoyabause.org/static_pages/download) and then in the video options make sure you have the correct full screen resolution for you monitor selected in the drop down, and the make sure Start in Fullscreen ticked off.  I don't recall having to do anything else, except checking those settings.  You can of course create a AHK script to force pressing alt-enter twice when you launch the emulator, but you shouldn't have to if you have the settings set correctly in the emulator.... or at least I didn't have to.

I have tried deleting it and unzipping it and it still does the same thing...loads in fullscreen but only displays in the lower left hand corner of the monitor.

Link to comment
Share on other sites

Just tried that emulator again, and I'm also seeing what you're seeing.  I thought I had it working with that emulator the other day, but I just realised I had issues with it so I switched to the Kronos port of Yabause instead (http://www.emutalk.net/threads/57084-Kronos-1-4-0).  Maybe give that one a try if you are still having issues with the emulator you're trying to get running.  It seems to be more compatible with fullscreen, and runs well for me.  Sorry about the confusion before, I swear I thought I had that running in fullscreen without issues before, but guess not.

Link to comment
Share on other sites

  • 2 weeks later...

I'm looking for an AHK script that will load different IPAC configurations for different windows games.

For example: I have 3 games (Injustice; Street Fighter IV and Killer Instinct). I've created the IPAC configs for each and a main default.ipc for all retro games.

I'd like the AHK script to load the appropriate ipc file, for example Injustice.ipc when the game is loaded and go back to default.ipc when I exit. 

also the same for the other windows games.

I started with the line below, but confused on what to do next, I know it involves an IF /Go to function.

Run C:\Program Files (x86)\WinIPAC\MKXL.ipc
 

Any advice would be appreciated

 

 

 

Link to comment
Share on other sites

On 7/1/2017 at 2:18 AM, Lordmonkus said:

I want to have a single thread for this so please share your useful and interesting AHK scripts here.

Provide a short description of what the script does put the script in the post using the code function (the <> at the top of the post box).

Launch Higan in fullscreen mode since not all versions of Higan has a command line parameter to do this:


#NoEnv

Sleep, 3000
SetKeyDelay, -1, 110
Send {F11}
Return

Universal close emulator with the Escape key, useful for ePSXe:


$Esc::
{
    Process, Close, {{{StartupEXE}}}
} 

Hide your mouse cursor for certain emulators that don't hide your mouse, change the numbers to match your monitors resolution:


MouseMove, 1920, 1080

 

Trying to use the universal close emulator auto hotkey script with dolphin when running gamecube titles but it quits BB completely not just the emulator. The annoyance is when closing a title the dolphin GUI remains on the screen, trying to get that to close when i quit the title.

Any ideas?

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