BATCH - Steam Window - windows

So I've been working on my personal Steam account swapper with pre-game choice options but, I've been running into a few problems. The program works fine but I'm getting this problem where when I chose which profile I want logon to (for smurfing purposes) the Steam window pops up in my face and it prevents me from being able to choose which game I want to play. So I was wondering if there's a way to close the Steam window (and only the window) as soon as it pops up. taskkilling it won't work because if you taskkill it right away it will close the login (login starts when I choose which account I want to play on)
TL;DR I want to close steam window as soon as it pops up
NOTE: When logging in, task manager reads the steam logon window as SteamLogin and not Steam Not sure if this would make the lightbulb go off.

In steam there is an option to suppress the login prompt on system boot, I am not 100% if this will work with your loginswitcher, but is worth a try.
Go to "start menu", "run", type "regedit".
In the registry editor, expand the tree until you find this HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
In "Run", you will find all applications that are starting with Windows. Edit the value for "Steam" and add the silent option (-silent).
Reboot and try your login switcher.

Related

Windows script to run at shutdown

i have been trying to get a windows startup/shutdown sound to play, i couldn't get the sounds to play so i asked on Microsoft, here is the link https://answers.microsoft.com/en-us/windows/forum/all/cannot-change-windows-start-up-sound/8bbcb0a0-1402-4f1e-b080-9c8d526bc205
and i was told that its not possible. well too bad because i am not going to stop there, so i went to local group policy editor on windows 10 where you can choose scripts to run during shutdown and start up. i then wrote a very small PowerShell command with the file name of "shutdown.ps1" the code inside of shutdown.ps1 is
start "C:\Windows\System32\GroupPolicy\Machine\Scripts\Shutdown\TADA.wav"
this file is located in the C:\Windows\System32\GroupPolicy\Machine\Scripts\Shutdown directory along with the TADA.wav file that it plays when it shuts down.
now the issue i am having is that when windows is shutting down, its ending all processes so it does not play the sound. what can i do to change that?
I'm pretty new to all of this and am very grateful for any input you can give.
thanks in advance,
Devin
From How to Change the Windows 10 Logoff, Logon, and Shutdown Sounds in Windows 10:
...
While you can still customize what sounds sounds play for most OS events, Windows 10 hid shut down, logoff, and logon from view. They’re still around, though. You just need to make a few mild changes in the Windows Registry to get them back.
Add the Actions Back to the Sound Control Panel by Editing the Registry
To add the shutdown, logoff, and logon actions back to the menu in the Sound Control Panel app, you just need to make a few little tweaks in the Windows Registry.
...
Open the Registry Editor by hitting Start and typing “regedit.” Press Enter to open Registry Editor and then give it permission to make changes to your PC.
In the Registry Editor, use the left sidebar to navigate to the following key:
HKEY_CURRENT_USER\AppEvents\EventLabels
You’re going to be making one small change in each of three different subkeys inside that EventLabels key. First, we’ll tackle the shutdown sound or, as Windows likes to call it, System Exit. Under the EventLabels key on the left side of Registry Editor, select the SystemExit subkey. On the right side, double-click the ExcludeFromCPL value.
Note that by default, the value is 1, meaning that the action is excluded from the Control Panel. Change the value to 0 and then click “OK.”
Next, you’re going to make exactly the same change in two other subkeys inside the EventLabels key: WindowsLogoff and WindowsLogon. Head into each of those folders, open the ExcludeFromCPL value inside, and change the value from 1 to 0.
No need to restart Windows. You can go ahead and test your changes right away. Open up the Sound Control Panel app by right-clicking the speaker icon in your Notification Area and selecting “Sounds.” 1
You should now see the new actions (Exit Windows, Windows Logoff, and Windows Logon) available in the selection window and you can assign whatever sounds you like to those actions.
If, for whatever reason, you want to hide those actions from the Control Panel again, just head back into Registry Editor and change each of those ExcludeFromCPL values back to 1.
1: On my machine, to get to the Sounds control panel, I had to go into the Settings, choose "Personalization", then "Themes", then `Sounds".
UPDATE:
And indeed, all three sound events show up in my Sounds control panel once I re-enable them in the Registry. However, I tried assigning audio files to them, and although Windows remembered the assignments, nothing played when invoking those actions.
So, I guess the playback functionality is simply not implemented for those events anymore. This seems to be confirmed in your discussion with a Microsoft Insider on answers.microsoft.com (with an 89% upvote rate of 143K replies, I would think he knows what he's talking about):
In Windows 10 there is no way to change the Windows Startup Sound, that sound is set permanently in a DLL in Windows, it is not an audio file like the other system sounds, and even when you turn on the Startup sound on that dialog, sometimes the startup sound will play and other times it will not, this is a known bug in Windows 10, which seems to have been fixed in Windows 11
Windows10 does not support a shutdown sound like previous versions of Windows, you wil find many methods posted online, sadly, none of them work.

Cancel macOS logout

Users often forget to do a task which must be done before logging out. To help with this I'd like to create a popup on logout with an option to cancel logging off.
I'm open to using any language. AppleScript looks promising, although I have no idea how to go about detecting and canceling a logout.
Since writing the question I've discovered the quit handler fires on logging out. I've created a script showing a dialog in the quit handler, which does the job of cancelling a logout, but I'm left with an ugly icon in the dock.
I'm able to remove the dock icon using the "LSUIElement" property in "info.plist", however it no longer prevents logging out when this is set.
Normally, logout clean-up is handled by individual apps: e.g., a document-based app with unsaved changes might prompt the user to save documents first. That makes sense, because each app knows what does and does not need to be taken care of before it closes, while the system generally doesn't.
As you've discovered, if you create a front-facing app the system will poll it and give the app a chance to delay or abort logout. The system does not notify background apps, services, or accessories (on the assumption that only user input needs to be checked for persistence). If you set LSUIElement to 1, your app becomes a background app, and never gets the chance to interfere with logout. There's no easy or immediate way both to have such an app work and have it be invisible to the dock.
Maybe if you're more specific about what your goal is, there might be a workaround (e.g., if you're only interested in monitoring a specific app, that might be doable).

Intercepting a window's attempt to steal global focus on Windows

I'm a developer and a long-time Windows user with an obsession about making my system as convenient to use as possible.
Yesterday I thought about something that has always annoyed me in Windows and that I've taken for granted, and I realized that I have a better idea for how it could work, and I'm now wondering whether it's possible to tweak Windows to work like that.
The thing that annoys me is when windows steal focus. For example, I could be running an installer for some program. While it's working, I'll switch to my browser and browse, maybe entering some text into an email in my browser. Then suddenly the installer finishes and its window steals the focus. Now I'm in the middle of writing an email, so I might press a key that happens to be bound to a button on that installer, and then that button gets invoked, doing some action that I never intended to happen!
This is doubly annoying to me because I'm using a multiple-desktop program called DexPot, and when a window steals focus, it also brings itself to the desktop I'm currently on, which can be really annoying, because then I have to put it back into its original desktop.
How my ideal solution to this problem would work: Every time a window tries to steal focus, we intercept that, and don't let it. We show something like a toaster message saying "Foobar installer wants focus, press Win-Whatever to switch to it". If and when you press the key combo, it switches to the window.
The question is: Is there an easy way to tweak Windows to make this happen? I know very little about Windows programming. I do know AHK and if it's possible with that, that'd be great.
No, there isn't an easy way to add this behavior, but Windows tries to do this automatically.
In theory apps shouldn't be able to steal the foreground while you're actively using another app. Unfortunatly there are some scenarios where Windows can't tell the difference between legitimate user actions that should change the foreground and unwanted foreground-theft. The window manager generally tightens up the holes a bit with each new version of Windows, but also needs to make sure that apps can come to the foreground when the user wants them to, even if that desire is expressed indirectly.
For example, a process launched by the current foreground process can put a window into the foreground. This is necessary so that when a user launches a window from Explorer the newly launched process can open its main window. This permission only lasts until the next user input, so if an application is slow to launch and you start working on an email the app may lose its foreground permissions before it can use them.
See the SetForegroundWindow function documentation for a list of requirements for a process to be able to set a window into the foreground.
There are also apps which specifically make use of these requirements to steal the permission (by joining the foreground queue or synthsising user input to themselves), but I suspect in your installer scenario it is accidental.
I'm not sure what exactly is going on, but I suspect that the problem comes from the installer running as a service and accidentally stealing the foreground permission when it tries to launch the app on your current desktop.
It would be theoretically possible for an external process to hook into the foreground system to override this and show your confirmation toast, but it would be tricky to get right and would require significant low level code (I'd probably start with a CbtHook). It would not be possible in a scripting package like AHK (assuming you mean AutoHotKey) but would need to be native C/C++ code injected into every running process.

Windows restart process reload options

I have such problem. I've got Hanvon graphic tablet on a dual-display system. There is an option in tablet settings to select a display to work with, but I do need an opttion to switch monitors on the fly without entering options.
I've found out, that there is some file HWTabletFind.hou that controls the options. So, i've copied two versions of this file - each for one display. And created a *.bat file
#echo off
ren switch.hou temp.hou
ren HWTabletFind.hou switch.hou
ren temp.hou HWTabletFind.hou
taskkill /F /IM Jwpen.exe
start c:\windows\jwpen.exe /runtablet
HWTabletFind.hou is a running options file,
switch.hou are the options for other monitor
jwpen.exe is a process that controlls tablet.
Now the problem: everything works fine, displays are switching. But when I restart jwpen.exe process, all my applications (e.g. Photoshop) do not see my tablet anymore. Tablet works, but in "mouse mode" - no pressure, no tilt, etc. If I restart application, it sees tablet again.
I think, jwpen.exe must run on application initialisation. If it stopps, app thinks, that tablet is disconnected and does not see it again on jwpen.exe start.
Is there a way not to kill and start a process, but to reset it in some way?
If I change display from tablet settings panel, everything works ok. So it's possible to do it via custom script, to run it via hotkey without opening settings.
AutoIt can help to press and click buttons in a script, Autohotkey can do the same by a hotkey, and SENDKEYS via a VBS script can press keys in a GUI too.

What exactly occurs when selecting windows "Install Updates and shut down" logoff option?

When updates are available and the user selects Shut Down from the Windows start menu, a dialog appears with a menu for Shutdown, Log Off etc.
One option which appears is
"Install Updates And Shut Down"
The question is, what exactly happens when the user presses OK?
Is the task showing the dialog Explorer? (It seems impossible to tell with process monitor spying, because the desktop is frozen)
I assume (But am not sure) this is Explorer and when the user presses OK it calls ExitWindowsEx
If So the question is what is different when the user selects "Install Updates And Shut Down" would it send special flags to ExitWindowsEx or perhaps call another API and would there be any way to spy this functionality?
when the user clicks "ok", it logs out every connected user then it installs all pending updates. the update installation process does not execute in explorer. i think it executes under WinLogon, maybe through a Winlogon notification package. i don't know which system call would trigger this behaviour automatically...
however, you can have a look at the Windows Update Agent API which should allow you to control automatic updates programmatically.
Im just throwing out some thoughts..
Maybe it puts an entry in this registry key before restarting: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce
Also check out the value ShutdownFlags in the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon

Resources