Jump to content
LaunchBox Community Forums

Auto Hotkey Scripts


Lordmonkus

Recommended Posts

5 hours ago, JoeViking245 said:

Ok.  At first you just said it wasn't working.  Now that we know what's not working about it... 

Open the emulator and go into its settings and check the box "Pause on Focus Loss".

image.png.b8a8e1ad4ffe746fbfde1d43ff4b9766.png

Thank you for the suggestion . Perfect I solved it . 

Link to comment
Share on other sites

Hello, I'm using the following AHK code to launch a game from my streamdeck:

run, "G:\Launchbox\Emulators\Retroarch\retroarch.exe" -f -L "G:\Launchbox\Emulators\Retroarch\cores\mame_libretro.dll" "G:\Launchbox\Games\MAME\roms\robotron.zip"

it works but now I want the games artwork to be displayed on my pixelcade LCD marquee and pixelcade LED marquee on my arcade.

I'm sure I need to launch the game from LB/BB, is this possible?

Link to comment
Share on other sites

  • 1 month later...
On 9/15/2022 at 2:34 AM, JoeViking245 said:

 

Have fun. :D     ToggleAllLibrary.ahk.txt  (be sure to remove ".txt" if/when you go to use it.)

 

Hi @JoeViking245 after more than a year I can tell you that your script is still great, I use it all the time with Bigbox. :)
I wanted to ask you if it's possible to insert a custom mouse cursor (I need it in a few steps during weapon loading where for a few seconds the mouse arrow is shown) and then restore of course the windows cursor when closing.

And then disable the screensaver, this is because during attract mode the screensaver starts, I thought there was an option to disable it but if not maybe it would be nice to include it in your script

thank you very much in advance for your possible reply 🙏

Link to comment
Share on other sites

14 hours ago, Sbaby said:

Hi @JoeViking245 after more than a year I can tell you that your script is still great, I use it all the time with Bigbox. :)

Thanks! :) 

 

14 hours ago, Sbaby said:

I wanted to ask you if it's possible to insert a custom mouse cursor (I need it in a few steps during weapon loading where for a few seconds the mouse arrow is shown) and then restore of course the windows cursor when closing.

Not personally tested, but this looks like it should work.  You'll need to have the custom cursor file and edit the 1st line to point to it.

https://www.autohotkey.com/boards/viewtopic.php?p=356126&sid=6cea5e7a2d7eb46ec819002b2927457f#p356126

 

14 hours ago, Sbaby said:

And then disable the screensaver, this is because during attract mode the screensaver starts, I thought there was an option to disable it but if not maybe it would be nice to include it in your script

I haven't used a screen saver since the early 90's. lol

The easiest way is probably to change the registry value directly.

;Disable screen saver
RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\desktop, ScreenSaveActive, 0

;Enable screen saver
RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\desktop, ScreenSaveActive, 1

 

Link to comment
Share on other sites

3 hours ago, JoeViking245 said:

Not personally tested, but this looks like it should work.  You'll need to have the custom cursor file and edit the 1st line to point to it.

https://www.autohotkey.com/boards/viewtopic.php?p=356126&sid=6cea5e7a2d7eb46ec819002b2927457f#p356126

The crosshair/cursor works fine but I have not understood how I can put it in the context of our file, I would like to avoid pressing the F3 and F4 buttons but simply have it activated when starting the file and deactivated when closing it. I have tried but I am not sure if I am using the brackets correctly

 

3 hours ago, JoeViking245 said:

The easiest way is probably to change the registry value directly.

;Disable screen saver
RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\desktop, ScreenSaveActive, 0

;Enable screen saver
RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\desktop, ScreenSaveActive, 1

 

This screensaver script only worked the first time, all subsequent times it no longer works for me, not even using it as administrator, do you have any suggestions ?

Edited by Sbaby
Link to comment
Share on other sites

13 minutes ago, Sbaby said:

The crosshair/cursor works fine but I have not understood how I can put it in the context of our file, I would like to avoid pressing the F3 and F4 buttons but simply have it activated when starting the file and deactivated when closing it. I have tried but I am not sure if I am using the brackets correctly

The file = [pathToCursorFile] variable would go near the top of the script with any other variable declarations (and before any hotkey assignments).

