WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Process UDFs

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Run EXE No Focus

 Keywords:  Run EXE No Not Focus Active udfRunNotActive SW_SHOWMINNOACTIVE ShellExecuteEx ShellExecuteExA

Question:

In WB is it possible to run another application (an executable) without the other application taking focus? by this I mean use one of the run commands I know there is a RunIcon but for instance if you need to run Notepad as a normal window with no focus can this be done?

Answer:

#DefineFunction udfRunNotActive (filename)
   bbfile=BinaryAlloc(StrLen(filename))
   BinaryPokeStr(bbfile,0,filename)   
   bbExecInfo=BinaryAlloc(60)
   BinaryPoke4(bbExecInfo,00,60)
   BinaryPoke4(bbExecInfo,04,0);
   BinaryPoke4(bbExecInfo,08,0)
   BinaryPoke4(bbExecInfo,16,IntControl(42,bbfile,0,0,0))
   BinaryPoke4(bbExecInfo,28,4) ;SW_SHOWNOACTIVE = 4   
   ret=DllCall(DirWindows(1):"shell32.dll",long:"ShellExecuteExA",lpbinary:bbExecInfo)   
   BinaryFree(bbExecInfo)
   BinaryFree(bbfile)
   Return
#EndFunction

udfRunNotActive(DirWindows(1):"notepad.exe")

Exit

Article ID:   W18383
Filename:   Run EXE No Focus .txt
File Created: 2013:04:30:10:42:16
Last Updated: 2013:04:30:10:42:16