Jump to content
LaunchBox Community Forums

Auto Hotkey Scripts


Lordmonkus

Recommended Posts

4 hours ago, Jayinem said:

Actually I already have it. After your help with 3 different scripts I have it where it maximizes when minimized, maximizes when restores and reopens after closing. Guess it doesn't matter that it's multiple scripts.

Maximize after restore:

When you say "maximize after restore", are you saying the window is there, but neither maximized nor minimized? 

i.e. You can resize the window by dragging the edges and you can move it around by clicking and dragging the title bar. 

if so, that's what the 2nd if statement checks in the script I gave above.  "if WinState = 0".

 

You could combine the 3 into one (actually 2, eliminating one)

#SingleInstance Force

FullEXE = "D:\Jay\Launchbox\Launchbox.exe"
Path = "D:\Jay\Launchbox\"
EXE = Launchbox.exe

loop
{
    Process, Exist, %EXE%
    If (ErrorLevel = 0)
    {
        Run, %FullEXE%, %Path%, hide
        Sleep 5000
    }
    Else
    {
        WinGet, WinState, MinMax, ahk_exe %EXE%
        If WinState = -1
             WinMaximize, ahk_exe %EXE%
        If WinState = 0
             WinMaximize, ahk_exe %EXE%
    }

    sleep 500
}

 

 

Link to comment
Share on other sites

Right the middle button between minimize and close on the top right. If that gets pressed or there's a windowed launchbox it maximizes it.

Thanks for the additional script btw one more inquiry speaking of those buttons, is there anyway to hide those buttons such as minimize close restore? I really wouldn't even mind hiding the entire Launchbox menu in the top if possible, but of course to where it's not impossible to unhide them. But if that's not possible it is alright, I am happy with what I have.

Link to comment
Share on other sites

32 minutes ago, Jayinem said:

is there anyway to hide those buttons such as minimize close restore?

You'd need to edit the Theme.

For the Default Theme, after making a copy of the folder, edit MainView.xaml in the 'copy'.

Completely remove the sections starting with:

<Button x:Name="Minimize"... />
<Button x:Name="Maximize"... />
<Button x:Name="Restore"... /> 
<Button x:Name="Close"... /> 

Then in LaunchBox, under Tools < Options (because you DIDN'T remove the entire LaunchBox menu ;)), change the Theme to your copy.

 

Otherwise, for "normal" windows (like Notepad), you'd use (in an AHK script)

;Remove Title bar
LWIN & LButton::
WinSet, Style, -0xC00000, Untitled - Notepad
return

;Restore Title Bar
LWIN & RButton::
WinSet, Style, +0xC00000, Untitled - Notepad
return

(Windows key + Left (or Right) mouse button)

  • Like 1
Link to comment
Share on other sites

Since I don't have premium I abandoned the idea of editing theme which is ok.

But how do I make a script that bypasses this annoying Launcher with Chrono Cross Radical Dreamers? Even if you use a shortcut or direct .exe the launcher comes up. So I want to click on certain position on screen and left click on the launcher where it tells you to launch the game to at least bypass it even though it'll still launch.

 

I got the coordinates through windowspy, just can't remember how to put it into a script.

 

Screen:    1292, 490 (less often used)
Window:    1149, 344 (default)
Client:    1149, 344 (recommended)
Color:    1D2026 (Red=1D Green=20 Blue=26)

And the Launcher comes back up when I escape the game, how do I run a script that closes it along with the game when escaping?

This script below closes it if I do it separate from having the game running through launchbox

 

SetTitleMatchMode 2
WinClose ahk_exe CHRONOCROSS_LAUNCHER.exe

But when I hit escape in the game it does this confirm do you want to close in the game and you have to go to exit, and only then does the launcher come back up. So how would I make that work if possible? Can't believe a game that came out in 2022 would have a launcher that's not bypassable and then even more dumb force the launcher to reopen after you escape from the game and confirm escape.

 

Edit I figured out how to click on the launcher automatically

 

SetTitleMatchMode 2
run CHRONOCROSS_LAUNCHER.exe
Sleep 3000
MouseClick, Left, 1109, 325 

However one strange thing I've never seen, it only works on the .ahk but if I turn it into an .exe the mouse doesn't move?

But I could just use the .ahk in launchbox I guess, just need to how to autoclose this launcher with the game.

Edited by Jayinem
Link to comment
Share on other sites

2 hours ago, Jayinem said:

However one strange thing I've never seen, it only works on the .ahk but if I turn it into an .exe the mouse doesn't move?

But I could just use the .ahk in launchbox I guess, just need to how to autoclose this launcher with the game.

The AHK script is a smaller footprint and easier to manage than an exe. ;) 

To close the launcher as well, just add the standard escape sequence to the bottom of the script.

$Esc::
{
   WinClose, ahk_exe CHRONOCROSS_LAUNCHER.exe
}

You might be able to, before WinClose, add your necessary MouseClick to click on Exit.

Link to comment
Share on other sites

49 minutes ago, JoeViking245 said:

The AHK script is a smaller footprint and easier to manage than an exe. ;) 

To close the launcher as well, just add the standard escape sequence to the bottom of the script.

$Esc::
{
   WinClose, ahk_exe CHRONOCROSS_LAUNCHER.exe
}

You might be able to, before WinClose, add your necessary MouseClick to click on Exit.

In this case it doesn't work, because the launcher launches before the game, then closes when the game runs, then waits until you escape the game THEN relaunches. Alt+F4 closes the game but then the launcher reappears, escape does not close the game, instead you get this Escape menu which is still technically in game. It's really a joke like they're going out of their way to be annoying. And notice it says quit game and return to launcher.

Untitled.png

Maybe there isn't a solution because I can't run a loop to always close launcher, I need it to run the game initially.

Edited by Jayinem
Link to comment
Share on other sites

1 hour ago, Jayinem said:

With mouse click I can exit if I click on the launcher set sleep and it'll close it, but winactivate is not working I ran WindowSpy tried everything there. Just a major PITA for no reason.

What do you get when you WindowSpy the "Escape Menu?  I presume it shows you an exe filename.

Try changing the escape sequence to match what you need.

!F4::
{
   WinClose, ahk_exe [the_filename_you_found].exe
}

This way you're not clicking their "Quit".  You're [force] closing 'that' window.

Link to comment
Share on other sites

2 minutes ago, JoeViking245 said:

What do you get when you WindowSpy the "Escape Menu?  I presume it shows you an exe filename.

Try changing the escape sequence to match what you need.

!F4::
{
   WinClose, ahk_exe [the_filename_you_found].exe
}

This way you're not clicking their "Quit".  You're [force] closing 'that' window.

That escape menu is still in game, the Window doesn't change at all. It's like some games where you hit escape but it doesn't actually escape. My escape key has a script always running $Esc::!F4, so it's supposed to combine the two, but it doesn't work on that game because the game must have programmed it that way. Only if I actually hit alt + F4 does it escape, but then the launcher comes up. I tried making a script where !F4 = !F4 twice with a sleep on it but didn't work because I can't seem to activate the launcher window through AHK.

Link to comment
Share on other sites

 

@Jayinem you should read up on what SetTitleMatchMode is. you put it into mode 2 for every thing you post, but nothing you post requires it.

every time you have ended up referring to something through a WinTitle you are using ahk_criteria specifically ahk_exe

the exe is not impacted by SetTitleMatchMode. an exe is not a window title! SetTitleMatchMode is only useful to adjust (and that is, if only needed to adjust from default mode 1) if you are referring to the window's window title!

 

 

 

 

4 hours ago, Jayinem said:

But how do I make a script that bypasses this annoying Launcher with Chrono Cross Radical Dreamers?

you cannot! make sure to try Google before posting questions because I found this out in 1 min after a single search on their Steam forum! devs designed the game/launcher to work like this.

Link to comment
Share on other sites

here would be my approach to it.

 

