Hi,
I have this code to run and application (notepad for example) and if it is already running I want to set focus on it.
Regards
I have this code to run and application (notepad for example) and if it is already running I want to set focus on it.
Code:
Set objShell = CreateObject("WScript.Shell")
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
strQuery = "Select * from Win32_Process"
Set ColItems = objWMIService.ExecQuery(strQuery,,48)
For Each objItem In colItems
If UCase(objItem.name)=UCase("notepad.exe") Then
msgbox objItem.name & " already running"
[highlight #FCE94F]'-------- Here I want to set focus on the Open notepad window ------[/highlight]
WScript.Quit
End If
Next
objShell.run "notepad.exe"
Regards