Home
Download
Screenshots

Wiki
Plugins
Translations
Developers
Donate

Forums/Help
Contact Us

StrokeIt

Run command activate if open

Posted by Lmar Kurie 
Lmar Kurie
Run command activate if open
November 09, 2004 11:45AM
It would be nice to have an option on the run command to switch to an already existing version of a program if the program is already running. If the program is not running it executes the shortcut but if the progam is running then activate the window.
Lmar Kurie
Re: Run command activate if open
November 30, 2004 03:14PM
I found a work around that works with XP. It calls a vbs file and passes it the name of the program to open. Here is the source:

'on error resume next
dim WshShell, Instances
set WshShell = CreateObject("WScript.Shell")
set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
dim colItems

Set colItems = objWMIService.ExecQuery("Select * from Win32_Process where ExecutablePath = '" & Replace(WScript.Arguments(0), "\", "\\") & "'",,48)
For Each objItem in colItems
PID = objItem.ProcessID
Next
Test = WshShell.AppActivate(PID)

If test = False then WshShell.run """" & WScript.Arguments(0) & """"
WshShell.SendKeys "%( )x"
nik
Re: Run command activate if open
December 01, 2004 02:04AM
That seems to be the default behaviour for me lmar.
Author:

Your Email:


Subject:


Spam prevention:
Please, solve the mathematical question and enter the answer in the input field below. This is for blocking bots that try to post this form automatically.
Question: how much is 13 plus 3?
Message: