JoeViking245 Posted September 6, 2022 Share Posted September 6, 2022 2 hours ago, skizzosjt said: Unfortunately on my end I have had no luck with using the method detailed in the AHK docs you're asking about. I went about it from every angle and interpretation I could think of without success. I never did get that that MsgBox to show up! No worries. Thanks for checking. 2 hours ago, skizzosjt said: but I'm not 100% if that is how controllers work In this case, the issue is not so much the controller. It's the "If(state)" line. Where "state" is, "is something on the controller activated". A button is pushed. A joystick (thumbstick?) is not at 0,0. etc. The script is running "checkForJoy:" every 10 milliseconds. When you press "A", If(state) = True, so it executes whatever is in between the { }. If you hold down "A", If(state) will = True, If(state.wButtons & 4096) will also = True, so it will 'Send k'. [In this case] there's nothing else to do inside the 'hotkey label' "checkForJoy". So nothing more happens. Until 10 milliseconds later when checkForJoy is activated again. Guess what.. If(state) equals True. So it will 'Send k'. Again. It's a vicious, never-ending cycle. Like you, I tried different Sleep timers, tried changing the SetTimer to different values (which turns out to be pretty much the same as changing the sleep timer). Looked at several other little things too. So I got creative.... There is no auto-repeat at all. So if you press and hold "A", you will not (can not) get "kkkkkkkkkkkkkkkkkkkk". You'll only get "k". But if you press A,B,X,Y super-fast, you'll get "kpde" typed out. Super-fast. Or press "B" 4 time real fast, you'll get "pppp". As fast as you press the button. Spoiler #Include Xinput.ahk #Persistent SetKeyDelay, 0, 50 SetTimer, checkForJoy1, 10 checkForJoy1: XInput_Init() state := Xinput_GetState(0) TriggerPrev= %Trigger% If(state.wButtons & 4096) ;A button Trigger=A else If(state.wButtons & 8192) ;B button Trigger=B else If(state.wButtons & 16384) ;X button Trigger=X else If(state.wButtons & 32768) ;Y button Trigger=X else If(state.wButtons & 1) ;D-Pad UP Trigger=DUp else If(state.wButtons & 2) ;D-Pad Down Trigger=DDown else If(state.wButtons & 4) ;D-Pad Left Trigger=DLeft else If(state.wButtons & 8) ;D-Pad Right Trigger=DRight else If(state.wButtons & 16) ;Start Trigger=Start else If(state.wButtons & 32) ;Back Trigger=Back else If(state.wButtons & 256) ;Left Shoulder trigger=LShoulder else If(state.wButtons & 512) ;Right Shoulder Trigger=RShoulder else If(state.bLeftTrigger > 100) ;Left Trigger (range 0 - 255) Trigger=LTrigger else If(state.bRightTrigger > 100);Right Trigger Trigger=RTrigger else If(state.wButtons & 64) ;Left Thumb Click Trigger=LThumb else If(state.wButtons & 128) ;Right Thumb Click Trigger=RThumb else if(state.sThumbLX < -9000 && state.sThumbLX > -32768) Trigger=LjoyL else if(state.sThumbLX > 9000 && state.sThumbLX < 32767) Trigger=LjoyR else if(state.sThumbLy > 9000 && state.sThumbLX < 32767) Trigger=LjoyU else if(state.sThumbLY < -9000 && state.sThumbLX > -32768) Trigger=LjoyD else if(state.sThumbRX < -9000 && state.sThumbLX > -32768) Trigger=RjoyL else if(state.sThumbRX > 9000 && state.sThumbLX < 32767) Trigger=RjoyR else if(state.sThumbRy > 9000 && state.sThumbLX < 32767) Trigger=RjoyU else if(state.sThumbRY < -9000 && state.sThumbLX > -32768) Trigger=RjoyD else Trigger= if Trigger= %TriggerPrev% ; We have not released the previous trigger return ; Do nothing. ;************************************************************** ; Change below here what you want each button/trigger to do ; ; If you don't want a button/trigger to do do anything, comment ; the 2 lines for that "trigger". ;************************************************************** if Trigger=A Send, k if Trigger=B Send, p if Trigger=X Send, d if Trigger=Y Send, e if Trigger=DUp Send, D-Pad Up if Trigger=DDown Send, D-Pad Down if Trigger=DLeft Send, D-Pad Left if Trigger=DRight Send, D-Pad Right if Trigger=Start Send, Start if Trigger=Back Send, Back if Trigger=LShoulder Send, Left Shoulder if Trigger=RShoulder Send, Right Shoulder if Trigger=LTrigger Send, Left Trigger if Trigger=RTrigger Send, Right trigger if Trigger=LThumb Send, Left Thumb Click if Trigger=RThumbRight joy moved Right Send, Right Thumb Click if Trigger=LjoyL Send, Left joy moved Left if Trigger=LjoyR Send, Left joy moved Right if Trigger=LjoyU Send, Left joy moved Up if Trigger=LjoyD Send, Left joy moved Down if Trigger=RjoyL Send, Right joy moved Left if Trigger=RjoyR Send, Right joy moved Right if Trigger=RjoyU Send, Right joy moved Up if Trigger=RjoyD Send, Right joy moved Down return The script is a bit longer, but seems to work well. 1 Quote Link to comment Share on other sites More sharing options...
LegzRwheelz Posted September 6, 2022 Share Posted September 6, 2022 I changed it a little bit more and came up with this and I am pleased: SendMode Input ;; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. eProc = explorer.exe ^!e:: keywait, e Process,Exist,%eProc% If ErrorLevel != 0 { RunWait, taskkill /f /IM %eProc%,,Hide return }else { If ErrorLevel = 0 Run, %eProc% } Return Quote Link to comment Share on other sites More sharing options...
drw4013 Posted September 7, 2022 Share Posted September 7, 2022 On 9/1/2022 at 8:04 PM, skizzosjt said: I don't see anything for the guide button in the library, so that may not be possible. To make sure we're on the same page, this is the same button to power on/off the wireless controllers? The rest is already done though! Yes, the "Xbox" button. Since it registers like any other button when testing controller properties in Win10/11 (as button 11 I believe), wouldn't there be a way to map in in this script? Quote Link to comment Share on other sites More sharing options...
LegzRwheelz Posted September 7, 2022 Share Posted September 7, 2022 (edited) 33 minutes ago, drw4013 said: Yes, the "Xbox" button. Since it registers like any other button when testing controller properties in Win10/11 (as button 11 I believe), wouldn't there be a way to map in in this script? this key is known as vk07 Check out this post. He posted a little script, here it is #IfWinNotExist, LaunchBox Big Box $vk07sc000:: aDown:=A_TickCount While GetKeyState("vk07sc000") Duration:=(A_TickCount-aDown) If (Duration<300) run "LOCATION OF BIGBOX.EXE" Else {} Return #IfWinActive, LaunchBox Big Box $vk07sc000:: aDown:=A_TickCount While GetKeyState("vk07sc000") Duration:=(A_TickCount-aDown) If (Duration<300) send, x Else {} Return Edited September 7, 2022 by CtinD 1 Quote Link to comment Share on other sites More sharing options...
skizzosjt Posted September 7, 2022 Share Posted September 7, 2022 (edited) 21 hours ago, drw4013 said: Yes, the "Xbox" button. Since it registers like any other button when testing controller properties in Win10/11 (as button 11 I believe), wouldn't there be a way to map in in this script? I've never once seen Windows 10 (I don't have 11 to test) recognize the Guide button in "Game Controllers" properties test window, but in your defense I bet it would be button 11 also since (in no particular order) A, B, X, Y, back, start, LB, RB, LThumb click, RThumb click would be 10 buttons....the next logical spot for a button like the Guide button would be #11. Now it's not that Windows 10 cannot see this button pressed at all, it works some how with the Xbox Game Bar or whatever overlay comes up when you click it, it's AHK that is being a finicky SOB about reading it. But I swear, it has never lit up button #11 or any button # at that in the Game Controllers window 20 hours ago, CtinD said: this key is known as vk07 Check out this post. He posted a little script, here it is #IfWinNotExist, LaunchBox Big Box $vk07sc000:: aDown:=A_TickCount While GetKeyState("vk07sc000") Duration:=(A_TickCount-aDown) If (Duration<300) run "LOCATION OF BIGBOX.EXE" Else {} Return #IfWinActive, LaunchBox Big Box $vk07sc000:: aDown:=A_TickCount While GetKeyState("vk07sc000") Duration:=(A_TickCount-aDown) If (Duration<300) send, x Else {} Return I got that much myself from reviewing the key history in AHK, since the Guide button is literally the only xinput button that is pseudo recognized by AHK as a key press. I had to make sure the key board hook was installed with the "#InstallKeybdHook" line for the button to even come up with that virtual key address along with it's key name always being "not found" I found more stuff too and was piecing away at it over the last week but I've not had luck with getting the Guide button to do anything. I did not have the Game Bar disabled until tonight, repeating my tests this didn't change anything though. I also am on the latest version of AHK 1.1.34.03 and frankly think shit is getting silly with how many versions I need for this very reason....as AHK continues to mature it may break old scripts. I normally fix up the old scripts to work with new AHK versions because I already got three I keep on my system, I don't want more. AHK already is trying to work its way to version 2.0 and LaunchBox includes version 1.1.24.03 so I didn't have the version that user claims is required for their script to work. I mean, this script doesn't even launch (on newer versions) due to having an invalid hotkey putting in the virtual key code like that....IDK if AHK really changed something that much between versions or what......BUT.....if you want to find that very specific version that script does seem to work......with that very specific version is the key bit to take away. Besides the fact that the #If(Not)WinExist functions are deprecated, I'm not seeing anything else as old/deprecated. So I'm not sure what else would need changing if making any changes would get the Guide button script to run on newer versions. The #In(Not)WinExist lines are not the issue , it's recent versions don't recognize that virtual key as an acceptable hotkey. Furthering my point, taking the new working scripts and trying to run them on the older version that user directed us to, doesn't run like that either. The info I found suggested you needed to further alter Xinput.ahk "library" to include additional DLL files, which I did, and also added in the Guide button to the constants. Recall I said it wasn't in there? I figured it would be as easy as identifying it and adding in these additional lines....I was wrong. It still doesn't work for me after making all the adjustments. So now the only time I can say the guide button was able to be used with AHK is that one specific AHK version, 1.0.48.05, and the accompanying script that same user shared On 9/6/2022 at 4:25 PM, JoeViking245 said: No worries. Thanks for checking. In this case, the issue is not so much the controller. It's the "If(state)" line. Where "state" is, "is something on the controller activated". A button is pushed. A joystick (thumbstick?) is not at 0,0. etc. The script is running "checkForJoy:" every 10 milliseconds. When you press "A", If(state) = True, so it executes whatever is in between the { }. If you hold down "A", If(state) will = True, If(state.wButtons & 4096) will also = True, so it will 'Send k'. [In this case] there's nothing else to do inside the 'hotkey label' "checkForJoy". So nothing more happens. Until 10 milliseconds later when checkForJoy is activated again. Guess what.. If(state) equals True. So it will 'Send k'. Again. It's a vicious, never-ending cycle. Like you, I tried different Sleep timers, tried changing the SetTimer to different values (which turns out to be pretty much the same as changing the sleep timer). Looked at several other little things too. So I got creative.... There is no auto-repeat at all. So if you press and hold "A", you will not (can not) get "kkkkkkkkkkkkkkkkkkkk". You'll only get "k". But if you press A,B,X,Y super-fast, you'll get "kpde" typed out. Super-fast. Or press "B" 4 time real fast, you'll get "pppp". As fast as you press the button. Reveal hidden contents #Include Xinput.ahk #Persistent SetKeyDelay, 0, 50 SetTimer, checkForJoy1, 10 checkForJoy1: XInput_Init() state := Xinput_GetState(0) TriggerPrev= %Trigger% If(state.wButtons & 4096) ;A button Trigger=A else If(state.wButtons & 8192) ;B button Trigger=B else If(state.wButtons & 16384) ;X button Trigger=X else If(state.wButtons & 32768) ;Y button Trigger=X else If(state.wButtons & 1) ;D-Pad UP Trigger=DUp else If(state.wButtons & 2) ;D-Pad Down Trigger=DDown else If(state.wButtons & 4) ;D-Pad Left Trigger=DLeft else If(state.wButtons & 8) ;D-Pad Right Trigger=DRight else If(state.wButtons & 16) ;Start Trigger=Start else If(state.wButtons & 32) ;Back Trigger=Back else If(state.wButtons & 256) ;Left Shoulder trigger=LShoulder else If(state.wButtons & 512) ;Right Shoulder Trigger=RShoulder else If(state.bLeftTrigger > 100) ;Left Trigger (range 0 - 255) Trigger=LTrigger else If(state.bRightTrigger > 100);Right Trigger Trigger=RTrigger else If(state.wButtons & 64) ;Left Thumb Click Trigger=LThumb else If(state.wButtons & 128) ;Right Thumb Click Trigger=RThumb else if(state.sThumbLX < -9000 && state.sThumbLX > -32768) Trigger=LjoyL else if(state.sThumbLX > 9000 && state.sThumbLX < 32767) Trigger=LjoyR else if(state.sThumbLy > 9000 && state.sThumbLX < 32767) Trigger=LjoyU else if(state.sThumbLY < -9000 && state.sThumbLX > -32768) Trigger=LjoyD else if(state.sThumbRX < -9000 && state.sThumbLX > -32768) Trigger=RjoyL else if(state.sThumbRX > 9000 && state.sThumbLX < 32767) Trigger=RjoyR else if(state.sThumbRy > 9000 && state.sThumbLX < 32767) Trigger=RjoyU else if(state.sThumbRY < -9000 && state.sThumbLX > -32768) Trigger=RjoyD else Trigger= if Trigger= %TriggerPrev% ; We have not released the previous trigger return ; Do nothing. ;************************************************************** ; Change below here what you want each button/trigger to do ; ; If you don't want a button/trigger to do do anything, comment ; the 2 lines for that "trigger". ;************************************************************** if Trigger=A Send, k if Trigger=B Send, p if Trigger=X Send, d if Trigger=Y Send, e if Trigger=DUp Send, D-Pad Up if Trigger=DDown Send, D-Pad Down if Trigger=DLeft Send, D-Pad Left if Trigger=DRight Send, D-Pad Right if Trigger=Start Send, Start if Trigger=Back Send, Back if Trigger=LShoulder Send, Left Shoulder if Trigger=RShoulder Send, Right Shoulder if Trigger=LTrigger Send, Left Trigger if Trigger=RTrigger Send, Right trigger if Trigger=LThumb Send, Left Thumb Click if Trigger=RThumbRight joy moved Right Send, Right Thumb Click if Trigger=LjoyL Send, Left joy moved Left if Trigger=LjoyR Send, Left joy moved Right if Trigger=LjoyU Send, Left joy moved Up if Trigger=LjoyD Send, Left joy moved Down if Trigger=RjoyL Send, Right joy moved Left if Trigger=RjoyR Send, Right joy moved Right if Trigger=RjoyU Send, Right joy moved Up if Trigger=RjoyD Send, Right joy moved Down return The script is a bit longer, but seems to work well. This is great work again! A little help has turned into doing all the heavy lifting here lol. I am up to speed and confident of the scripts behavior and logic, but I still didn't have the experience to do what you just added on. I would have eventually got the joysticks working after narrowing down the dead zone I wanted, but this bit I didn't even think about going down the path you implemented to deal with what I would call "anti auto fire". I really like the idea to store the trigger variable into triggerprev so you can do a check if they change. Funny enough I just made a script for the first time "storing" variables like this, but this is where I don't have experience yet to understand how to use all the tools at my disposal. Little help like this goes a long way in teaching me new concepts and methods to get past a coding challenge. This community is specifically what convinced me learning AHK is worth my time. I've learned so much from studying others scripts on here along with the AHK forum so I appreciate the continued help and lesson you're giving me here! Edited September 7, 2022 by skizzosjt 1 1 Quote Link to comment Share on other sites More sharing options...
maxforwardspeed Posted September 11, 2022 Share Posted September 11, 2022 Do you guys know how to have an AHK run as an additional app to launch software in the background and keep it in the background? I'm running a script to launch Sinden software before games but Launchbox and Bigbox seem to lose focus on actually keeping those apps as background processes, and the game never launches Fullscreen, but I see it below in the taskbar. In Bigbox I have to Alt-tab my way out of a completely black screen, even though all processes are running, just not in the right sequence I guess? Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted September 11, 2022 Share Posted September 11, 2022 9 minutes ago, maxforwardspeed said: Do you guys know how to have an AHK run as an additional app to launch software in the background and keep it in the background? I'm running a script to launch Sinden software before games but Launchbox and Bigbox seem to lose focus on actually keeping those apps as background processes, and the game never launches Fullscreen, but I see it below in the taskbar. In Bigbox I have to Alt-tab my way out of a completely black screen, even though all processes are running, just not in the right sequence I guess? Does this help? Quote Link to comment Share on other sites More sharing options...
maxforwardspeed Posted September 11, 2022 Share Posted September 11, 2022 10 minutes ago, JoeViking245 said: Does this help? Unfortunately it doesn't help in my case. So maybe it's more of an issue with the Sinden software. Was hoping there was something I could do in the scripting itself to force launchbox as the main window and keep in the foreground. Thanks Joe. Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted September 11, 2022 Share Posted September 11, 2022 11 minutes ago, maxforwardspeed said: Unfortunately it doesn't help in my case. Was that checkbox even an option for you? Does it actually start it and send it to the taskbar (if checked)? If you don't use the additional app, does your game start full screen and in focus? [With the additional app in place] try disabling the startup screen. Any change? When you have to Alt+Tab to the non-fullscreen game to bring it in focus, can you see what application you're Alt+Tabbing from? (The application that is stealing focus) Is the Alt+Tab thing required in BigBox only? Or do you need to do that when launching the game from LaunchBox as well? Can you show the script you're using to launch the Sinden software? In the emulator Startup Screen settings that you're using for the game(s) you load the Sinden software with, Is Hide All Windows that are not in Exclusive Fullscreen Mode box checked? Try the opposite. Quote Link to comment Share on other sites More sharing options...
maxforwardspeed Posted September 11, 2022 Share Posted September 11, 2022 24 minutes ago, JoeViking245 said: Was that checkbox even an option for you? Does it actually start it and send it to the taskbar (if checked)? If you don't use the additional app, does your game start full screen and in focus? [With the additional app in place] try disabling the startup screen. Any change? When you have to Alt+Tab to the non-fullscreen game to bring it in focus, can you see what application you're Alt+Tabbing from? (The application that is stealing focus) Is the Alt+Tab thing required in BigBox only? Or do you need to do that when launching the game from LaunchBox as well? Can you show the script you're using to launch the Sinden software? In the emulator Startup Screen settings that you're using for the game(s) you load the Sinden software with, Is Hide All Windows that are not in Exclusive Fullscreen Mode box checked? Try the opposite. Was that checkbox even an option for you? Does it actually start it and send it to the taskbar (if checked)? Yes, it does start directly to the system tray, does not even display in taskbar with this checked. If you don't use the additional app, does your game start full screen and in focus? Yes, works normally. [With the additional app in place] try disabling the startup screen. Any change? No change When you have to Alt+Tab to the non-fullscreen game to bring it in focus, can you see what application you're Alt+Tabbing from? (The application that is stealing focus) It's almost like it's stuck on windows explorer, when I alt-tab the last displayed window of windows explorer is what I'm tabbing from (even though it's not showing on screen, just a black screen in bigbox or last screen view in launchbox) Is the Alt+Tab thing required in BigBox only? Or do you need to do that when launching the game from LaunchBox as well? I have to do it in bigbox as my taskbar does not display, but in launchbox mame will not go fullscreen even though I see it launched in the taskbar. I can alt-tab to mame or just select it from the taskbar below with the mouse. Can you show the script you're using to launch the Sinden software? https://pastebin.com/wq2PZ8GM In the emulator Startup Screen settings that you're using for the game(s) you load the Sinden software with, Is Hide All Windows that are not in Exclusive Fullscreen Mode box checked? Try the opposite. No change, although got excited when I saw this option! Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted September 11, 2022 Share Posted September 11, 2022 @maxforwardspeed Try adding ,,Min to the end of your 2 run lines #SingleInstance Force Run, E😕Emulation\LaunchBox\Sinden\Player 1\[the rest of the long path]\Lightgun.exe,,Min Run, E😕Emulation\LaunchBox\Sinden\Player 2\[the rest of the long path]\Lightgun.exe,,Min ~Esc:: Process,Close,Lightgun.exe Run,taskkill /im "Lightgun.exe" /F sleep, 500 ExitApp return Edit: lol it likes changing : \ when their right next to each other. But you get the idea Quote Link to comment Share on other sites More sharing options...
maxforwardspeed Posted September 11, 2022 Share Posted September 11, 2022 2 hours ago, JoeViking245 said: @maxforwardspeed Try adding ,,Min to the end of your 2 run lines #SingleInstance Force Run, E😕Emulation\LaunchBox\Sinden\Player 1\[the rest of the long path]\Lightgun.exe,,Min Run, E😕Emulation\LaunchBox\Sinden\Player 2\[the rest of the long path]\Lightgun.exe,,Min ~Esc:: Process,Close,Lightgun.exe Run,taskkill /im "Lightgun.exe" /F sleep, 500 ExitApp return Edit: lol it likes changing : \ when their right next to each other. But you get the idea No dice with that either...But, I checked the box in the additional apps that says "wait for exit" and it at least allows the game to load correctly, eventually: takes an extremely long time to load that game...like 15 seconds or so. Quote Link to comment Share on other sites More sharing options...
Sbaby Posted September 14, 2022 Share Posted September 14, 2022 (edited) I would like to set a Windows desktop wallpaper when launchbox starts. This is for those milliseconds when I occasionally can't cover the desktop for some game loads (They are few but it happens to me). But then I would like the Windows 11 wallpaper to return when launchbox / bigbox is closed. Is it possible to do this with ahk script? Edited September 14, 2022 by Sbaby Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted September 15, 2022 Share Posted September 15, 2022 2 hours ago, Sbaby said: I would like to set a Windows desktop wallpaper when launchbox starts. This is for those milliseconds when I occasionally can't cover the desktop for some game loads (They are few but it happens to me). But then I would like the Windows 11 wallpaper to return when launchbox / bigbox is closed. Is it possible to do this with ahk script? This works on Windows 10. Not sure about Windows 11. Also, not sure about dual monitors. To RESTORE the original wallpaper, you would need to keep the script running until you close LB/BB, or store the originalWallpaper variable to a txt file (or something). ; Store original desktop wallpaper (probably has issues with multiple monitors) RegRead, originalWallpaper, HKCU\Control Panel\Desktop, WallPaper ; Set desktop wallpaper to null (not saved to registry. Changes will revert after rebooting PC) DllCall("SystemParametersInfo", UInt, 0x14, UInt, 0, Str, , UInt, 2) Unless you want a 'special' wallpaper while LB/BB is running, it might be easier to have no wallpaper ("null") and set the background color to black. If your default is something other than black, you'll want to save the origBackground variable as well ; Store original background color RegRead, backgroundRGB, HKCU\Control Panel\Colors, Background StringSplit split, backgroundRGB, " " origBackground := % RGB( split1, split2, split3) ; Set the background Color to black DllCall("SetSysColors", "Int", 1, "Int*", 1, "UInt*", 0) And if you're saving (storing) origBackgound, you'll need this subroutine also. ;this subroutine is a part of desktopBackground RGB(r, g, b) { SetFormat, Integer, Hex Return, (r << 16) | (g << 8) | b } Then to restore things after LB/BB closes (again, uses the variables originalWallpaper and origBackground that were saved from before.) ; Restore original desktop wallpaper (image) DllCall("SystemParametersInfo", UInt, 0x14, UInt, 0, Str, originalWallpaper, UInt, 2) ; Restore the original background color DllCall("SetSysColors", "Int", 1, "Int*", 1, "UInt*", origBackground) If you'd prefer to have all that in a library and just call a function to hide and another to restore, you can call the attached library using #Include. Instructions are in the file. You will still need to have the script running, or save to fore mentioned variables externally to be recalled when restoring. The library I made actually also hides/restores the desktop icons, taskbar, minimizes all windows as well as the wallpaper/background thing above. Basically it gives you a black canvas. So you'll want to comment or delete those portions you don't want out. Have fun. ToggleAllLibrary.ahk.txt (be sure to remove ".txt" if/when you go to use it.) Quote Link to comment Share on other sites More sharing options...
Sbaby Posted September 15, 2022 Share Posted September 15, 2022 18 hours ago, JoeViking245 said: This works on Windows 10. Not sure about Windows 11. Also, not sure about dual monitors. To RESTORE the original wallpaper, you would need to keep the script running until you close LB/BB, or store the originalWallpaper variable to a txt file (or something). ; Store original desktop wallpaper (probably has issues with multiple monitors) RegRead, originalWallpaper, HKCU\Control Panel\Desktop, WallPaper ; Set desktop wallpaper to null (not saved to registry. Changes will revert after rebooting PC) DllCall("SystemParametersInfo", UInt, 0x14, UInt, 0, Str, , UInt, 2) Unless you want a 'special' wallpaper while LB/BB is running, it might be easier to have no wallpaper ("null") and set the background color to black. If your default is something other than black, you'll want to save the origBackground variable as well ; Store original background color RegRead, backgroundRGB, HKCU\Control Panel\Colors, Background StringSplit split, backgroundRGB, " " origBackground := % RGB( split1, split2, split3) ; Set the background Color to black DllCall("SetSysColors", "Int", 1, "Int*", 1, "UInt*", 0) And if you're saving (storing) origBackgound, you'll need this subroutine also. ;this subroutine is a part of desktopBackground RGB(r, g, b) { SetFormat, Integer, Hex Return, (r << 16) | (g << 8) | b } Then to restore things after LB/BB closes (again, uses the variables originalWallpaper and origBackground that were saved from before.) ; Restore original desktop wallpaper (image) DllCall("SystemParametersInfo", UInt, 0x14, UInt, 0, Str, originalWallpaper, UInt, 2) ; Restore the original background color DllCall("SetSysColors", "Int", 1, "Int*", 1, "UInt*", origBackground) If you'd prefer to have all that in a library and just call a function to hide and another to restore, you can call the attached library using #Include. Instructions are in the file. You will still need to have the script running, or save to fore mentioned variables externally to be recalled when restoring. The library I made actually also hides/restores the desktop icons, taskbar, minimizes all windows as well as the wallpaper/background thing above. Basically it gives you a black canvas. So you'll want to comment or delete those portions you don't want out. Have fun. ToggleAllLibrary.ahk.txt (be sure to remove ".txt" if/when you go to use it.) Wow, that looks great and very interesting 😮 I did a test on a virtual machine with windows 10. I used your script ToggleAllLibrary.ahk I changed it by removing the semicolons from ToggleEverything: = HideDesktop () and magically it's all black ( This is great ) Then I used a second identical script but removing the semicolons from RestoreDesktop (ToggleEverything [1], ToggleEverything [2]) This brought me everything back to normal...icons, bar, etc except for the desktop background which remained black, instead it should have brought me back the original wallpaper, where did I go wrong? 🧐 1 Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted September 15, 2022 Share Posted September 15, 2022 1 hour ago, Sbaby said: Wow, that looks great and very interesting 😮 I did a test on a virtual machine with windows 10. I used your script ToggleAllLibrary.ahk I changed it by removing the semicolons from ToggleEverything: = HideDesktop () and magically it's all black ( This is great ) Then I used a second identical script but removing the semicolons from RestoreDesktop (ToggleEverything [1], ToggleEverything [2]) This brought me everything back to normal...icons, bar, etc except for the desktop background which remained black, instead it should have brought me back the original wallpaper, where did I go wrong? 🧐 The call to RestoreDesktop doesn't (shouldn't?) have any semicolons. Removing the semicolon from ToggleEverything changes it from an expression method to a legacy method in which both are different in how they set the array ToggleEverything. So that may have something to do with it. Removing the colon from ToggleEverything := HideDesktop() shouldn't have made a difference in "hiding" everything. But it may make a difference in setting its array (originalWallpaper, origBackground) that are returned from HideDesktop(). If those aren't stored properly (or at all), attempting to run RestoreDesktop (ToggleEverything [1], ToggleEverything [2]) Would be just the same as running RestoreDesktop ("", "") ..then RestoreDesktop won't know what the originalWallpaper was to restore it. Quote Link to comment Share on other sites More sharing options...
Sbaby Posted September 15, 2022 Share Posted September 15, 2022 10 minutes ago, JoeViking245 said: The call to RestoreDesktop doesn't (shouldn't?) have any semicolons. Removing the semicolon from ToggleEverything changes it from an expression method to a legacy method in which both are different in how they set the array ToggleEverything. So that may have something to do with it. Removing the colon from ToggleEverything := HideDesktop() shouldn't have made a difference in "hiding" everything. But it may make a difference in setting its array (originalWallpaper, origBackground) that are returned from HideDesktop(). If those aren't stored properly (or at all), attempting to run RestoreDesktop (ToggleEverything [1], ToggleEverything [2]) Would be just the same as running RestoreDesktop ("", "") ..then RestoreDesktop won't know what the originalWallpaper was to restore it. I didn't understand what I should do ... Right now if I run 1.ahk everything works fine and everything goes black Then if I run 2.ahk it restores everything except original wallpaper how should i correct them? 1.ahk2.ahk Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted September 15, 2022 Share Posted September 15, 2022 10 minutes ago, Sbaby said: I didn't understand what I should do ... Right now if I run 1.ahk everything works fine and everything goes black Then if I run 2.ahk it restores everything except original wallpaper how should i correct them? OHhhhh..... you removed the semicolon to uncomment the line(s). Gotch'ya. 21 hours ago, JoeViking245 said: You will still need to have the script running, or save to fore mentioned variables externally to be recalled when restoring. The file I attached was a library that you are to make reference from in your original script. You can reference it by using the #Include statement. I suppose you could try to use it the way you did. But use just one script file. Uncomment the 2 lines and somewhere in between them, add RunWait, "D:\LaunchBox\Core\LaunchBox.exe" Quote Link to comment Share on other sites More sharing options...
Sbaby Posted September 15, 2022 Share Posted September 15, 2022 1 hour ago, JoeViking245 said: OHhhhh..... you removed the semicolon to uncomment the line(s). Gotch'ya. The file I attached was a library that you are to make reference from in your original script. You can reference it by using the #Include statement. I suppose you could try to use it the way you did. But use just one script file. Uncomment the 2 lines and somewhere in between them, add RunWait, "D:\LaunchBox\Core\LaunchBox.exe" 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, very welcome 👍 ; To hide Icons, taskbar, minimize all windows, set wallpaper null, set background black ToggleEverything := HideDesktop() Runwait, "C:\Launchbox\BigBox.exe" Process, Wait, BigBox.exe Process, WaitClose, BigBox.exe ; To restore everything RestoreDesktop(ToggleEverything[1], ToggleEverything[2]) 1 Quote Link to comment Share on other sites More sharing options...
Sbaby Posted September 15, 2022 Share Posted September 15, 2022 Only problem: if I switch from launchbox to bigbox or vice versa I lose the script and desktop return to original normal mode Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.