Jump to content
LaunchBox Community Forums

Auto Hotkey Scripts


Lordmonkus

Recommended Posts

2 hours ago, Sbaby said:

At the moment it didn't work but I added these two lines and it works fine now . It is also perfect with Windows 11. Thank you very much

Good to know it works on Windows 11.  Thanks.

If you wanted, you could replace those 3 BigBox lines with just 1 like I showed.  Start ("RunWait") BigBox.exe (or LaunchBox.exe) from within the "Core" subfolder.

Link to comment
Share on other sites

On 9/16/2022 at 4:01 AM, JoeViking245 said:

If you wanted, you could replace those 3 BigBox lines with just 1 like I showed.  Start ("RunWait") BigBox.exe (or LaunchBox.exe) from within the "Core" subfolder.

Okkkk ! Thanks ! Works fine 😍

Edited by Sbaby
Link to comment
Share on other sites

Out of curiosity, I'm wondering if it's possible to create a script that just simply minimizes Big Box when launching a Steam game instead of showing the "Loading Game" message or showing a startup screen. There are a few games in my library (Spyro Reignited being a notorious offender) that take noticeably longer to launch from Big Box than from LaunchBox desktop mode or other full-screen frontends like Playnite. I think it might have something to do with how Big Box in its current form handles Window focusing.

Link to comment
Share on other sites

58 minutes ago, BlueDragon992 said:

Out of curiosity, I'm wondering if it's possible to create a script that just simply minimizes Big Box when launching a Steam game instead of showing the "Loading Game" message or showing a startup screen. There are a few games in my library (Spyro Reignited being a notorious offender) that take noticeably longer to launch from Big Box than from LaunchBox desktop mode or other full-screen frontends like Playnite. I think it might have something to do with how Big Box in its current form handles Window focusing.

Edit Game > Startup/Pause > Override Default Startup Screen Settings

Then click click Customize to adjust to your liking

Startup themes are totally optional. No need for scripting because there is already a feature that lets you customize these settings down to as fined tuned as the per game level. In your case you could try turning up the delay time on the slider so the startup screen displays longer for the games that take more time to startup, or turn them off completely if that is all you're after.

Edited by skizzosjt
typo
Link to comment
Share on other sites

1 hour ago, skizzosjt said:

Edit Game > Startup/Pause > Override Default Startup Screen Settings

Then click click Customize to adjust to your liking

Startup themes are totally optional. No need for scripting because there is already a feature that lets you customize these settings down to as fined tuned as the per game level. In your case you could try turning up the delay time on the slider so the startup screen displays longer for the games that take more time to startup, or turn them off completely if that is all you're after.

I've tried messing with that and it only seems to work when it feels like it... Even so, that still doesn't solve the problem of certain steam games (Spyro Reignited is the one I keep benchmarking for this) taking nearly 20 seconds to load when launched from Big Box even when I have both LaunchBox and the game installed on a NVME SSD... If it can't be AHK scripted, then maybe a future version of LaunchBox should just straight-up add a minimize on launch option in the override settings as a "when all else fails" sort of solution.

Link to comment
Share on other sites

I have a question regarding input blocking during a game load of my steam script, it works fine but if I inadvertently press the buttons after making my choice  (while loading the game) It often sends inputs to bigbox, which instead has to sit down and shut up, and that's not good. I found a solution by entering script  "BlockInput, On" while loading, and "BlockInput, Off"  as soon as the game starts . This works fine with keyboard and mouse inputs (administrator run) but I can't find a solution if I use the joypad. I would like to enable or disable the joystick buttons. How can I do ?

 

Thanks

Link to comment
Share on other sites

37 minutes ago, Sbaby said:

I found a solution by entering script  "BlockInput, On" while loading, and "BlockInput, Off"  as soon as the game starts

You might be able to, in between those "blocks", assign some do-nothing hotkeys for the joy buttons.  I don't know how you set the 'blocks', probably something along the lines of  while game_not_started_yet, BlockInput, On..... then add your joy buttons...  Joy1::Return   Joy2::Return.... etc.

Then [hopefully] those hotkey assignments only do-nothing 'while loading'.

Link to comment
Share on other sites

8 ore fa, JoeViking245 ha detto:

Potresti essere in grado, tra quei "blocchi", di assegnare alcuni tasti di scelta rapida per non fare nulla per i pulsanti Joy. Non so come hai impostato i 'blocchi', probabilmente qualcosa sulla falsariga di while game_not_started_yet, BlockInput, On..... quindi aggiungi i tuoi pulsanti Joy... Joy1::Return Joy2::Return.... eccetera.

