Jump to content
LaunchBox Community Forums

Auto Hotkey Scripts


Lordmonkus

Recommended Posts

Sometimes my Launchbox goes fullscreen where it covers the taskbar and I don't ever want it to. Could I have a script that checks periodically if it's covering the taskbar and if it does make it where it isn't? 

I've tried 

WinActivate, Launchbox.exe

WinRestore, Launchbox.exe 

but it's not working.

Edit: I was able to do it with a hotkey I just needed to make WinRestore be WinRestore, A to work on any app but I want there to be a timer or loop that checks if it's fullscreen and do it automatically. I just don't know how to write that script. 

Edited by Jayinem
Link to comment
Share on other sites

12 hours ago, Jayinem said:

Sometimes my Launchbox goes fullscreen where it covers the taskbar and I don't ever want it to.

How are you getting it to cover the taskbar?  Is your taskbar set to autohide?   I can't get mine to cover the taskbar at all.  I assume you're talking about the LB GUI vs. a loading screen or something similar. 

When does this happen / what seems to trigger it?  After playing a game?  When you 'grab' the top with a mouse-click and move it yourself?  Clicking between the minimize and maximize buttons?  The GUI window should stay put unless you move it yourself.  Do you have some other script running that somehow makes it full screen**?

 

12 hours ago, Jayinem said:

I want there to be a timer or loop that checks if it's fullscreen and do it automatically

Checking if an app is "full screen" in AHK isn't very straight forward or reliable.  A window** that is full screen is different than a window that is maximized.  

Here's something quick and dirty that'll sorta do what you're asking (in a roundabout way).  But it'd be better to figure out why (and how?) LB is covering the taskbar in the 1st place. Then (possibly) fix that.

Loop
{
   if WinActive("ahk_exe LaunchBox.exe")
      WinRestore
}

(You don't need to tell WinRestore which window to restore because it's passed along from the if statement.)

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

Got home tried it seemed to work until I did a reboot, now it doesn't work. I made the script #persistent but it didn't help. 

 

This is my entire TV when it happens. There should be a taskbar on the bottom I didn't crop it or anything.

 

Untitled.thumb.png.8822111cb777713c97cff0c16ed2983b.png 

 

Edit: Weirdly it's doing the opposite of what I want. If I hit the little square on Launchbox in the top right next to close that says Maximize or Restore, it automatically makes it go fullscreen as if the script it saying "keep it fullscreen with no taskbar" 

And so I changed it instead of WinRestore I changed it WinMaximize in the script and sure enough it won't allow it to cover the taskbar and stays Windowed Fullscreen. 🤣

Untitled1.thumb.png.6734d3bb4599be480bf0100c7fe3922b.png

 

 

 

Edited by Jayinem
  • Game On 1
Link to comment
Share on other sites

Got another question I want to change the DPI scaling of Launchbox only. I have a script that changes the DPI but it does it for the entire computer screen. I want -1 DPI from what I have set in Windows. I tried changing all the per application options Windows gives when right clicking and choosing it didn't help. 

For reference here is the script that changes DPI but it does it for the entire computer not just Launchbox. I had to get my TVs reg keys out of regedit.

SetDpi(-1)

SetDpi(dpi) {
    RegWrite, REG_DWORD, HKEY_CURRENT_USER\Control Panel\Desktop\PerMonitorSettings\VIZ10390_01_07E4_30^30BB376176AE7BF6A3A1FE1F935346BE, DpiValue, % dpi 
    RegWrite, REG_DWORD, HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\GraphicsDrivers\ScaleFactors\VIZ10390_01_07E4_30^30BB376176AE7BF6A3A1FE1F935346BE, DpiValue, % dpi
    ChangeResolution() 
}
return


ChangeResolution(Screen_Width := 1920, Screen_Height := 1080, Color_Depth := 32) ; change these values for your screen resolution
{
    VarSetCapacity(Device_Mode,156,0)
    NumPut(156,Device_Mode,36) 
    DllCall( "EnumDisplaySettingsA", UInt,0, UInt,-1, UInt,&Device_Mode )
    NumPut(0x5c0000,Device_Mode,40) 
    NumPut(Color_Depth,Device_Mode,104)
    NumPut(Screen_Width,Device_Mode,108)
    NumPut(Screen_Height,Device_Mode,112)
    Return DllCall( "ChangeDisplaySettingsA", UInt,&Device_Mode, UInt,0 )
}
return

And yes I'm aware that there's a scale on the button bar of Launchbox but it doesn't do what I want.  I want 5 games to show on a row and the icons are too small when I do that. The correct DPI does what I want but it also doesn't work for the rest of my computer unfortunately. 

