Xphere Posted May 4, 2005 Author Posted May 4, 2005 Thanks, yeah the space between the exe and the args was something i did catch, i forgot to mention that. so my current line is like this$ALL_ARGS = " " & $CmdLine[1] & " " & $CmdLine[2] & " " & $CmdLine[3]I did the msgbox thing, it does grab the whole set of arguments. However it doesnt get the quotes around the path. So i could manually add them within the script or is there a way to get those from the $Cmdline var?If i add them into the Script then would it be like this?$ALL_ARGS = " " & $CmdLine[1] & " " & $CmdLine[2] & ' "' & $CmdLine[3] & '" 'I was not sure either - never used that, so could not comment on it. From the looks of your next post, that area needs some attention.You know what it should look like on the "Target:" line of a shortcut... so, how does MsgBox(0,"$ALL_ARGS",$ALL_ARGS) make it look?$ALL_ARGS = $CmdLine[1] & " " & $CmdLine[2] & " " & $CmdLine[3]MsgBox(0,"$ALL_ARGS",$ALL_ARGS) ;add this line hereAlso, do you need a space between the "exe" and the single quote or are you handling that another way? ---exe ' & $ALL_ARGSAbout the MsgBox question:From manual - Return ValueSuccess: Returns the ID of the button pressed. - see table -$ans = (0, "Notice!", "Please be patient your application is already loading")If $ans = 1 Then;;;;;;they pressed okEndIf<{POST_SNAPBACK}>
Xphere Posted May 4, 2005 Author Posted May 4, 2005 Sweet Finally got it! Thank you so much for your help. Heres the final for now. Added a timeout on the Msgbox. May seem simple for others but this is actually going to save me from some of the most irritating tech support calls. Thank you. $PCC_WindowName = "PCC Process Control" $ALL_ARGS = " " & $CmdLine[1] & " " & $CmdLine[2] & ' "' & $CmdLine[3] & '" ' If WinExists($PCC_WindowName) Then NoticeBox() Else AutoItWinSetTitle($PCC_WindowName) Run ('c:\program files\continuum\Launch.exe' & $ALL_ARGS) PCC_KeepAlive() EndIf Func PCC_KeepAlive() While ProcessExists("Launch.exe") Sleep(1000) WEnd Exit EndFunc Func NoticeBox() MsgBox ( 0, "Notice!", "Please be patient your application is already loading", 10) Exit EndFunc
herewasplato Posted May 4, 2005 Posted May 4, 2005 (edited) CmdLineRaw is lookin' pretty good right about now... but yes, your manual method looks about right --- do you need the space at the very end? '"' vs. '" ' If you search the forum for CmdLine and CmdLineRaw you will get a lot of returns... I've just never needed/used this feature.... later Edit: stupid keyboard - "e" is boucing. Edited May 5, 2005 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size]
SvenP Posted May 5, 2005 Posted May 5, 2005 ..<{POST_SNAPBACK}>A piece of unfinished code that I did some time ago. It doesn't work properly ( Timerdiffs() need to be rewritten and using a splashscreen is not an effective way to show something), but maybe you can use some some scraps from it:expandcollapse popup#Include <Array.au3> $ProcessName="notepad.exe"; Name of process to monitor $MAXTIME=8000 ; Maximum time (in millisecond) process is allowed to run. Dim $ProcessRunning[1]; List of processes with the same name Dim $ProcessInfo[2]; To keep track of running time of a specific process. ; We use $ProcessInfo[0] for PID ; We use $ProcessInfo[1] for Running time $ProcessRunning[0]=0 ; Number of processes with the same name HotKeySet ( "{ESC}" , "EscapeKey" ); User must press ESC to end the loop $CloseProgram = 0 ; Flag for user if he want to stop this script. $String = "No processes running with name " & $ProcessName Do ; Do this loop until user closes the script $list = ProcessList($ProcessName); Make a list of all processes with the name in $ProcessName if $list[0][0] > 0 then; Do we have at least one process with the same name? ; ADD ; Check each process and look if we have the PIDs already in our list ; If not, then add it. for $i = 1 to $list[0][0] $PID=$list[$i][1]; See Helpfile 'ProcessList()' ; Search in our stored list if PID already existed If not FindPID($ProcessRunning,$PID) then $ProcessInfo[0]=$PID; Remember Process ID $ProcessInfo[1]=TimerInit() ; Remember starting time _ArrayAdd($ProcessRunning, $ProcessInfo) ; Add to list $ProcessRunning[0]=$ProcessRunning[0] + 1; Increase counter Endif next endif if $ProcessRunning[0] > 0 then ; Do we have running processes with the given name ; KILL ; Kills processes that were running longer than the permitted time for $i = 1 to $ProcessRunning[0] $ProcessInfo = $ProcessRunning[$i] ; Terminate process if running too long If TimerDiff($ProcessInfo[1]) > $MAXTIME then ProcessClose ($ProcessInfo[0]) next ; CLEAN ; Now clean up the list with PID's not running anymore ; We couldn't do this earlier because a running process could be just stopped by itself or killed by us. $list = ProcessList($ProcessName); Make a list of all processes with the name in $ProcessName for $i = 1 to $ProcessRunning[0] $String = "" $ProcessInfo = $ProcessRunning[$i] ; Now we search in the running process list .. if not FindPID2($List,$ProcessInfo[0]) then _ArrayDelete($ProcessRunning,$i) $ProcessRunning[0]=$ProcessRunning[0] -1; Decrease number of processes EndIf if $i >= $ProcessRunning[0] then exitloop ; in case we deleted an item next ; DISPLAY ; These lines are just for debugging purposes $String = " PID:" & @TAB & "Time:" & @CRLF for $i = 1 to $ProcessRunning[0] $ProcessInfo = $ProcessRunning[$i] $String = $String & $ProcessInfo[0] & @TAB & $ProcessInfo[1]/1000 & @TAB & int(TimerDiff($ProcessInfo[1])) & @CRLF next EndIf ; Show a nice informatical splash SplashTextOn("Monitoring: " & $ProcessName,$String,200,300,200,200,2+16) Until $CloseProgram=1 SplashOff() exit Func FindPID(ByRef $ProcessArray, $PID) ; Searches for a specific PID in each processinfo element in the given array ; Returns 0 if not found ; Returns 1 if found For $Counter = 1 to UBound($ProcessArray) -1 $ProcInfo=$ProcessArray[$Counter] if $ProcInfo[0]=$PID then return 1 Next Return 0 EndFunc Func FindPID2(ByRef $ProcListArray, $PID) ; Searches for a specific PID in each processlist element in the given array ; Returns 0 if not found ; Returns 1 if found For $Counter = 1 to UBound($ProcListArray) -1 ; See ProcessList() helpfile $ProcInfo=$ProcListArray[$Counter][1] if $ProcInfo=$PID then return 1 Next Return 0 EndFunc Func EscapeKey() ; Used to end the main loop when user presses the ESCape key $CloseProgram=1 EndFuncRegards,-Sven
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now