Quindi [si spera] quelle assegnazioni di tasti di scelta rapida non fanno nulla "durante il caricamento".

In questo video le cose funzionano bene ma a volte capita che continuo a sentire la musica del bigbox in sottofondo e quindi anche gli ingressi vengono intercettati dal bigbox durante il caricamento del gioco

Quando ciò accade i problemi sono:

1) Il comando blockinput non funziona se non avvio lo script in modalità amministratore, ma allo stesso tempo se lo avvio come amministratore si verificano altri problemi con steam

2) Non so inserire i comandi del joypad alternativi per il blocco in quanto li ho già inseriti per la scelta degli account

 

 

image.png.ac2095bad8bcf023094c3d45394924f4.png

 

Nota: le rom di vapore sono file di testo falsi senza estensione che hanno come nome il numero di codice di Steam, ad esempio Tekken 7 : 389730

image.thumb.png.297608ee1488e0f5a4d45b05c4b876a4.png

 

Emulatore:  https://github.com/TcNobo/TcNo-Acc-Switcher

image.thumb.png.3b40634c6a834792a50cdf69acafb3e5.png

 

 

Script ahk :

 

 

 

SbabySteamLauncher.ahk

Edited by Sbaby
Link to comment
Share on other sites

looks like you already tried what I would have suggested, using context hotkeys with something like #IfWinExist. I'm surprised that wouldn't get the job done.  But I would use #IfWinNotExist and the context would be a WinTitle format of the game, you couldn't use ahk_exe gameoverlayui.exe since it creates no window! The hotkeys being linked to nothing would do nothing during the boot, and once the game window appears the context hotkey is now invalid and the joypad sends inputs as intended.

 

Not seeing anything super obvious right away. Using this method works for me, so should for you too then...right? I used different keys since I don't have a dinput joypad but worked fine using keyboard keys. I tested with Notepad and the game Streets of Rage 4, having those context sensitive hotkeys only enable if those windows existed. That splashimage should work, but why doesn't it work already? Does "MySplash" close when "Splash2" opens? If so, I think that's your problem....

 

Looks closer.........BINGO....I think it does... here on line 53! Wouldn't this make those context sensitive hotkey invalid as soon as this line runs?

SplashImage,1:off

 

Edited by skizzosjt
Link to comment
Share on other sites

12 hours ago, skizzosjt said:

looks like you already tried what I would have suggested, using context hotkeys with something like #IfWinExist. I'm surprised that wouldn't get the job done.  But I would use #IfWinNotExist and the context would be a WinTitle format of the game, you couldn't use ahk_exe gameoverlayui.exe since it creates no window! The hotkeys being linked to nothing would do nothing during the boot, and once the game window appears the context hotkey is now invalid and the joypad sends inputs as intended.

FYI you got your account #'s in there. Not that I think this is the place nefarious ppl troll looking for Steam accounts to steal but just sayin'

 

Not seeing anything super obvious right away. Using this method works for me, so should for you too then...right? I used different keys since I don't have a dinput joypad but worked fine using keyboard keys. I tested with Notepad and the game Streets of Rage 4, having those context sensitive hotkeys only enable if those windows existed. That splashimage should work, but why doesn't it work already? Does "MySplash" close when "Splash2" opens? If so, I think that's your problem....

 

Looks closer.........BINGO....I think it does... here on line 53! Wouldn't this make those context sensitive hotkey invalid as soon as this line runs?

SplashImage,1:off

 

ok thanks but that line serves otherwise the situation gets worse because it allows you to make the same choice several times.

My problem is that the script works but during loading game the inputs are intercepted below in the bigbox menu, bigbox does not minimize, it stays under the image but should actually be minimized

Link to comment
Share on other sites

3 hours ago, Sbaby said:

ok thanks but that line serves otherwise the situation gets worse because it allows you to make the same choice several times.

My problem is that the script works but during loading game the inputs are intercepted below in the bigbox menu, bigbox does not minimize, it stays under the image but should actually be minimized

