AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

kill process AND tray icon - possible?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
brotherS



Joined: 01 Jun 2005
Posts: 147

PostPosted: Wed Feb 15, 2006 11:11 am    Post subject: kill process AND tray icon - possible? Reply with quote

Hi,

what I don't really like about "process, close, bla.exe" is that it just kills the process but leaves the program's tray icon in the tray... do you know any way to prevent that?
_________________
DonationCoder.com brings AHK to the newbies!
Fan of AutoHotkey? Consider an occasional donation to its developer, Chris Mallett.
Back to top
View user's profile Send private message
Micha



Joined: 15 Nov 2005
Posts: 440
Location: Germany

PostPosted: Wed Feb 15, 2006 11:37 am    Post subject: Reply with quote

Hi,
well it's the same behaviour, if you kill the thread with taskmanager.
The Explorer doesn't recognize, that the tread had died.

I have only 2 very bad "solutions"
1. Kill all explorer-tasks and start a new one. The tray is recreated. But this means that all explorerwindows will close and some programs does not draw its trayicon again so you can "loose" some icons (Really bad idea)

The second idea: If you move your mouse over the icon, it vanishes.
Perhaps you can remember the current mouseposition, gets the coordinates of the trayicon, kill the thread, move the mouse to that position and moves it back.

I hope somebody has better ideas Smile

Ciao
Micha
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Wed Feb 15, 2006 11:54 am    Post subject: Reply with quote

WinSet Redraw, , ahk_class TrayNotifyWnd
(Untested)
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Last edited by PhiLho on Wed Feb 15, 2006 6:09 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
brotherS



Joined: 01 Jun 2005
Posts: 147

PostPosted: Wed Feb 15, 2006 1:19 pm    Post subject: Reply with quote

@Micha:
Hehe, nice, I thought about something like that too but then thought there MUST be some better way Smile

@PhiLho:
Thanks, sounds perfect, but doesn't work Sad

I tried
Code:

WinSet Redraw, , ahk_class TrayNotifyWnd


and

Code:

WinSet, Redraw, , ahk_class Shell_TrayWnd


and even

Code:

DetectHiddenWindows, on
WinSet, Redraw, , ahk_class Shell_TrayWnd



..but nothing works Sad
_________________
DonationCoder.com brings AHK to the newbies!
Fan of AutoHotkey? Consider an occasional donation to its developer, Chris Mallett.
Back to top
View user's profile Send private message
Titan



Joined: 11 Aug 2004
Posts: 5382
Location: /b/

PostPosted: Wed Feb 15, 2006 2:19 pm    Post subject: Reply with quote

TrayNotifyWnd1 seems to refresh after you move the mouse over it. You can use MouseMove to simulate this.
_________________

Back to top
View user's profile Send private message Visit poster's website
brotherS



Joined: 01 Jun 2005
Posts: 147

PostPosted: Wed Feb 15, 2006 2:53 pm    Post subject: Reply with quote

I'm not sure I can follow... since I'm using the Windows task bar on the left side of the desktop my (currently 15) tray icons are piling up in 3 icon rows... so you suggest to zig-zag the mouse over all the possible tray icon positions with MouseMove?
_________________
DonationCoder.com brings AHK to the newbies!
Fan of AutoHotkey? Consider an occasional donation to its developer, Chris Mallett.
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Wed Feb 15, 2006 6:11 pm    Post subject: Reply with quote

The doc. suggests to try to hide and unhide the window if WinSet Redraw fails... Still untested...
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Whitespliff



Joined: 09 Feb 2006
Posts: 33

PostPosted: Thu Feb 16, 2006 2:25 am    Post subject: Reply with quote

I was just to ask the same thing & I stumble on this thread Very Happy