Edited by Jayinem
Link to comment
Share on other sites

6 hours ago, Jayinem said:

I tried changing all the per application options Windows gives when right clicking and choosing it didn't help.

I'm curious, you say it didn't 'help'. But did it even do 'anything'? Good, bad or indifferent?  And you tested it on the executable in the /Core/ folder?  Actually, that's all more-so out of morbid curiosity because I don't think you're going to be able to accomplish what you want via Windows.  As you've seen, it's pretty much all or nothing.

Have you messed with the adjustments under Tools, Options, Visuals, Boxes, Spacing?  That might just be your ticket.

Link to comment
Share on other sites

Hi guys been lurking for a hot minute. I have a OLD PC game that is awesome. Micky Mouse: Castle of Illusion (Remastered). This game just wont load full screen with BigBox. it starts to flicker. I did not know what to do so I set it windowed. No more flicker but now it wont load on my second monitor (The TV). SO I have Display tools... I set a hot key of Ctrl+Alt+UP arrow and poof the active screen goes to the correct monitor. But I would like this to be done automatically. Unlike  emulators I do not see a startup for PC games. I see a AHK thing but it seems to be for ALL Windows games. Only this game refuses to start on my TV.

 

Alternatively if someone knows how to get rid of the flicker when Fullscreen that would be great too. Also happens for Transformers (War/Fall) Of CyberTron. I know old PC stuff... Love them tho.

Link to comment
Share on other sites

7 hours ago, Kinglifer said:

This game just wont load full screen with BigBox.

Does it load full screen when you launch it on its own?  It should load the same via BigBox as it does when double-clicking the exe file in Windows Explorer.

 

I don't have any [old] PC games on my setup, so can't help with any PC game particulars.  But being as we're in the AutoHotkey Scripts section of the forum: 

You could setup an Additional Application for the game(s) and point it to your myScript.ahk file and check Automatically Run Before Main Application

In your script, remove the  ^!{Up}::  hotkey label and add a Sleep, 5000 to the beginning.  Adjust the Sleep 5 seconds ("5000") up or down to accommodate game load time, before moving the window.

 

If launching the game full screen (vs windowed) opens where it should (on the TV), but there's flickering, then there's most likely a game/display/monitor/tv setting that needs adjusting.  But that stuff is beyond me.

Link to comment
Share on other sites

On 8/24/2021 at 12:57 PM, JoeViking245 said:

For having been spot on before and with more details here, I think I'm good now. lol

I think you'll be better off just using a batch file (vs an AHK script).  You get the same outcome either way.  Plus it's easier to describe. ;) 

Create 2 new text files.  "Start x360ce.txt" and "Shutdown x360ce.txt".  Or name them what ever you want.

Inside "Start x360ce.txt", put

Start /min "D:\Games\Extras\x360ce\x360ce.exe"

Inside "Shutdown x360ce.txt", put

c:\windows\system32\cmd.exe /c c:\windows\system32\TASKKILL.exe /F /IM x360ce.exe

Save and close both files.  In Windows Explorer, rename them to have the file extension ".bat"  i.e. "Start x360ce.bat".  

If  you can't see the file extensions...

image.png.6d2b42d1ed5491af73e76216ff29373d.png

Click the "View" tab and check "File name extensions"

image.thumb.png.649825103746f2a97a81158b5e7008af.png

When all's good, they should look like:

image.png.9cc87f1c50a05e205129abe59c5eb845.png

Add these to BigBox, and play games.:D

Joeviking245.. I have a UCR profile set up to emulate a Xbox controller for my steam games. I have been trying to convert your advice to my situation: loading a specific UCR profile when I open steam games and close it down when the game is closed. I always seem to run into different problems: either not working at all or opening in a separate window and freezing the emulation. Would you be able to offer some advice on the best way to accomplish this?  Also: would I have to add a script to every individual game or could it be a global script per platform?  Thank you. 

Link to comment
Share on other sites

Hi guys... I need some serious help. 
Problem. I have two games. Transformers War of Cybertron and Fall of Cybertron. Old games. They do not have the option to load on my secondary screen. Also the save folder is the SAME FOLDER (Come on Activision)_.

Fix Plan... an AHK script that moves the window to the secondary monitor and then copies the save FOLDER to the default section in my documents folder.

When the game ends the Default game save folder is moved to a safe space so there is no corruption if the other game is played. 

 

Code I got so far that does not work...

#NoEnv
user1 = "TRANSFORMERS: Fall of Cybertron"
user2 = "TRANSFORMERS: War of Cybertron"
Sleep, 50
If WinActive(user1)
 Send, ^!{Up}
