Jump to content

else...if


Ravel
 Share

Recommended Posts

I would like to know if anyone knows how to set up a script to only close a particular program if another particular program is not open?

Basically what i want to do is kill a process... only if a program that also uses that process isnt open.

Local $List = ProcessList('FileA.exe')
For $I = 1 To $List[0][0]
    ProcessClose($List[$I][1])
Next

; I suppose i would put the command "If" here...

opt ("WinTitleMatchMode",2)
WinWaitActive("FileC.exe")
WinActive("FileC.exe")

; then if the above process didnt exist i would go..."else?"

Local $List = ProcessList('FileB.exe'); is the process that should be closed if process (FileC.exe) doesnt exist
For $I = 1 To $List[0][0]
    ProcessClose($List[$I][1])
Next

; and if (FileC.exe) does exist then it should not be closed.

So I think I explained what i would like to do. I hope you all can understand it and point me in the right direction for getting the script correct. As always I appreciate any help that you can provide. Thanks! :o

Link to comment
Share on other sites

  • Moderators

Assuming you know which programs go with what... If ProcessExists('.exe') Then ProcessClose('.exe') ?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Um... not sure i am Understanding what you are referring to... My knowledge of auto it isnt that indepth. I am still behind the learning curve. I am not exactly sure where the commands that you mentioned should be placed in the above script.

Local $List = ProcessList('FileA.exe')
For $I = 1 To $List[0][0]
    ProcessClose($List[$I][1])
Next

; I suppose i would put the command "If" here...
If ProcessExists('FileC.exe'); if process exists use command endif?

-----or-------

;if process (FileC.exe)doesnt exist then use "Then ProcessClose(FileB.exe)?

opt ("WinTitleMatchMode",2)
WinWaitActive("FileC.exe")
WinActive("FileC.exe")

; then if the above process didnt exist i would go..."else?"

Local $List = ProcessList('FileB.exe'); is the process that should be closed if process (FileC.exe) doesnt exist
For $I = 1 To $List[0][0]
    ProcessClose($List[$I][1])
Next

; and if (FileC.exe) does exist then it should not be closed.

Is that what you were referring to?

Edited by Ravel
Link to comment
Share on other sites

  • Moderators

First do you know which programs go with what programs your trying to close?

If ProcessExists('Process1.exe') And ProcessExists('ProcessToClose.exe') Then ProcessClose('ProcessToClose.exe')... you wouldn't need to do the process search if you know the names.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

First do you know which programs go with what programs your trying to close?

If ProcessExists('Process1.exe') And ProcessExists('ProcessToClose.exe') Then ProcessClose('ProcessToClose.exe')... you wouldn't need to do the process search if you know the names.

Yea i know the names of the processes that i am trying to close. So I think I understand what you are asking me, but I cant figure out how what you are saying to above must inserted into the script.

Local $List = ProcessList('DFBHD.exe')
For $I = 1 To $List[0][0]
    ProcessClose($List[$I][1])
Next
Local $List = ProcessList('hidexp.exe')
For $I = 1 To $List[0][0]
    ProcessClose($List[$I][1])
Next

Above is the script as it sits now. How would i use the commands that you mentioned above to close the hidexp.exe, if bittorrent.exe didnt exist, and if it did skip it and leave it running?

Link to comment
Share on other sites

Yea i know the names of the processes that i am trying to close. So I think I understand what you are asking me, but I cant figure out how what you are saying to above must inserted into the script.

Local $List = ProcessList('DFBHD.exe')
For $I = 1 To $List[0][0]
    ProcessClose($List[$I][1])
Next
Local $List = ProcessList('hidexp.exe')
For $I = 1 To $List[0][0]
    ProcessClose($List[$I][1])
Next

Above is the script as it sits now. How would i use the commands that you mentioned above to close the hidexp.exe, if bittorrent.exe didnt exist, and if it did skip it and leave it running?

If Not ProcessExists("bittorrent.exe") Then ProcessClose("hidexp.exe")

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

  • Moderators

Basically, you would just have this in a loop:

If ProcessExists('DFBHD.exe') And ProcessExists('hidexp.exe') Then 
ProcessClose('hidexp.exe')
EndIf
That's it.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Depends on the script you have written, assuming you have one written.

The script that I have mentioned is written above... also based on what you said, and what smoke said how would they work together? Do either of you mind putting together the information that you provided with what I provided into a working script? I think then I will understand what you all are showing me... I guess i learn best by seeing something that works.

Link to comment
Share on other sites

don't need

Local $List = ProcessList('FileA.exe')

For $I = 1 To $List[0][0]

ProcessClose($List[$I][1])

Next

Not sure what you mean here

; I suppose i would put the command "If" here...

opt ("WinTitleMatchMode",2)

WinWaitActive("FileC.exe")

WinActive("FileC.exe")

Don't need this either

; then if the above process didnt exist i would go..."else?"

Local $List = ProcessList('FileB.exe'); is the process that should be closed if process (FileC.exe) doesnt exist

For $I = 1 To $List[0][0]

ProcessClose($List[$I][1])

Next

