Jump to content

How would i do this in v3?


Recommended Posts

How would i do this in v3?

im still looking, but any help would be great.

ok fine

well at least someone saw the poor attempt i made, can some one point me in a better direction

Edited by Xphere
Link to comment
Share on other sites

How would i do this in v3?

im still looking, but any help would be great.

LineWait:
  If ProcessExists("Launch.exe") Then Goto, LineActiveLaunch
  Goto, LineWait

LineActiveLaunch:

 $list = ProcessList("Launch.exe")
 If $list[0][0] > 1 then goto, LineDamtheHam
 Goto, LineWait

LineDamntheHam:

Sleep(5000)
If $list[0][0] < 1 then goto, LineWait
If $list[0][0] > 1 then goto, LineKill

LineKill:

$howmany = $list[0][0]
For $1 = $howmany to 0 Step -1
   ProcessClose("Launch.exe")
Next
  Goto, LineWait

<{POST_SNAPBACK}>

Look in the help file for these.

While

Func

Kerby

Link to comment
Share on other sites

i am not sure about what ur code is suppose to do.

but i think that its suppose to kill all instances of launch.exe

if so you can use:

While 1
    
$PID = ProcessExists("Launch.exe")
If $PID Then ProcessClose($PID)

WEnd

for a complex problem theres almost always an easy solution :(

Edited by w0uter

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Link to comment
Share on other sites

Launch.exe is actually supposed to run, but i have users that click and click over and over again with out waiting for the program to launch.

Then i get multiple instances of launch.exe and it seems when i get more then 3 or 4 randomly it just locks up. so im trying to make sure launch.exe doesnt run too long, and not more then 1 instance or 2. basically launch.exe runs for a few seconds, processes some arguments and then loads another program. so launch.exe should never run very long, and rarely more then 2 or 3 instances at most.

so im trying to control that.

i am not sure about what ur code is suppose to do.

but i think that its suppose to kill all instances of launch.exe

if so you can use:

While 1
    
$PID = ProcessExists("Launch.exe")
If $PID Then ProcessClose($PID)

WEnd

for a complex problem theres almost always an easy solution  :(

<{POST_SNAPBACK}>

Link to comment
Share on other sites

Here is the code i place at the beginning of the script to prevent multiple launches of the same script

If UBound(ProcessList(@ScriptName)) > 2 then Exit

Basically, if there is more than one instance of the script (@Scriptname) loaded in memory, the script terminates itself. You need the >2 because the first entry of the array it returns is the number of processes returned. It could also be done as

$ProcessArray = ProcessList(@ScriptName)
If $ProcessArray[0][0] > 1 then Exit

Launch.exe is actually supposed to run, but i have users that click and click over and over again with out waiting for the program to launch.

Then i get multiple instances of launch.exe and it seems when i get more then 3 or 4 randomly it just locks up. so im trying to make sure launch.exe doesnt run too long, and not more then 1 instance or 2. basically launch.exe runs for a few seconds, processes some arguments and then loads another program. so launch.exe should never run very long, and rarely more then 2 or 3 instances at most.

so im trying to control that.

<{POST_SNAPBACK}>

EDIT:added explanation Edited by ILikeStuff
Link to comment
Share on other sites

Thats useful too but im really trying to run the script and have it run from windows booting indefinately. so i need something that will continually run and check for launch.exe and when it exists. to make sure it doesnt exist too long or get opened too many times.

thank you tho

Here is the code i place at the beginning of the script to prevent multiple launches of the same script

If UBound(ProcessList(@ScriptName)) > 2 then Exit

Basically, if there is more than one instance of the script (@Scriptname) loaded in memory, the script terminates itself.

EDIT:added explanation

<{POST_SNAPBACK}>

Link to comment
Share on other sites

Launch.exe is actually supposed to run, but i have users that click and click over and over again with out waiting for the program to launch.

<snipped>

so im trying to control that.

<{POST_SNAPBACK}>

It sounds like the same topic started in this post.

Anyway, it also sounds like you can change things on each users' computer(s). The "process kill" method will work, but I would like to sugggest a totally different approach. Change the shortcut that normally starts "Launch" to start your script. Your script will start launch. If you include the code from FAQ #14 in the manual, the users will get a message box of your choice if they click again and/or perhaps a small splash screen asking them to be patient while the app loads. That same script can time/kill the app if it is on too long... the script can exit if it notices that the process has been killed by the user. If there are too many users/computers to make these changes on, then toss my idea.

If "Launch' is a complied AutoIt script - then just include the code suggeested above into it...

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

You know i had thought about that approach, but i dismissed it a while ago thinking it wouldnt be the best way to do it. However having a msg box coming up to tell them to be patient is a good idea. Actually i think i'll have the script first check for itself and then run functions based on that. Thank you i like that idea. Unfortunatly launch.exe is not a script..

*edit*

btw "herewasplato" in response to your post in the other thread that i forgot about. I'll just respond here so i dont bring back another topic. The day i started that topic i was incredibly stressed and sleep deprived, no offense taken about my english skills. They are horrible even on a good day. Looking at that post im surprised anyone got anything logical from that post. Thank you for trying to understand it none the less.

*/edit*

It sounds like the same topic started in this post.

Anyway, it also sounds like you can change things on each users' computer(s). The "process kill" method will work, but I would like to sugggest a totally different approach. Change the shortcut that normally starts "Launch" to start your script. Your script will start launch. If you include the code from FAQ #14 in the manual, the users will get a message box of your choice if they click again and/or perhaps a small splash screen asking them to be patient while the app loads. That same script can time/kill the app if it is on too long... the script can exit if it notices that the process has been killed by the user. If there are too many users/computers to make these changes on, then toss my idea.

If "Launch' is a complied AutoIt script - then just include the code suggeested above into it...

<{POST_SNAPBACK}>

Edited by Xphere
Link to comment
Share on other sites

Ok, how about this:

$ProcessName = "Launch.exe";process to watch
$ProcessTimeLimit = 15000;Time First Process can exist in milliseconds
$Timer = 0           ;Initialize the variable
$FirstProcessPID = 0   ;Initialize the variable
$CurrentProcessList = 0;Initialize the variable
$ProcessCount = 0   ;Initialize the variable
$SleepInterval = 250   ;how long of a delay you want in milliseconds in executing the loops so as not to hog the cpu
Do 
    While Not $FirstProcessPID  
        Sleep($SleepInterval)
        $FirstProcessPID = ProcessExists($ProcessName)
        $Timer = TimerInit()
    WEnd
    
    While ProcessExists($FirstProcessPID) 
        $CurrentProcessList = ProcessList($ProcessName)
        If $CurrentProcessList[0][0] > 1 Then
            For $ProcessCount = 1 to $CurrentProcessList[0][0]
                If $CurrentProcessList[$ProcessCount][1] <> $FirstProcessPID then ProcessClose($CurrentProcessList[$ProcessCount][1])
            Next
        EndIf
        If TimerDiff($Timer) > $ProcessTimeLimit then ProcessClose($FirstProcessPID)
        Sleep($SleepInterval)
    WEnd
    $FirstProcessPID = 0
Until 0

But I think herewasplato's suggestion is a much more elegant solution

Thats useful too but im really trying to run the script and have it run from windows booting indefinately. so i need something that will continually run and check for launch.exe and when it exists. to make sure it doesnt exist too long or get opened too many times.

thank you tho

<{POST_SNAPBACK}>

Edited by ILikeStuff
Link to comment
Share on other sites

Thank you for taking the time to write that out. Obviously im a very early stage student at this. So any code i can read through is helpfull.

Ok, how about this:

$ProcessName = "Launch.exe";process to watch
$ProcessTimeLimit = 15000;Time First Process can exist in milliseconds
$Timer = 0          ;Initialize the variable
$FirstProcessPID = 0  ;Initialize the variable
$CurrentProcessList = 0;Initialize the variable
$ProcessCount = 0  ;Initialize the variable
$SleepInterval = 250  ;how long of a delay you want in milliseconds in executing the loops so as not to hog the cpu
Do 
    While Not $FirstProcessPID  
        Sleep($SleepInterval)
        $FirstProcessPID = ProcessExists($ProcessName)
        $Timer = TimerInit()
    WEnd
    
    While ProcessExists($FirstProcessPID) 
        $CurrentProcessList = ProcessList($ProcessName)
        If $CurrentProcessList[0][0] > 1 Then
            For $ProcessCount = 1 to $CurrentProcessList[0][0]
                If $CurrentProcessList[$ProcessCount][1] <> $FirstProcessPID then ProcessClose($CurrentProcessList[$ProcessCount][1])
            Next
        EndIf
        If TimerDiff($Timer) > $ProcessTimeLimit then ProcessClose($FirstProcessPID)
        Sleep($SleepInterval)
    WEnd
    $FirstProcessPID = 0
Until 0

But I think herewasplato's suggestion is a much more elegant solution

<{POST_SNAPBACK}>

Link to comment
Share on other sites

Ok, so one more question.

The only programming languages i work with are proprietary languages for building automation controls. They use goto, and line within their code. Other then that ive only worked with LPC in a LimaMud which is executed completely differently.

Im guessing there is something entirely inefficient or elementary about goto and line vrs the suggestions ive gotten in this topic. Being that im trying to learn, would anyone care to enlighten me on this subject?

OMG ! Goto on this forum !

Please remove this topic ASAP, or people will start acting extremely mad !  :(

<{POST_SNAPBACK}>

Link to comment
Share on other sites

Ok, so heres my revised script. Go easy on me here, this is my first attempt. I cant test this script locally because i dont have the application locally and i cat test this on the computer its going on until tomorrow. So i wanted to put it up here so people can tell me how much i messed this up.

Basically the user clicks on a shortcut that will launch this script and it needs to be able to send these arguments to it.

-o -SGraphics "-NJackson\CX\Jackson Site"

So if i were just going to run the program with out the script i would end up with.

c:\program files\continuum\Launch.exe -o -SGraphics "-NJackson\CX\Jackson Site"

So the quick upshot is, I need to keep my users from trying to open this too many times. So the Script is suppposed to Check for itself. If its already running then put up a msgbox and stop itself as well as not run another instance of Launch.exe. But if the script is not running then there also Shouldnt be a Launch.exe running so it should run launch.exe and send the appropriate arguments to launch.exe.

I hope that made sense and i hope my script isnt too butchered (wow i really cant spell) I would be greatly indebted if someone could look through this code and tell me how bad i messed up. Thanks

$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()

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")
 Exit
EndFunc
Link to comment
Share on other sites

Good job - See below for slight modification:

;;;;;;;;;;;;;;;added this line

$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;;;;;;;;;;;;;;;added this line

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")
 Exit
EndFunc
Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Thank you, just wanted to ask becuase i really wasnt sure if i did the $ALL_ARGS line correctly to combine the args into one variable. I just wasnt sure if i needed to encase all the $cmdline combo's in another set of quotes. Well that and i was wondering how i tell when the user has clicked on ok in that msg box. I was reading the help file and didnt really see how that gets handled or how you can interact with what they click on. I didnt want the script to end until they click ok.

thank you for your help

Good job - See below for slight modification:

;;;;;;;;;;;;;;;added this line

$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;;;;;;;;;;;;;;;added this line

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")
 Exit
EndFunc

<{POST_SNAPBACK}>

Link to comment
Share on other sites

ok, ran into technical problems.. i got a few sorted out. and narrowed down what im hopeing is my last problem with the script.

Aparently, When passing this " -o -SGraphics "-NJackson\CX\Jackson Site" "

to the script, cmdline[1], and [2] are fine, however somehow only "-NJackson" gets sent to the third one. Im sure there is a good reason for that. So what do i do? does that mean then CX will be [4] and Jackson will be [5] and Site will be [6] ? is there a way to capture that whole thing as one? or do i need to take em how they are and concat them in the script? id like to be able to grab everything inbetween the quotes in a easy fashion becuase other wise this script will only work for this set of arguments, and not another set with a different or longer path.

Any insight on this would be greatly appreciated. Im gonna go back to reading the manual in the mean time.

*edit*

Should i use $CmdLineRaw and then remove the scriptname from that and then use that?

I guess im just wondering what "\" in a argument is going to do, or how is that parsed..

Still looking.

Sorry if im abusing this forum

*edit*

Edited by Xphere
Link to comment
Share on other sites

...wasnt sure if i did the $ALL_ARGS line correctly...

<{POST_SNAPBACK}>

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 here

Also, do you need a space between the "exe" and the single quote or are you handling that another way? ---exe ' & $ALL_ARGS

About the MsgBox question:

From manual - Return Value

Success: 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 ok

EndIf

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...