Now I'm using the MouseMove solution but thats not foolproof, somehow refreshing the systray would do it but I've no idea how to do that (exept for killing explorer.exe & restarting it but that's a bit overkill Laughing).

More ideas are welcome...
_________________
In a world without walls and fences, who needs Windows and Gates?
Back to top
View user's profile Send private message
JSLover



Joined: 20 Dec 2004
Posts: 541
Location: LooseChange911.com... the WTC attacks were done by the US Gov't... the official story is a lie...

PostPosted: Thu Feb 16, 2006 11:19 am    Post subject: Reply with quote

Whitespliff wrote:
More ideas are welcome...

...have you both tried all manner of asking the process to close besides Process, Close...get a handle to a window & do WinClose on it or do PostMessage, WM_CLOSE or WM_QUIT...or something...anything is better than Process, Close...what programs do you need to close so hard?

Code:
WM_CLOSE=0x10
WM_QUIT=0x12

DetectHiddenWindows, On
Process, Exist, dienow.exe
pid:=errorlevel
IfWinExist, ahk_pid %pid%
{
   WinClose
   ;PostMessage, WM_CLOSE
   ;PostMessage, WM_QUIT
}
else msgbox, No dice!

_________________

Home • Click image! • Blog
Back to top
View user's profile Send private message Visit poster's website
Whitespliff



Joined: 09 Feb 2006
Posts: 33

PostPosted: Thu Feb 16, 2006 12:21 pm    Post subject: Reply with quote

In my case it are 2 processes that start along with my TV software, when I close PCTV the processes keep running.

EDIT: I'm not on the cpu that has the script running but I think this would work, TNX!
_________________
In a world without walls and fences, who needs Windows and Gates?
Back to top
View user's profile Send private message
brotherS



Joined: 01 Jun 2005
Posts: 147

PostPosted: Fri Feb 17, 2006 8:18 pm    Post subject: Reply with quote

JSLover wrote:

...have you both tried all manner of asking the process to close besides Process, Close...get a handle to a window & do WinClose on it or do PostMessage, WM_CLOSE or WM_QUIT...or something...anything is better than Process, Close...


You are totally right, I'm now using your WM_QUIT approach, thanks! Smile

Too bad that neither that removes the tray icon...
_________________
DonationCoder.com brings AHK to the newbies!
Fan of AutoHotkey? Consider an occasional donation to its developer, Chris Mallett.
Back to top
View user's profile Send private message
evl



Joined: 24 Aug 2005
Posts: 1239

PostPosted: Fri Feb 17, 2006 9:01 pm    Post subject: Reply with quote

Buried in the manual somewhere was this method I've been using of closing windows, which is supposed to be the same as clicking on the window close button (the X):

Code:

WindowID = ; need to get the window ID one way or another

; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
PostMessage, 0x112, 0xF060,,, ahk_id %WindowID%
Back to top
View user's profile Send private message
Whitespliff



Joined: 09 Feb 2006
Posts: 33

PostPosted: Sat Feb 18, 2006 4:34 pm    Post subject: Reply with quote

brotherS wrote:
Too bad that neither that removes the tray icon...
Strange, it removes the tray icon on my scripts.
There was 1 script where I had to loop it 2 times before the icon disappeared.
_________________
In a world without walls and fences, who needs Windows and Gates?
Back to top
View user's profile Send private message
JSLover



Joined: 20 Dec 2004
Posts: 541
Location: LooseChange911.com... the WTC attacks were done by the US Gov't... the official story is a lie...

PostPosted: Sat Feb 18, 2006 6:19 pm    Post subject: Reply with quote

brotherS wrote:
Too bad that neither that removes the tray icon...

...what prog? Also...instead of zig-zagging you could make an image (screenshot) of only the tray icon...then use ImageSearch to find it on screen & MouseMove to the icon & back...to cause it to disappear from a mouse over...if nothing else ends up working...

Whitespliff wrote:
There was 1 script where I had to loop it 2 times before the icon disappeared.

...ok...

Code:
WM_CLOSE=0x10
WM_QUIT=0x12

DetectHiddenWindows, On
Process, Exist, dienow.exe
pid:=errorlevel
Loop
{
   IfWinExist, ahk_pid %pid%
   {
      WinClose
      ;PostMessage, WM_CLOSE
      ;PostMessage, WM_QUIT
   }
   else if A_Index>1
      break
   else msgbox, No dice!
}

_________________

Home • Click image! • Blog
Back to top
View user's profile Send private message Visit poster's website
brotherS



Joined: 01 Jun 2005
Posts: 147

PostPosted: Sun Feb 19, 2006 8:08 pm    Post subject: Reply with quote

Thanks for your help, I still hope Chris will come up with a RefreshTray command though... Laughing
_________________
DonationCoder.com brings AHK to the newbies!
Fan of AutoHotkey? Consider an occasional donation to its developer, Chris Mallett.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group