If WinActive(user2)
 Send 2
Sleep, 50
Return

source = C:\Users\Halo\Documents\My Games\Transformers\Fall of Cybertron
target = C:\Users\Halo\Documents\My Games\Transformers\TransGame
SysGet, mon1, MonitorWorkArea, 1
WinWait, ahk_exe TFOC.exe
SoundBeep, 1500
WinMove, %mon1Left%, %mon1Top%
FileMoveDir, %source%, %target%
If ErrorLevel
 MsgBox, 48, Source to target, An error occurred while moving.
WinWaitClose
SoundBeep, 1000
FileMoveDir, %target%, %source%
If ErrorLevel
 MsgBox, 48, Target to source, An error occurred while moving.

Any help would be appreciated...
Thank you

Link to comment
Share on other sites

On 1/23/2022 at 8:38 AM, JoeViking245 said:

In your script, remove the  ^!{Up}::  hotkey label and add a Sleep, 5000 to the beginning.  Adjust the Sleep 5 seconds ("5000") up or down to accommodate game load time, before moving the window.

If I do this... how will the hot key I made activate? That part lost me. I know the Sleep section... timing there... Got that... Hey... thank you for answering as well. 

Link to comment
Share on other sites

11 hours ago, jivemd said:

Joeviking245.. I have a UCR profile set up to emulate a Xbox controller for my steam games. I have been trying to convert your advice to my situation: loading a specific UCR profile when I open steam games and close it down when the game is closed. I always seem to run into different problems: either not working at all or opening in a separate window and freezing the emulation. Would you be able to offer some advice on the best way to accomplish this?  Also: would I have to add a script to every individual game or could it be a global script per platform?  Thank you. 

I'm afraid I can't really help with this as I've never used the Universal Control Remapper program.  

11 hours ago, jivemd said:

opening in a separate window and freezing the emulation

Is this opening a Command Prompt Window?  When this happens, if you use {Alt}+{Tab}, can you switch to the game and then play?  

Link to comment
Share on other sites

11 hours ago, Kinglifer said:

Code I got so far that does not work...

Can you provide a little more detail?  Does any of it work? Where does it stop working?  Possibly at "Return"?  If you're running it Before Main Application, the window might not be active yet.   You may need to WinWait, ahk_exe TFOC.exe before trying to Send, ^!{Up}  or Send, 2.

Link to comment
Share on other sites

11 hours ago, Kinglifer said:

If I do this... how will the hot key I made activate? That part lost me. I know the Sleep section... timing there... Got that... Hey... thank you for answering as well. 

As an Addition App set to Run Before Main app.  'We' removed the hotkey part and replaced it with a Sleep timer.

So when you launch the game, this script will load 1st and then the game. The script will Sleep for 5 seconds, giving the game time to load.

Alternatively (and better), replace Sleep with a WinWait statement (just like your above post).  This way you don't have to guess at the "5 seconds" (more or less).

Link to comment
Share on other sites

20 hours ago, JoeViking245 said:

Can you provide a little more detail?  Does any of it work? Where does it stop working?  Possibly at "Return"?  If you're running it Before Main Application, the window might not be active yet.   You may need to WinWait, ahk_exe TFOC.exe before trying to Send, ^!{Up}  or Send, 2.

I dropped AHK because I am just not qualified to code it. I did get it to work in DisplayFusion. 

If anyone else likes Transformers War of Cybertron, Fall of Cybertron or has a similar issue (Windows Program not being able to handle scripts) I hope this fix helps you.


To copy files once the game ends I set up an Addition App set to Run Before Main app.

In DisplayFusion I download (DisplayFusion Settings > Functions > Scripted Function > Download Scripted Function) called "Copy Directory (Overwrites Destination Files)". [Thank you Owen Muhlethaler] I renamed the script Copy Directory. (I was not sure if the brackets would work in a command line.)

You can specify your file paths on line 13 and 14, along with the overwrite setting on line 10. The same trigger applies, you can attach this to a Window Destroyed event to have it run but I just did a command line using the title of the function. DisplayFusionCommand.exe -functionrun "Copy Directory". (I did this under the Addition App area). You can also duplicate the script, and have it attached to a Window Created event and swap the source/destination to copy the folder back or just make another Addition app when the program starts if triggers are not working for you. 

Edited by Kinglifer
  • Game On 1
Link to comment
Share on other sites

53 minutes ago, tribe fan said:

Hello,

I'm trying to write a very simple script to send the F11 key to the melonDS emulator to go fullscreen after a game launches. I've tried multiple methods (including compiling the ahk to an executable and running before the app). Can't seem to get it to work.

What does your script look like so far?

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