Run, CHRONOCROSS_LAUNCHER.exe
WinWait, ahk_exe CHRONOCROSS_LAUNCHER.exe
ControlSend, [control], {Enter}, ahk_exe CHRONOCROSS_LAUNCHER.exe
WinWait, ahk_exe CHRONOCROSS_GAME.exe
WinWaitClose, ahk_exe CHRONOCROSS_GAME.exe
WinWait, ahk_exe CHRONOCROSS_LAUNCHER.exe
WinClose, ahk_exe CHRONOCROSS_LAUNCHER.exe

idk what the actual game exe is, so change out "CHRONOCROSS_GAME.exe" appropriately

change the control parameter to the control (button) on the launcher, assuming said launcher actually has a name for the play control (button). you can get this info with WinSpy. if the controls have no name, then leave that parameter empty and it would work just the same as regular Send. If that is the case this plan would only work if you can prove it works though. That would mean you open the launcher and then press enter or even spacebar on your keyboard. Does it do what you want it to? that being close the launcher and launch the game? if so, this is automating that.

mouse clicks is a bad way to go. only in a last resort would I do that. and you need more because it only would work if it's the top most window. you can put the window on top prior to the click.

11 minutes ago, Jayinem said:

I can't seem to activate the launcher window through AHK.

use AlwaysOnTop, not WinActivate

if there are no name for the controls you might need to put the launcher AlwaysOnTop even for a Send command to work

 

I think you're going at it wrong. the game already has native methods for exiting via keyboard and a controller! don't try and come up with some new method there. the only part that would need automation is hitting play on the launcher, and then closing the launcher at exit of the game.  I will say, a launcher at the start of a game is very normal. A launcher popping back up after exiting, is very abnormal. That's on the game's devs.

Link to comment
Share on other sites

30 minutes ago, skizzosjt said:

 

@Jayinem you should read up on what SetTitleMatchMode is. you put it into mode 2 for every thing you post, but nothing you post requires it.

every time you have ended up referring to something through a WinTitle you are using ahk_criteria specifically ahk_exe

the exe is not impacted by SetTitleMatchMode. an exe is not a window title! SetTitleMatchMode is only useful to adjust (and that is, if only needed to adjust from default mode 1) if you are referring to the window's window title!

 

 

 

 

you cannot! make sure to try Google before posting questions because I found this out in 1 min after a single search on their Steam forum! devs designed the game/launcher to work like this.

It's funny I just recently looked over this entire thread and you're the first person saying "try google" we're here to help each other, if you don't want to help then don't help but don't nag me about a question that isn't common. Most of the questions on this thread can probably be answered on Google. You're the only one getting annoyed at someone and telling them to check there, that's your issue not mine. I will not be mistreated by you so please stop. JoeViking is a mod and he's kind and helps people he doesn't bark orders at people like you're trying to do.

Edited by Jayinem
Link to comment
Share on other sites

I do my best to try to teach someone to fish.

I also try my best to not hand them a fish. no one learns anything that way.

Using AlwaysOnTop requires different syntax. Use WinGet. If you want to find stuff on AHK their docs are very easy to navigate

https://www.autohotkey.com/docs/v1/lib/WinSet.htm#AlwaysOnTop

 

omg you don't even have a clue what you're talking about. 🤦‍♂️ AlwaysOnTop has been there since the beginning. lol

Link to comment
Share on other sites

1 hour ago, Jayinem said:

That escape menu is still in game, the Window doesn't change at all. It's like some games where you hit escape but it doesn't actually escape. My escape key has a script always running $Esc::!F4, so it's supposed to combine the two, but it doesn't work on that game because the game must have programmed it that way. Only if I actually hit alt + F4 does it escape, but then the launcher comes up. I tried making a script where !F4 = !F4 twice with a sleep on it but didn't work because I can't seem to activate the launcher window through AHK.

@skizzosjt has a great idea using the ControlSend command. Way more reliable than moving the cursor and clicking.  The Waits and WaitClose's can often be overlooked and underutilized.  Glad they were brought up.  Thanks S!  (I was being too lazy to think. 😊)

Looking the Exit screen screenshot, it 'says' you can press Enter for "OK".  Which leads me to believe that you can also "press" arrow keys as necessary to move to that menu item.  This leads me to believe that on the initial launcher screen, you can do the same thing.