The 2 functions ( SetSystemCursor(file) and RestoreCursors() ) would go at the bottom of the script (below any hotkeys and subroutines).

Then inside the method (or function or subroutine) that 'starts the file', add in the single line SetSystemCursor(file) (removing the F3 hotkey assignment).

Likewise, wherever the file gets 'closed', add in RestoreCursors() (removing the F4 hotkey assignment).

 

25 minutes ago, Sbaby said:

This screensaver script only worked the first time, all subsequent times it no longer works for me, not even using it as administrator, do you have any suggestions ?

Sorry. I don't.  I ran the 2 RegWrite lines back-and-forth several times.  In between, checking the registry (HKCU\Control Panel\Desktop\ScreenSaveActive) to verify that it changed.  And it had.  (note: when looking at the registry, you'll need to click a different folder, then click back to the 'Desktop' folder to see the change)

Link to comment
Share on other sites

2 hours ago, JoeViking245 said:

The file = [pathToCursorFile] variable would go near the top of the script with any other variable declarations (and before any hotkey assignments).

The 2 functions ( SetSystemCursor(file) and RestoreCursors() ) would go at the bottom of the script (below any hotkeys and subroutines).

Then inside the method (or function or subroutine) that 'starts the file', add in the single line SetSystemCursor(file) (removing the F3 hotkey assignment).

Likewise, wherever the file gets 'closed', add in RestoreCursors() (removing the F4 hotkey assignment).

For crosshair/cursor:
I have tried a few methods, and I have found a method that works although not exactly as you described it, can you confirm that it is correct? It seems to work correctly but I would like to have more certainty from you, I attach the file here

 

2 hours ago, JoeViking245 said:

Sorry. I don't.  I ran the 2 RegWrite lines back-and-forth several times.  In between, checking the registry (HKCU\Control Panel\Desktop\ScreenSaveActive) to verify that it changed.  And it had.  (note: when looking at the registry, you'll need to click a different folder, then click back to the 'Desktop' folder to see the change)

For Screensaver
It works perfectly, thank you

 

Bigbox_with_desktop_features.ahk

 

 

Edited by Sbaby
Link to comment
Share on other sites

40 minutes ago, Sbaby said:

For crosshair/cursor:
I have tried a few methods, and I have found a method that works although not exactly as you described it, can you confirm that it is correct? It seems to work correctly but I would like to have more certainty from you

That's quite elegant.  I'd never thought to put 2 methods onto one line.  TBH, I didn't know you could [and just separate them with a comma].  Today is a good day as I learned something new.  :D  Thanks for this!

; To hide blah, blah, blah and set custom cursor
ToggleEverything := HideDesktop(), SetSystemCursor(file)
 
;*** VS ***
 
; To hide blah, blah, blah
ToggleEverything := HideDesktop()
 
; Set custom cursor
SetSystemCursor(file)

 

 

59 minutes ago, Sbaby said:

For Screensaver
It works perfectly, thank you

Out of curiosity, what did you do differenly to make it work?

Link to comment
Share on other sites

40 minutes ago, JoeViking245 said:

That's quite elegant.  I'd never thought to put 2 methods onto one line.  TBH, I didn't know you could [and just separate them with a comma].  Today is a good day as I learned something new.  :D  Thanks for this!

; To hide blah, blah, blah and set custom cursor
ToggleEverything := HideDesktop(), SetSystemCursor(file)
 
;*** VS ***
 
; To hide blah, blah, blah
ToggleEverything := HideDesktop()
 
; Set custom cursor
SetSystemCursor(file)

 

😁 I'm delighted with your enthusiasm and I'm very pleased, but to be exact I made your approach similar to :

; To restore everything
    RestoreDesktop(ToggleEverything[1], ToggleEverything[2])


I had seen that you had put an additional variable after a comma although I never understood why there are two "ToggleEverything". so I simply tried adding another one and it became :

; To restore everything
    RestoreDesktop(ToggleEverything[1], ToggleEverything[2]), RestoreCursors()

 

 

 

40 minutes ago, JoeViking245 said:

Out of curiosity, what did you do differenly to make it work?

 

