Jump to content

How do I kill application running in tray?


Fabre
 Share

Recommended Posts

Ok I need some help

I am using Thunderbird in conjunction with K9, hotmail popper and yahoopops.

so to launch all at once

run ("c:\program files\hotmail popper\hotpop.exe")

run ("C:\Program Files\YahooPOPs\YahooPOPs.exe")

run ("C:\Program Files\KeirNet\K9\K9.exe")

run ("c:\program files\thunderbird\thunderbird.exe")

now I am trying to get the second part of the script to close the first 3 applications when I close Thunderbird

If ProcessExists("thunderbird.exe") = 1 Then

???????

Else

ProcessClose ("hotpop.exe")

ProcessClose ("K9.exe")

ProcessClose ("YahooPOPs.exe")

EndIf

is that correct so far and what command should I use when the process exist?

Guess I should put some kind of loop until the answer is 0 but I am not sure how to do that.

Link to comment
Share on other sites

Thanks a million for the help guys it works like a charm.

2 question tho

When the processes close their icon remains in the tray, they dissapear when they are hovered by the mouse, is there a trick to get them to close aswell?

after the script ends the AutoIt3 process doesn't close, instead it says in the tray that the script is paused.

should i add a ProcessClose for it in the script or is there a cleaner way?

Edited by Fabre
Link to comment
Share on other sites

the WinClose worked for yahoopops so thats 1 icon less

Had a look in K9 found out that if I deactivated the tray options, it would now exit when closing the window (instead of just staying in the tray) but it now ask me for confirmation when exiting.

Didn't manage to find a hidden window for hotmail popper.

Tried the EnvUpdate() made no difference.

So that's only 1 icon left (I can live with that)

and a yes no prompt. (don't have a clue how to deal with that one)

/Edit: bingo found the window it is called "Options - Hotmail Popper"

Edited by Fabre
Link to comment
Share on other sites

If I understand correctly, I would code it this way:

While ProcessExists("thunderbird.exe");forever loop until thunderbird is closed
sleep(1000); small delay to rest processor.
Wend; loop stops when no more thunderbird.
   If Not ProcessExists("thunderbird.exe") Then
         ProcessClose ("hotpop.exe")
         ProcessClose ("K9.exe")
         ProcessClose ("YahooPOPs.exe")
         Exit
    EndIf
; Since Thunderbird and all the other programs are closed, I will now exit to free up memory.

This way you don't have any extra memory taken up by an autoit script (even if very very tiny.)

oh yea, you might want to do a winclose() or winkill() just in case.

Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

scriptkitty the exit Command suggested by Larry solved that issue.

Going to follow your advice and increase the Sleep to 1000

The script now look like this

run ("c:\program files\hotmail popper\hotpop.exe")
run ("C:\Program Files\YahooPOPs\YahooPOPs.exe")
run ("C:\Program Files\KeirNet\K9\K9.exe")
run ("c:\program files\thunderbird\thunderbird.exe")
While 1;forever loop
If Not ProcessExists("thunderbird.exe") Then
WinClose ("Options - Hotmail Popper")
WinClose ("YahooPOPs")
WinClose ("K9")
Exit
EndIf
Sleep(1000)
Wend

No more savage ProcessClose only thing remaining is the yes/no prompt at K9 close

Edited by Fabre
Link to comment
Share on other sites

Lol, yea, I missed the exit, I keep thinking exit loop. :whistle:

$x=msgbox(4,"Warning","Did you read all of the script")
if $x=6 then
exit
else
run("insert foot in mouth.exe")
endif

Oh yea, test out WinKill() or add

sleep(1000)

if winexists("Are you sure you want to close K9?","") then send("Y") ; or something like that.

Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

what about

WinWaitActive("K9", "Are you sure you want to exit")
Send("{ENTER}")

it works but the window is not active when it pop up I still have to select it

/Edit

Ok It's fixed now everything work like it should

here is the final version

run ("c:\program files\hotmail popper\hotpop.exe")
run ("C:\Program Files\YahooPOPs\YahooPOPs.exe")
run ("C:\Program Files\KeirNet\K9\K9.exe")
run ("c:\program files\thunderbird\thunderbird.exe")
While 1;forever loop
If Not ProcessExists("thunderbird.exe") Then
Winclose ("Options - Hotmail Popper")
WinClose ("YahooPOPs")
WinClose ("K9")
WinWait("K9", "Are you sure you want to exit")
WinActivate("K9", "Are you sure you want to exit")
Send("{ENTER}")
Exit
EndIf
Sleep(1000)
Wend

Thanks again for all your precious help.

Edited by Fabre
Link to comment
Share on other sites

It'd probably be safer (and faster since you wouldn't have to activate the window) if you waited for the K9 window, then use ControlLeftClick (preferrably) or WinClose on it.

You could also do something like:

; Start programs
WHILE ProcessExists("thunderbird.exe")
Sleep(1000)
WEND
; Close programs

That eliminates the need for an IF statement and EXIT, also.

Link to comment
Share on other sites

Ok followed your advice

run ("c:\program files\hotmail popper\hotpop.exe")
run ("C:\Program Files\YahooPOPs\YahooPOPs.exe")
run ("C:\Program Files\KeirNet\K9\K9.exe")
run ("c:\program files\thunderbird\thunderbird.exe")
WHILE ProcessExists("thunderbird.exe")
Sleep(1000)
WEND
Winclose ("Options - Hotmail Popper")
WinClose ("YahooPOPs")
WinClose ("K9")
WinWait("K9", "Are you sure you want to exit")
ControlLeftClick ("K9", "Are you sure you want to exit", "Button1")

Anymore changes required?

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