1 Attachment(s)
iGuidance 2.x auto-run shortcut
In appreciation to all of you who have helped me get my car pc running smoothly, I have written a compiled vb script that will launch iGuidance from a front-end application (I use Digital Dash app) and maximize the window. The script will examine the currently running processes, and if the app is already running, move focus back, rather than launching another instance of iGuidance. On my own system, I also place a shortcut to the script in the start menu so that the app comes up and is ready once the front-end loads. For added convenience, the script will wait 2 seconds, and then send an "enter" key command so to bypass the warning screen. If you did not install iGuidance in the default directory, the script will not function. I’ve included the vbs below if you want to modify and work on it for yourself.
I hope this helps someone out!
'James Eidson - 06/02/05
'run and/or set focus on specified application
'force variable dim
Option Explicit
'dim variables
Dim WshShell
Dim Process, ProcessList
Dim strApplicationName, strApplicationDirectory
Dim strProcessName
'user settings
'------------------------------------
'set process name variable
strProcessName = "iGuidance"
'set application name variable
strApplicationName = "iGuidance"
'set application directory variable
'- don't forget trailing "\"
strApplicationDirectory = "C:\Documents and Settings\All Users\Start Menu\Programs\iNav\iGuidance\"
'------------------------------------
'ignore errors
on error resume next
set WshShell = WScript.CreateObject("WScript.Shell")
'get a list of processes that are running
For Each Process In GetObject("winmgmts:").InstancesOf("Win32_process" )
ProcessList = ProcessList & " " & Process.Name
Next
'see if application is running
If instr(ProcessList, strProcessName) > 0 Then
'If application is running, then return focus to it
WshShell.AppActivate (strApplicationName)
Else
'if application not running, open it
WshShell.Run """"&strApplicationDirectory&strProcessName&"""",3 , false
'run command switches
'0 Hides the window and activates another window.
'1 Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
'2 Activates the window and displays it as a minimized window.
'3 Activates the window and displays it as a maximized window.
'4 Displays a window in its most recent size and position. The active window remains active.
'5 Activates the window and displays it in its current size and position.
'6 Minimizes the specified window and activates the next top-level window in the Z order.
'7 Displays the window as a minimized window. The active window remains active.
'8 Displays the window in its current state. The active window remains active.
'9 Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.
'10 Sets the show-state based on the state of the program that started the application.
'pause until application opens
WScript.Sleep 2000
'run application
WshShell.AppActivate (strApplicationName)
'send the enter command
WshShell.SendKeys "{Enter}"
End If
'do cleanup
Set WshShell = Nothing