Actually it always worked, the thing is that I thought it disabled the screen saver from the control panel, so I kept looking at that... instead it actually forces activation by completely ignoring the Windows settings. Works even better for me, perfect 

  • Like 1
Link to comment
Share on other sites

5 minutes ago, Sbaby said:

to be exact I made your approach similar to :

; To restore everything
    RestoreDesktop(ToggleEverything[1], ToggleEverything[2])


I had seen that you had put an additional variable after a comma although I never understood why there are two "ToggleEverything". so I simply tried adding another one and it became :

; To restore everything
    RestoreDesktop(ToggleEverything[1], ToggleEverything[2]), RestoreCursors()

I think you got lucky 'simply adding another one'. ;)  But as I illuded towards, a pretty cool happenstance. 

 

Why there are two "ToggleEverything":

We set the variable ToggleEverything to equal the return value of the method HideDesktop().  So looking at what HideDesktop() does, the last thing it does is it returns 2 values.  So now ToggleEverything is holding (equal to) 2 separate values.  Making it an 'Array'.  The 1st value in the array is stored in ToggleEverything[1] and the 2nd value is in ToggleEverything[2].

Now when you look at the method RestoreDesktop, it requires that 2 parameters be sent to it.  "originalWallpaper" and "origBackground)".  So when you execute it under "To Restore Everything", you have to send with it, the 2 parameters.  Note, we place these 2 parameters inside of the methods parenthesis.  

RestoreDesktop ( ToggleEverything[1] , ToggleEverything[2] )       (added spaces and colors for clarity)

 

Now adding a comma after the last (closing) parenthesis of this method we're executing, allows us to string together multiple commands.  (so I had learned, today)

I'm not sure how far you can go with it   command_1, command_2, command_3, command_4 ...   But from a coding readability aspect, probably don't want to go too far.

Link to comment
Share on other sites

41 minutes ago, JoeViking245 said:

I think you got lucky 'simply adding another one'. ;)  But as I illuded towards, a pretty cool happenstance. 

 

😁😁😁

 

42 minutes ago, JoeViking245 said:

Why there are two "ToggleEverything":

We set the variable ToggleEverything to equal the return value of the method HideDesktop().  So looking at what HideDesktop() does, the last thing it does is it returns 2 values.  So now ToggleEverything is holding (equal to) 2 separate values.  Making it an 'Array'.  The 1st value in the array is stored in ToggleEverything[1] and the 2nd value is in ToggleEverything[2].

Now when you look at the method RestoreDesktop, it requires that 2 parameters be sent to it.  "originalWallpaper" and "origBackground)".  So when you execute it under "To Restore Everything", you have to send with it, the 2 parameters.  Note, we place these 2 parameters inside of the methods parenthesis.  

RestoreDesktop ( ToggleEverything[1] , ToggleEverything[2] )       (added spaces and colors for clarity)

 

Now adding a comma after the last (closing) parenthesis of this method we're executing, allows us to string together multiple commands.  (so I had learned, today)

I'm not sure how far you can go with it   command_1, command_2, command_3, command_4 ...   But from a coding readability aspect, probably don't want to go too far.

my brain is bursting, but I think I understand 🦾

  • Like 1
Link to comment
Share on other sites

On 10/27/2023 at 11:57 AM, artiss said:

Hello, I'm using the following AHK code to launch a game from my streamdeck:

run, "G:\Launchbox\Emulators\Retroarch\retroarch.exe" -f -L "G:\Launchbox\Emulators\Retroarch\cores\mame_libretro.dll" "G:\Launchbox\Games\MAME\roms\robotron.zip"

it works but now I want the games artwork to be displayed on my pixelcade LCD marquee and pixelcade LED marquee on my arcade.

I'm sure I need to launch the game from LB/BB, is this possible?

@artiss You can do this now using the CLI Launcher plugin. The AHK script to launch the game through LB/BB would just be a single line:

 Run, "LaunchBox\ThirdParty\CLI_Launcher\CLI_Launcher.exe" launch "<platform_name>" "<game_name>"

Edited by superrob3000
Link to comment
Share on other sites

On 12/5/2023 at 8:33 PM, d8thstar said:

just curious if anyone has ever made a doc with a glossary of all the fantastic scripts in this thread?

you could break up scripts by function (chapters in the doc), cross reference by emulator specific, etc.

just a thought

Even better, they should all be included in Launchbox for you to pick from!  Imagine the possibilities.

Glossary, chapters, cross-referenced?  Sounds like a job for a Librarian hehe.

Edited by damageinc86
Link to comment
Share on other sites

@JoeViking245

again with regard to your fantastic scriptToggleAllLibrary.ahk, I usually start it directly in this way:

; To hide Icons, taskbar, minimize all windows, set wallpaper null, set background black, set cursor
    ToggleEverything := HideDesktop()

; Master application
Runwait, "M:\Giochi\Utility\Launchbox\core\BigBox.exe"

; To restore everything
    RestoreDesktop(ToggleEverything[1], ToggleEverything[2])

ecc.etc....

 

but if I wanted to put it inside the startup application options (Bigbox Only) instead, how should I modify the script?

i tried winwait instead of runwait but it doesn't work very well

Link to comment
Share on other sites

12 hours ago, Sbaby said:

but if I wanted to put it inside the startup application options (Bigbox Only) instead, how should I modify the script?

i tried winwait instead of runwait but it doesn't work very well

Grabbed from some old notes for doing something different, but the result is what you want...

; Master application
Process, Wait, BigBox.exe
Sleep, 5000
Process, Wait, BigBox.exe
Process, WaitClose, BigBox.exe

I'm not sure when exactly when the Startup App gets triggered, so for a safety measure we wait 2 times.   The 1st Wait is for BB launched from LB's root folder.  That exe starts BigBox.exe that's in the /Core/ folder then closes itself. 

We give the 1st exe a few seconds to do its thing then Wait for /Core/BigBox.exe to be running.  Lastly, wait for it to exit before restoring things. 

 

You might be able to do away with the 1st two lines of code.  But having them in there won't hurt anything and the cost (programmatically and financially) is free. 😎

Link to comment
Share on other sites

9 hours ago, JoeViking245 said:

Grabbed from some old notes for doing something different, but the result is what you want...

; Master application
Process, Wait, BigBox.exe
Sleep, 5000
Process, Wait, BigBox.exe
Process, WaitClose, BigBox.exe

I'm not sure when exactly when the Startup App gets triggered, so for a safety measure we wait 2 times.   The 1st Wait is for BB launched from LB's root folder.  That exe starts BigBox.exe that's in the /Core/ folder then closes itself. 

We give the 1st exe a few seconds to do its thing then Wait for /Core/BigBox.exe to be running.  Lastly, wait for it to exit before restoring things. 

 

You might be able to do away with the 1st two lines of code.  But having them in there won't hurt anything and the cost (programmatically and financially) is free. 😎

it works, very nice , thank you.

 

Programmatically and financially, it was a bargain 😁

  • Game On 1
Link to comment
Share on other sites

Do you think it is possible to block bigbox input from joypad when an executable or window exists?

For example for Model 2, winclass is "MYWIN". , wintitle is "Model 2 Emulator" , the executable name is "emulator_multicpu.EXE"

My problem is that sometimes randomly, bigBox intercepts my joypad inputs while I'm playing, so I play Daytona quietly but when I exit the game I find myself in the bigbox options, or I find myself in another platform

I've tried a thousand scripts that keep BigBox forcibly minimised while running Model 2 but it still happens, randomly, i.e. most of the time it's correct, but sometimes it happens and that makes me nervous. Don't ask me what configuration I have of Model 2 because I've tried thousands of all possible combinations and on various computers, the only thing I haven't changed is Ds4Windows, maybe that's the problem, I don't know.

I know the Blockinput function with autohotkey but it only works with mouse and keyboard but I would need to block the xinput for BigBox (excluding the LaunchBox Pause Screen as in this case the input must work)

Link to comment
Share on other sites

  • 3 weeks later...

I'm new. I want to make it possible to close the ps3. RPCS3 emulator from the joystick.
I made a script. I wrote it down: Manager -> platform -> Rpcs3(edit) -> Exit script.
In the joystick settings, I programmed the keyboard shortcut to exit the game. And so I'm going to exit this particular emulator with this script?

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