Starting an app and cmd without focusing on their windows
The current situation is that I have a mouse button binding in AutoHotkey to kill a process, do some file operations and then start an application (.exe).
I would like to start the app without losing the focus of the current fullscreen window I am using.
In Autohotkey you have the function WinActivate to give the focus on a windows :
I can think of 2 ways to accomplish this, assuming there are no command line switches to start it minimized or hidden.
- FileCreateShortcut allows a RunState parameter. You could create a shortcut with a RunState of minimized, then execute the shortcut. The effectiveness of this depends largely on what type of application it is.
- Use WinWait with a timeout period to wait for your executed program to exist, then use WinActivate to reactivate your fullscreen application. This will allow your application start time to vary, and you will not have to hard code sleep times.
Set the window (Mainwindow) that you want to keep the focus on to be always on top. Note that this doesnt work with a fullscreen app (I couldn't find a solution for a true fullscreen app), but it works fine with a windowed one: Winset, Alwaysontop, , Mainwindow
Run the side app and wait until it creates a window: Run, Sideapp.exe, , hide; WinWait, Sideapp
Focus on the main window again: WinActivate, Mainwindow
Thank you for everyone who contributed.