This also leads me to believe that you're using a controller for the game and that these menus can be handled with said controller.  But can appreciate wanting to automate these little extra steps.

Your launchers exe file is "CHRONOCROSS_LAUNCHER.exe".  What is the exe filename of the actual game?

Plagiarizing the script provided above:

  • This assumes the actual games exe is "chronocross.exe"
  • This assumes at the Launcher window, you just need to press Enter
  • This assumes the exit window places the cursor on Audio and you need to down arrow 3 times. (then press Enter)
    #SingleInstance Force
    SetKeyDelay, 0, 50
    
    Run, CHRONOCROSS_LAUNCHER.exe
    WinWait, ahk_exe CHRONOCROSS_LAUNCHER.exe
    ControlSend,,{Enter},ahk_exe CHRONOCROSS_LAUNCHER.exe
    WinWait, ahk_exe chronocross.exe
    WinWaitClose, ahk_exe chronocross.exe
    WinWait, ahk_exe CHRONOCROSS_LAUNCHER.exe
    ControlSend,,{down}{down}{down}{Enter},ahk_exe CHRONOCROSS_LAUNCHER.exe

 

The 2nd line is in case the launcher is being stubborn about accepting key presses from AHK.  The duration is suitable for most apps. But you can try increasing it of it needs more.

Do test with an actual keyboard 1st to get the necessary physical key presses needed.

Then just replace the name of the actual game's exe and the actual controls (keys) needing pressed.  If the key presses for some reason don't work, just replace the 2 ControlSend's with the MouseClick method you discovered above.

Link to comment
Share on other sites

57 minutes ago, JoeViking245 said:

@skizzosjt has a great idea using the ControlSend command. Way more reliable than moving the cursor and clicking.  The Waits and WaitClose's can often be overlooked and underutilized.  Glad they were brought up.  Thanks S!  (I was being too lazy to think. 😊)

Looking the Exit screen screenshot, it 'says' you can press Enter for "OK".  Which leads me to believe that you can also "press" arrow keys as necessary to move to that menu item.  This leads me to believe that on the initial launcher screen, you can do the same thing.

This also leads me to believe that you're using a controller for the game and that these menus can be handled with said controller.  But can appreciate wanting to automate these little extra steps.

Your launchers exe file is "CHRONOCROSS_LAUNCHER.exe".  What is the exe filename of the actual game?

Plagiarizing the script provided above:

  • This assumes the actual games exe is "chronocross.exe"
  • This assumes at the Launcher window, you just need to press Enter
  • This assumes the exit window places the cursor on Audio and you need to down arrow 3 times. (then press Enter)
    #SingleInstance Force
    SetKeyDelay, 0, 50
    
    Run, CHRONOCROSS_LAUNCHER.exe
    WinWait, ahk_exe CHRONOCROSS_LAUNCHER.exe
    ControlSend,,{Enter},ahk_exe CHRONOCROSS_LAUNCHER.exe
    WinWait, ahk_exe chronocross.exe
    WinWaitClose, ahk_exe chronocross.exe
    WinWait, ahk_exe CHRONOCROSS_LAUNCHER.exe
    ControlSend,,{down}{down}{down}{Enter},ahk_exe CHRONOCROSS_LAUNCHER.exe

 

The 2nd line is in case the launcher is being stubborn about accepting key presses from AHK.  The duration is suitable for most apps. But you can try increasing it of it needs more.

Do test with an actual keyboard 1st to get the necessary physical key presses needed.

Then just replace the name of the actual game's exe and the actual controls (keys) needing pressed.  If the key presses for some reason don't work, just replace the 2 ControlSend's with the MouseClick method you discovered above.

Yeah I dunno it's not working. The exe is RADICALDREAMERS instead of chronocross.exe I did put that in, no response from the launcher on the keypresses.

Tab works when I press it on the actual keyboard so I replaced your down down down with tab tab tab, but no response.

Edited by Jayinem
Link to comment
Share on other sites

Just now, JoeViking245 said:

Then it sounds like you're stuck with using the MouseClick method you discovered above.  Or just deal with the extra clicks (or controller button presses). ;) 

No problem, thanks for helping.

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