; and if (FileC.exe) does exist then it should not be closed.

I think this code is what your trying to do in the above

If ProcessExists("bittorrent.exe") Then 
; do something here
else
  ProcessClose("hidexp.exe")
endif
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

If ProcessExists("bittorrent.exe") Then 
; do something here
else
  ProcessClose("hidexp.exe")
endif
yea the do something here that you placed there... i would want the script to end it self there or errr.... quit trying to close the hidexp program since bittorrent is open.

So basically:

Local $List = ProcessList('DFBHD.exe');this is the default program in the script that will always be closed by the script when the script is ran. 
For $I = 1 To $List[0][0]
    ProcessClose($List[$I][1])
Next
;this is the part of the script that hinges on whether or not bittorrent exists
If ProcessExists("bittorrent.exe") Then 
; do something here (do not close)
else
  ProcessClose("hidexp.exe")
endif

IF the above script is usable... how do i stop it from continueing to close hidexp? Or will it automatically quit if bittorrent exists?

Edited by Ravel
Link to comment
Share on other sites

  • Moderators

Local $List = ProcessList('DFBHD.exe');this is the default program in the script that will always be closed by the script when the script is ran.

For $I = 1 To $List[0][0]

ProcessClose($List[$I][1])

Next

;this is the part of the script that hinges on whether or not bittorrent exists

If ProcessExists("bittorrent.exe") Then

; do something here (do not close)

else

ProcessClose("hidexp.exe")

Exit

endif

You don't need what's in red with ProcessExists()/Close()

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

yea the do something here that you placed there... i would want the script to end it self there or errr.... quit trying to close the hidexp program since bittorrent is open.

So basically:

Local $List = ProcessList('DFBHD.exe');this is the default program in the script that will always be closed by the script when the script is ran. 
For $I = 1 To $List[0][0]
    ProcessClose($List[$I][1])
Next
;this is the part of the script that hinges on whether or not bittorrent exists
If ProcessExists("bittorrent.exe") Then 
; do something here (do not close)
else
  ProcessClose("hidexp.exe")
endif

IF the above script is usable... how do i stop it from continueing to close hidexp? Or will it automatically quit if bittorrent exists?

if you know the exe names, you don't need to get the process list

and all your trying to do for example is the below

ProcessClose('DFBHD.exe')

;this is the part of the script that hinges on whether or not bittorrent exists
If Not ProcessExists("bittorrent.exe") Then ProcessClose("hidexp.exe")
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

You don't need what's in red with ProcessExists()/Close()

I know that part isnt needed for what i am trying to accomplish, but if i take it out of the script... when i execute the script it wont close dfbhd.exe. I need it to kill dfbhd.exe--->then hidexp.exe only if bittorrent.exe doesnt exist----and if it does then leave hidexp.exe running. I hope that clarifies what I am trying to do.

....another note... is the process list useful for closing multiple instances of the same process... I do use the script for that also.

Edited by Ravel
Link to comment
Share on other sites

$PID = ProcessExists('DFBHD.exe')
While $PID
    ProcessClose($PID)
    Sleep ( 1000 )
    $PID = ProcessExists('DFBHD.exe')
WEnd

;this is the part of the script that hinges on whether or not bittorrent exists
If Not ProcessExists("bittorrent.exe") Then ProcessClose("hidexp.exe")

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

another option also, is to have it run till bittorent.exe doesn't exist

$PID = ProcessExists('DFBHD.exe')
While $PID
    ProcessClose($PID)
    Sleep ( 1000 )
    $PID = ProcessExists('DFBHD.exe')
WEnd

;this is the part of the script that hinges on whether or not bittorrent exists
While ProcessExists("bittorrent.exe")
    Sleep ( 1000 )
WEnd
ProcessClose("hidexp.exe")
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Hey thanks for your help guys.... I got it running based on your inputs. I really appreciate it!!! Here is the code as it is written in working form. I have tested it and it works great!

HotkeySet('{ESC}', 'Terminate')

ProcessClose('DFBHD.exe')

If Not ProcessExists("bittorrent.exe") Then ProcessClose("hideippla.exe")

Local $List = ProcessList('AimBot.exe')
For $I = 1 To $List[0][0]
    ProcessClose($List[$I][1])
Next

Local $List = ProcessList('Xray.exe')
For $I = 1 To $List[0][0]
    ProcessClose($List[$I][1])
Next



;change speaker setup
Send("^{NUMPAD3}")
WinWaitActive("Sounds and Audio Devices Properties")
WinActive("Sounds and Audio Devices Properties")
Sleep(500)
Send("!d")
Sleep(100)
Send("5")
Sleep(100)
Send("!a")
Sleep(100)
Send("{ENTER}")
Sleep(100)
Send("{ENTER}")
Sleep(100)

;unhide google deskbar
MouseClick("left", 1599, 175,)
Sleep(1000)
MouseClick("left", 1519, 8,); these sets are to unhide Google side bar
Sleep(200)
MouseClick("left", 1428, 175,)


Func Terminate()
    Exit
EndFunc

There it is. The working code. Thanks again for everyones help! :o

Edited by Ravel
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...