OK so all that confirms the script is doing what you told it to do then. You tied the context sensitive hotkeys to a window (MySplash) that shows up for a moment and then is "destroyed" just a few lines later when  "Splashimage,1,off " is ran. The only time those "do nothing hotkeys" will work as you intend them to is between creating them and the time it takes Splash2 window to appear, which is before any game is launching, hence why you're inputs are still being detected while the game boots. That Splashimage off command destroys the window which the context sensitive hotkeys that are supposed to be blocking joypad inputs are dependent on. So they will not work anymore, meaning your inputs WILL be detected. This comes down to needing to design the script structure better so it suits your needs. There are options to get it done. A couple being the context sensitive hotkeys need to be tied to another window that exists during the whole duration you're are trying to block inputs. Or you could leave the current MySpalsh window existing for a longer period of time. Or you can tie them to the current MySplash window as you currently are but when MySplash is destroyed, create the hotkeys again but tie them in context to "Splash2" window existing, etc. You will have to experiment to see what method works best for you, I'm sure there are other ways to achieve the goal beyond what I just mentioned also.

 

To clarify, I wasn't saying you need to remove that line, I was pointing out I think that it is the main culprit of why the do nothing hotkeys aren't working as you intended. Which you have confirmed this is the case. It's the culprit, how you go about fixing it will be up to you but now you know why it's doing what it's doing.

 

image.thumb.png.ff6e793500e86c3503ec735252f24bf5.png

Link to comment
Share on other sites

On 9/22/2022 at 6:21 PM, skizzosjt said:

OK so all that confirms the script is doing what you told it to do then. You tied the context sensitive hotkeys to a window (MySplash) that shows up for a moment and then is "destroyed" just a few lines later when  "Splashimage,1,off " is ran. The only time those "do nothing hotkeys" will work as you intend them to is between creating them and the time it takes Splash2 window to appear, which is before any game is launching, hence why you're inputs are still being detected while the game boots. That Splashimage off command destroys the window which the context sensitive hotkeys that are supposed to be blocking joypad inputs are dependent on. So they will not work anymore, meaning your inputs WILL be detected. This comes down to needing to design the script structure better so it suits your needs. There are options to get it done. A couple being the context sensitive hotkeys need to be tied to another window that exists during the whole duration you're are trying to block inputs. Or you could leave the current MySpalsh window existing for a longer period of time. Or you can tie them to the current MySplash window as you currently are but when MySplash is destroyed, create the hotkeys again but tie them in context to "Splash2" window existing, etc. You will have to experiment to see what method works best for you, I'm sure there are other ways to achieve the goal beyond what I just mentioned also.

 

To clarify, I wasn't saying you need to remove that line, I was pointing out I think that it is the main culprit of why the do nothing hotkeys aren't working as you intended. Which you have confirmed this is the case. It's the culprit, how you go about fixing it will be up to you but now you know why it's doing what it's doing.

 

image.thumb.png.ff6e793500e86c3503ec735252f24bf5.png

I tried to invent solutions you suggested but I can't, I think I'm not capable, I need help on the structure, I'm not a programmer

Link to comment
Share on other sites

On 9/22/2022 at 8:23 AM, Sbaby said:

bigbox does not minimize, it stays under the image but should actually be minimized

your post helped me figure out something new here. hope this helps you too! I've tried minimizing Big Box in the past, out of pure curiosity reasons, and I never was successful. Even Windows built in function like Win + M which minimizes every window that exists doesn't do it. That just removes focus from Big Box, but it's still always visible. However, after seeing you were using WinMinimize I thought to myself "no way those commands work" and tried it to see what happens.....and it worked in my scenario! my first scenario......not all scenarios are created equal! I assigned it "WinMinimize ahk_exe BigBox.exe" to a hotkey and it works.......if you are just navigating through Big Box, (options, platforms, games, etc.) It only takes one line, no need to duplicate them either. It does NOT work during the startup sequence when the startup themes are displayed! You see a quick flash back and forth between Big Box and the startup theme when I try it at those points so Big Box doesn't minimize at this point of use.

 

So I don't think it is possible to minimize Big Box during the startup. This is a catch 22.....if startup themes are enabled, the very moment you click play the startup theme sequence will begin. So I found it isn't possible to even use an additional app script with this command telling it to launch prior to the main app. Basically you need to not use startup themes if you wanted to minimize Big Box. If you don't use startup themes the command WinMinimize works whether it is included in your main script or an additional app script. That will work for you. Tried an experiment also with using ControlSend to send keys to Big Box when it was minimized and it kinda, sorta, sometimes, worked. Seems like Big Box is "suspended" when minimized, evident that all videos stop playing...or err....usually stop playing. But, this plan of mine worked when I could still hear the videos playing when Big Box was minimized....I don't know why sometimes this happens as it seems somewhat related to if other windows are open and if I click the mouse or alt+tab prior to using the hotkey....I'm not finding the exact pattern to make that work with any sort of real consistency

 

1 hour ago, Sbaby said:

I tried to invent solutions you suggested but I can't, I think I'm not capable, I need help on the structure, I'm not a programmer

You're not a programmer? Welcome to the club, population you and myself lol! it's ok to not get it right away, I sure don't always get things immediately. The best thing I can recommend is you should try working on LITTLE BITS of script at a time to fully understand how they work, THEN start piecing stuff together to make the whole script. In this example you should be playing around with context sensitive hotkeys, then once you have your "eureka moment" you can start using your newly gained knowledge to add it into bigger scripts like the launcher you made.

But here's what you could try specifically. Try declaring them a 2nd time with the 2nd/newer window, like this for ex. This was suggestion #3. Since you're destroying  MySplash with line "SplashImage,1:off" it invalidates your context sensitive hotkeys. One of the ways to keep the do nothing hotkeys doing nothing is to then create them again but tied to another window that exists. The 2nd popup you're making is called Splash2, so use that in the same exact way as you did MySplash

Spoiler
#IfWinExist MySplash
   {
   1Joy3::
   2Joy3::
   $1::
   $v::
    {
SoundBeep, 600, 100
BlockInput On
Sleep, 120
SoundPlay, Audio\1_account1scelto.mp3
MouseMove, 1920, 1080
SplashImage,2:%Image2%,b %Options%,,,Splash2
WinMove, Splash2,,0,0, %A_ScreenWidth%, %A_ScreenHeight%
WinWait, Splash2
#IfWinExist Splash2
   {
   1Joy3::
   2Joy3::
   $1::
   $v::
    {
SplashImage,1:off

 

I do not think you need all those extra braces { btw. The context sensitive lines #If-blahblah work as such any hotkeys that are declared after those lines run, the hotkeys are tied to the context sensitive line until the script exits or if  there is another context sensitive line ran, which is what were doing here. Because normally you cannot declare the same hotkey more than once in a script otherwise! (how would AHK to know which hotkey to run if that was the case? that is when you get the error "Error: Duplicate Hotkey" when attempting to run a bad script like that) For example, this below works fine. If I had notepad open, or this exact webpage I'm typing on now because its title is "Auto Hokey Scripts" has "Hotkey" in the name, it makes all those keys do nothing. If I close my internet browser, they still do nothing because notepad is open. So now if I close notepad also, both windows are now closed, and now the keys j, k, and l will type out as normal. Trialing stuff in a small scale like this is how I learn, so it's why I recommend you give it a shot too. Everyone learns at their own pace and their own methods, but it's how I learn new stuff about the AHK language. I gotta understand the small bits before I go stuffing them into a several hundred line script

 

Spoiler
SetTitleMatchMode, 2
#IfWinExist, Notepad
j::
k::
l::

#IfWinExist, Hotkey
j::
k::
l::

;Launching Game stuff
Return

 

edit: might have worded the above wrong. for example, if I made the first j hotkey type 7 instead, and the 2nd j hotkey type 8 instead. when both windows (my browser and notepad) are open AHK defaults to executing the first hotkey that would be ran. which makes sense. this means I would type 7 if hitting j and both notepad and browser are open. if I close browser, 7 will still type out from the j key. but if I close notepad instead and the browser is still open, now j will type out 8. so in this case when we're using multiple windows for the same context sensitive hotkey, which ever one is activated first in the scripts auto execution sequence will run. for ones to run below it, the first one would need to be invalidated by closing the context window

 

Edited by skizzosjt
Link to comment
Share on other sites

2 hours ago, skizzosjt said:

 

  Hide contents
#IfWinExist MySplash
   {
   1Joy3::
   2Joy3::
   $1::
   $v::
    {
SoundBeep, 600, 100
BlockInput On
Sleep, 120
SoundPlay, Audio\1_account1scelto.mp3
MouseMove, 1920, 1080
SplashImage,2:%Image2%,b %Options%,,,Splash2
WinMove, Splash2,,0,0, %A_ScreenWidth%, %A_ScreenHeight%
WinWait, Splash2
#IfWinExist Splash2
   {
   1Joy3::
   2Joy3::
   $1::
   $v::
    {
SplashImage,1:off

 

👆this doesn't work for me

I have found an unclean solution, but it works

the cause is the lack of minimization of BB, so I use a second script that starts with administrator privileges and makes BB (or LB) minimize.
This allows you to press any key on the joypad after the principal choice and nothing happens underneath or above.

I also added a script that I already used for the mame, which for safety silences BB during the execution of the script and turns on again at the end of the script (when steam closes).

It seems to me that everything works, now I accept tips to make everything cleaner, for example I would also like to insert the BLOCKINPUT ON and BLOCKINPUT OFF  (for the keyboard) as administrator in the second script but I don't know how to do it for activate it and deactivate it at the right times, I tried with the usual #IFWINEXIST but not works.

In any case, for the moment this is working as I keep a clean desktop and being BB minimized any key or joypad pressure does not give interceptions

 

image.png.22b3312ca7c3bf91f35d0bf6fc760f87.png

-------------------------------

This is BoxMin.ahk 👇

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

if not A_IsAdmin
    Run *RunAs "%A_ScriptFullPath%"

Sleep 3000
WinMinimize, ahk_exe BigBox.exe,
WinMinimize, ahk_exe LaunchBox.exe,

run, "M:\Giochi\Utility\Launchbox\ThirdParty\SoundVolumeView\SoundVolumeView.exe" /Mute LaunchBox
run, "M:\Giochi\Utility\Launchbox\ThirdParty\SoundVolumeView\SoundVolumeView.exe" /Mute BigBox

WinMinimize, ahk_exe BigBox.exe,
WinMinimize, ahk_exe LaunchBox.exe,

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

 

 

These are the changes to SbabySteamLauncher.ahk 👇

 

;*************************Enter TcNo-Acc-Switcher Parameters*************************


TcNoPath = M:\Giochi\Utility\TcNo-Acc-Switcher
TcNoAccount1ID = 00000000000000000
TcNoAccount2ID = 00000000000000000

;******************************************************************************************************


#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.
StringSplit, ScriptNameArray, A_ScriptName,.

#SingleInstance force

Image = Themes\Image_start.png
Image2 = Themes\Image_account1.png
Image3 = Themes\Image_account2.png
Image4 = Themes\Image_exit.png
Emulator = "%TcNoPath%\TcNo-Acc-Switcher.exe"
Options = Zw%A_ScreenWidth% Zh%A_ScreenHeight%
;Options = Zw1920 Zh1080

Run, BoxMin.ahk

SoundPlay, Audio\0_failatuascelta.mp3
SplashImage,1:%Image%,b %Options%,,,MySplash
WinMove, MySplash,,0,0, %A_ScreenWidth%, %A_ScreenHeight%
MouseMove, 1920, 1080

#IfWinExist MySplash
   {
   1Joy3::
   2Joy3::
   $1::
   $v::
    {
SoundBeep, 600, 100
BlockInput On
Sleep, 120
SoundPlay, Audio\1_account1scelto.mp3
MouseMove, 1920, 1080
SplashImage,2:%Image2%,b %Options%,,,Splash2
WinMove, Splash2,,0,0, %A_ScreenWidth%, %A_ScreenHeight%
WinWait, Splash2
SplashImage,1:off
SetTimer, Image2, on,
RunWait, %Emulator% +s:%TcNoAccount1ID% +open steam://rungameid/%1%
Process, Wait, gameoverlayui.exe
Sleep, 1500
SoundPlay, Audio\4_giocoavviato.mp3
BlockInput Off
Process, WaitClose, gameoverlayui.exe
SoundPlay, Audio\5_uscitadalgioco.mp3
BlockInput On
Run, "C:\Program Files (x86)\Steam\steam.exe" -shutdown
sleep 50
    Gosub, Exit
   }

   1Joy4::
   2Joy4::
   $2::
   $b::
   {
SoundBeep, 600, 100
BlockInput On
Sleep, 120
SoundPlay, Audio\2_account2scelto.mp3
MouseMove, 1920, 1080
SplashImage,3:%Image3%,b %Options%,,,Splash3
WinMove, Splash3,,0,0, %A_ScreenWidth%, %A_ScreenHeight%
WinWait, Splash3
SplashImage,1:off
SetTimer, Image3, on,
RunWait, %Emulator% +s:%TcNoAccount2ID% +open steam://rungameid/%1%
Process, Wait, gameoverlayui.exe
Sleep, 1500
SoundPlay, Audio\4_giocoavviato.mp3
BlockInput Off
Process, WaitClose, gameoverlayui.exe
SoundPlay, Audio\5_uscitadalgioco.mp3
BlockInput On
Run, "C:\Program Files (x86)\Steam\steam.exe" -shutdown
sleep 50
    Gosub, Exit
   }

   1Joy2::
   2Joy2::
   $Esc::
   {
     SplashImage, 1:off
    SoundBeep, 600, 100
     Gosub, Exit2
   }
}
 
Exit:
SplashImage,4:%Image4%,b %Options%,,,Splash4
WinMove, Splash4,,0,0, %A_ScreenWidth%, %A_ScreenHeight%
WinWait, Splash4
Process, Wait, steam.exe
Process, WaitClose, steam.exe
WinActivate, ahk_exe LaunchBox.exe,
WinMaximize, ahk_exe LaunchBox.exe,
WinActivate, ahk_exe BigBox.exe, 
WinMaximize, ahk_exe BigBox.exe,
run, "M:\Giochi\Utility\Launchbox\ThirdParty\SoundVolumeView\SoundVolumeView.exe" /UnMute BigBox
run, "M:\Giochi\Utility\Launchbox\ThirdParty\SoundVolumeView\SoundVolumeView.exe" /UnMute LaunchBox
BlockInput Off
ExitApp


Exit2:
SplashImage,4:%Image4%,b %Options%,,,Splash4
WinMove, Splash4,,0,0, %A_ScreenWidth%, %A_ScreenHeight%
WinWait, Splash4
WinActivate, ahk_exe LaunchBox.exe,
WinMaximize, ahk_exe LaunchBox.exe,
WinActivate, ahk_exe BigBox.exe, 
WinMaximize, ahk_exe BigBox.exe,
run, "M:\Giochi\Utility\Launchbox\ThirdParty\SoundVolumeView\SoundVolumeView.exe" /UnMute BigBox
run, "M:\Giochi\Utility\Launchbox\ThirdParty\SoundVolumeView\SoundVolumeView.exe" /UnMute LaunchBox
ExitApp


Image2:
Sleep, 9000
SplashImage, 2:off
SetTimer, Image2, off,
return

Image3:
Sleep, 9000
SplashImage, 3:off
SetTimer, Image3, off,
return

Image4:
Sleep, 5000
SplashImage, 4:off
SetTimer, Image4, off,
return

 

Link to comment
Share on other sites

hmm what I tested does "work" (it works, but not really how we would want it to, explained throughout this post). Irregardless, it sounds like you have gone some other route to achieve the goal....good!

 

but I now see a few problems with that method we have been talking about, and it's a good learning experience. first off, you gotta understand what hotkeys do and how they operate. they execute the code on the same line they are on, OR, if nothing is on the same line, everything below it until something that would stop the thread, like a return or exit, goto, gosub etc. So look at your script closer, each time you would click one of those buttons you would literally be re-executing your script. An example I made to prove this theory
 

Spoiler

 

SetTitleMatchMode, 2
#IfWinExist Notepad
{

j::1
k::
l::

SoundBeep

#IfWinExist Hotkey
{
j::4
k::5
l::6
Return
}
;Launching Game stuff
Return
}

 

if I hit key j it will type out 1 as expected. but if I type out k, since no code is on the same line it executes below and goes to the next hotkey, l, which is doing the same thing with nothing on the same line, so it keeps executing lines up to it would one of the several commands (not sure if command is the right term) such as return tells it to stop. in this ex it stops once it gets to a hotkey with code on the same line, this being the 2nd instance of j. this means if I hit k....sure it does "nothing"......except start executing the rest of the fucking script! that's obviously not "nothing"! hitting k I can hear the soundbeep, and it goes into the next j hotkey that types out 4 instead. meaning despite declaring k first with nothing, hitting k will actually type out 4 in this example script. so this is a pretty flawed method to achieve the goal

 

It would be better to put some actual commands there that pertain to doing nothing. For example, tell the hotkeys to minimize a window that doesn't actually exist. This would work better then the first handful of suggestions. Use a WinTitle that is "fake".

Spoiler

 

SetTitleMatchMode, 2
#IfWinExist Notepad
{

j::WinMinimize, doesn't exist
k::WinMinimize, doesn't exist
l::WinMinimize, doesn't exist

SoundBeep

#IfWinExist Hotkey
{
j::WinMinimize, doesn't exist
k::WinMinimize, doesn't exist
l::WinMinimize, doesn't exist
Return
}
;Launching Game stuff
Return
}

I didn't see the problem with keeping them blank right away because the test script I made was just a test, it had no other code in it to run....but as I looked it over again it dawned on me this approach is problematic.  So that's how I ended up trying this other test with phony commands on the same line as the hotkey instead of leaving the hotkeys blank. But now as I stare at this test.....still will not work for your use case. if you hit one of those phony hotkeys it will bring the script to that line and stop at the next....stopping execution of your script. which obviously is not desired. I say at this point, this whole idea needs to be abandoned.  if we thought better about this, likely woulda saved wasting time trying this lol oh well that's all part of the learning experience

Link to comment
Share on other sites

25 minutes ago, skizzosjt said:

hmm what I tested does "work" (it works, but not really how we would want it to, explained throughout this post). Irregardless, it sounds like you have gone some other route to achieve the goal....good!

 

but I now see a few problems with that method we have been talking about, and it's a good learning experience. first off, you gotta understand what hotkeys do and how they operate. they execute the code on the same line they are on, OR, if nothing is on the same line, everything below it until something that would stop the thread, like a return or exit, goto, gosub etc. So look at your script closer, each time you would click one of those buttons you would literally be re-executing your script. An example I made to prove this theory
 

  Reveal hidden contents

 

SetTitleMatchMode, 2
#IfWinExist Notepad
{

j::1
k::
l::

SoundBeep

#IfWinExist Hotkey
{
j::4
k::5
l::6
Return
}
;Launching Game stuff
Return
}

 

if I hit key j it will type out 1 as expected. but if I type out k, since no code is on the same line it executes below and goes to the next hotkey, l, which is doing the same thing with nothing on the same line, so it keeps executing lines up to it would one of the several commands (not sure if command is the right term) such as return tells it to stop. in this ex it stops once it gets to a hotkey with code on the same line, this being the 2nd instance of j. this means if I hit k....sure it does "nothing"......except start executing the rest of the fucking script! that's obviously not "nothing"! hitting k I can hear the soundbeep, and it goes into the next j hotkey that types out 4 instead. meaning despite declaring k first with nothing, hitting k will actually type out 4 in this example script. so this is a pretty flawed method to achieve the goal

 

It would be better to put some actual commands there that pertain to doing nothing. For example, tell the hotkeys to minimize a window that doesn't actually exist. This would work better then the first handful of suggestions. Use a WinTitle that is "fake".

  Reveal hidden contents

 

SetTitleMatchMode, 2
#IfWinExist Notepad
{

j::WinMinimize, doesn't exist
k::WinMinimize, doesn't exist
l::WinMinimize, doesn't exist

SoundBeep

#IfWinExist Hotkey
{
j::WinMinimize, doesn't exist
k::WinMinimize, doesn't exist
l::WinMinimize, doesn't exist
Return
}
;Launching Game stuff
Return
}

I didn't see the problem with keeping them blank right away because the test script I made was just a test, it had no other code in it to run....but as I looked it over again it dawned on me this approach is problematic.  So that's how I ended up trying this other test with phony commands on the same line as the hotkey instead of leaving the hotkeys blank. But now as I stare at this test.....still will not work for your use case. if you hit one of those phony hotkeys it will bring the script to that line and stop at the next....stopping execution of your script. which obviously is not desired. I say at this point, this whole idea needs to be abandoned.  if we thought better about this, likely woulda saved wasting time trying this lol oh well that's all part of the learning experience


should i enter all the keys and all buttons? I do not want to .

have you tried my latest method? I also enter 30 times the same input but it runs only one game and everything goes perfectly

Keeping bigbox minimized solves all the problems, I was just wondering if there was another method other than the one I found which involves using two scripts. But it works!

Link to comment
Share on other sites

9 minutes ago, skizzosjt said:

I didn't see the problem with keeping them blank right away because the test script I made was just a test, it had no other code in it to run....but as I looked it over again it dawned on me this approach is problematic. 

When you place subsequent "blank" hotkeys, they'll all get assigned to command(s) that follow.  Hotkey assignments should also be 'terminated' with a Return. 

j::
K::
l::
Soundbeep
return

b::
n::
m::
send joe was here
return

Here, j, k and l are all assigned to "Soundbeep".  b, n and m will all type out "joe was here".

 

j::
K::
l::Return
Soundbeep
return

Here, j, k and l are all assigned to Return.  Soundbeep and the last return will never do anything.

 

SetTitleMatchMode, 2
#IfWinExist Notepad
{
  j::Return
  K::
  l::
  Soundbeep
  Send joe was here
  return
}

Here, ONLY if Notepad is running, j does nothing. k and l will both sound a beep and also type out "joe was here.  

 

Hopefully that helps makes the mud more clear. :) 

Link to comment
Share on other sites

3 hours ago, Sbaby said:

should i enter all the keys and all buttons? I do not want to .

NO!!! that was all explaining that the idea of using phony do nothing hotkeys is NOT going to work for what you want to achieve, which is blocking inputs while still executing the rest of your script.....as I say that.......I bet you could simply launch a separate script like you did with the BoxMin one! If you used the concept I went off by placing phony WinMinimize lines, JOE makes a much better point below to use a RETURN instead.....despite me knowing exactly what return does my mind didn't get to that conclusion lol. You could in your steam launcher script put in a line to run a separate new script, I'll refer to as "BlockInputScript" for now. In BlockInputScript you can place bunch of hotkeys with return on them. One of your buttons for ex: "1Joy3::Return" would force it to do nothing. You would want BlockInputScript to launch in your steam launcher script whenever you want the blocking inputs to start, and you can in the steam launcher script tell BlockInputScript to terminate when you want the inputs to stop being blocked. This allows your steam launcher script to continue executing as it normally does, while allowing the fake do nothing hotkeys to work as intended

So my last posts were pointing out these work when isolated in my test scripts but it's going to screw up the flow of execution when integrated with your script. Thankfully from you mentioning the new idea you had to make a separate script to minimize BB, you provided the idea to do the same thing to get blocking inputs to work. having multiple separate scripts run simultaneously creates a pseudo muti-threaded execution of AHK, that meaning they can operate independently of each other. I think you just helped yourself and didn't even know it lol. You wouldn't even need to use any context sensitive lines in BlockInputScript. This will suffice. I just tested this in with bigger scripts of mine (with different keys obviously, I've been using j, k l) and it works as I expected it to.

 

PUT THIS IN SOME SEPARATE SCRIPT LIKE "BLOCKINPUTSCRIPT"

1Joy3::Return
2Joy3::Return
$1::Return
$v::Return

 

THIS IS A MOCK UP OF YOUR STEAM LAUNCHER SCRIPT

CODE HERE BLAH BLAH
;NO INPUT BLOCKING YET

Run, BLOCKINPUTSCRIPT.AHK
;JOYPAD BUTTONS ARE NOW BLOCKED

MORE STEAM LAUNCHING CODE BLAH BLAH

;BLOCKINPUTSCRIPT IS TERMINATED WITH THIS METHOD TO ALLOW INPUTS TO WORK
DetectHiddenWindows, on
SetTitleMatchMode, 2
WinClose, BLOCKINPUTSCRIPT

between your and joe's feedback I think this is finally a solution that will work for your use case, rather than only work as an isolated test.

  

3 hours ago, Sbaby said:

have you tried my latest method? I also enter 30 times the same input but it runs only one game and everything goes perfectly

Keeping bigbox minimized solves all the problems, I was just wondering if there was another method other than the one I found which involves using two scripts. But it works!

if you're happy with the outcome that's what matters. I'd personally go the route we're mentioning with blocking inputs via a separate hotkey script rather than minimizing the window but I cannot argue against a it's not broken so don't try and fix it mentality either.

but I'm wondering, why does this even matter? you're saying hitting a button during booting of a game is creating problems for you then?  because that sounds like have(/had) something funny going on, that shouldn't be creating any problems.

 

 

 

3 hours ago, JoeViking245 said:

When you place subsequent "blank" hotkeys, they'll all get assigned to command(s) that follow.  Hotkey assignments should also be 'terminated' with a Return. 

j::
K::
l::
Soundbeep
return

b::
n::
m::
send joe was here
return

Here, j, k and l are all assigned to "Soundbeep".  b, n and m will all type out "joe was here".

 

j::
K::
l::Return
Soundbeep
return

Here, j, k and l are all assigned to Return.  Soundbeep and the last return will never do anything.

 

SetTitleMatchMode, 2
#IfWinExist Notepad
{
  j::Return
  K::
  l::
  Soundbeep
  Send joe was here
  return
}

Here, ONLY if Notepad is running, j does nothing. k and l will both sound a beep and also type out "joe was here.  

 

Hopefully that helps makes the mud more clear. :) 

It does, as you've reiterated what I went through. I get tunnel vision and didn't take a moment to think through how it would interact with his script. none of this will work for what Sbaby wanted to do, despite these ideas working OK when they are isolated as test scripts, the problems arise when they are integrated in with more code.

Edited by skizzosjt
Link to comment
Share on other sites

  • 1 month later...
22 minutes ago, FRK said:

Looking for a script to exit out of Visual Pinball X

You shouldn't need a script to exit VPX.  As your Default Command-line Parameter, use 

-minimized -exit -play

image.png.102bdc2cc9719b1b4304a87854b00d9f.png

Then make sure you don't have anything in your Running Script section for the emulator.  Also check that your Application Path is pointing to the correct vpinballx.exe in case you have another install.

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