Focus on running application startup

I am running a sequence of applications from a series of scripts and I want to make sure that the open program will always be in focus.
We must ensure this because it is an experimental setup, and we want to minimize such troubles as changing the focus to a full-screen window.

This problem has already occurred infrequently when the previous program ends, and for a moment the desktop becomes visible, and the user clicks on an icon on the desktop, and immediately after that the next program is processed in sequence, the new window is not in focus.

Now the problem became much more frequent when I hid the command window from the view.

Any way to get the focus for the next program in the sequence, whether it is a command command, some settings for the OS (we are in Win XP) or an auxiliary application can be useful.

+7
source share
2 answers

if I understood correctly, start /f yourapp.exe will launch the application in the foreground.

+1
source

If you want to focus another program, you can do it.

 call focus WindowTitle exit /b :focus setlocal EnableDelayedExpansion if ["%~1"] equ [""] ( echo Please give the window title. exit /b ) set pr=%~1 set pr=!pr:"=! echo CreateObject("wscript.shell").appactivate "!pr!" > "%tmp%\focus.vbs" call "%tmp%\focus.vbs" del "%tmp%\focus.vbs" goto :eof endlocal 

I use vbscript to focus the application. You need to pass the title box, not the name box (whatever.bat). To make sure that you have configured the window correctly, you can set its name. Example:

 title WindowTitle 
+1
source

All Articles