Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

kill process AND tray icon - possible?


  • Please log in to reply
32 replies to this topic
brotherS
  • Members
  • 183 posts
  • Last active: May 05 2017 09:15 AM
  • Joined: 01 Jun 2005
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.

Micha
  • Members
  • 539 posts
  • Last active: Dec 31 2011 01:43 PM
  • Joined: 15 Nov 2005
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 :-)

Ciao
Micha

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
WinSet Redraw, , ahk_class TrayNotifyWnd
(Untested)
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

brotherS
  • Members
  • 183 posts
  • Last active: May 05 2017 09:15 AM
  • Joined: 01 Jun 2005
@Micha:
Hehe, nice, I thought about something like that too but then thought there MUST be some better way :)

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

I tried
WinSet Redraw, , ahk_class TrayNotifyWnd

and

WinSet, Redraw, , ahk_class Shell_TrayWnd

and even

DetectHiddenWindows, on
WinSet, Redraw, , ahk_class Shell_TrayWnd


..but nothing works :(
DonationCoder.com brings AHK to the newbies!
Fan of AutoHotkey? Consider an occasional donation to its developer, Chris Mallett.

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
TrayNotifyWnd1 seems to refresh after you move the mouse over it. You can use MouseMove to simulate this.

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


brotherS
  • Members
  • 183 posts
  • Last active: May 05 2017 09:15 AM
  • Joined: 01 Jun 2005
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.

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
The doc. suggests to try to hide and unhide the window if WinSet Redraw fails... Still untested...
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

Whitespliff
  • Members
  • 33 posts
  • Last active: Mar 30 2008 08:43 PM
  • Joined: 09 Feb 2006
I was just to ask the same thing & I stumble on this thread :D

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 :lol:).

More ideas are welcome...
In a world without walls and fences, who needs Windows and Gates?

JSLover
  • Members
  • 920 posts
  • Last active: Nov 02 2012 09:54 PM
  • Joined: 20 Dec 2004

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?

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!

Useful forum links: New content since: Last visitPast weekPast 2 weeks (links will show YOUR posts, not mine)

OMFG, the AutoHotkey forum is IP.board now (yuck!)...I may not be able to continue coming here (& I love AutoHotkey)...I liked phpBB, but not this...ugh...

Note...
I may not reply to any topics (specifically ones I was previously involved in), mostly cuz I can't find the ones I replied to, to continue helping, but also just cuz I can't stand the new forum...phpBB was soo perfect. This is 100% the opposite of "perfect".

I also semi-plan to start my own, phpBB-based AutoHotkey forum (or take over the old one, if he'll let me)
PM me if you're interested in a new phpBB-based forum (I need to know if anyone would use it)
How (or why) did they create the Neil Armstrong memorial site (neilarmstronginfo.com) BEFORE he died?

Whitespliff
  • Members
  • 33 posts
  • Last active: Mar 30 2008 08:43 PM
  • Joined: 09 Feb 2006
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?

brotherS
  • Members
  • 183 posts
  • Last active: May 05 2017 09:15 AM
  • Joined: 01 Jun 2005

...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! :)

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.

evl
  • Members
  • 1237 posts
  • Last active: Oct 20 2010 11:41 AM
  • Joined: 24 Aug 2005
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):

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

; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
PostMessage, 0x112, 0xF060,,, ahk_id %WindowID%


Whitespliff
  • Members
  • 33 posts
  • Last active: Mar 30 2008 08:43 PM
  • Joined: 09 Feb 2006

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?

JSLover
  • Members
  • 920 posts
  • Last active: Nov 02 2012 09:54 PM
  • Joined: 20 Dec 2004

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...

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

...ok...

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!
}

Useful forum links: New content since: Last visitPast weekPast 2 weeks (links will show YOUR posts, not mine)

OMFG, the AutoHotkey forum is IP.board now (yuck!)...I may not be able to continue coming here (& I love AutoHotkey)...I liked phpBB, but not this...ugh...

Note...
I may not reply to any topics (specifically ones I was previously involved in), mostly cuz I can't find the ones I replied to, to continue helping, but also just cuz I can't stand the new forum...phpBB was soo perfect. This is 100% the opposite of "perfect".

I also semi-plan to start my own, phpBB-based AutoHotkey forum (or take over the old one, if he'll let me)
PM me if you're interested in a new phpBB-based forum (I need to know if anyone would use it)
How (or why) did they create the Neil Armstrong memorial site (neilarmstronginfo.com) BEFORE he died?

brotherS
  • Members
  • 183 posts
  • Last active: May 05 2017 09:15 AM
  • Joined: 01 Jun 2005
Thanks for your help, I still hope Chris will come up with a RefreshTray command though... :lol:
DonationCoder.com brings AHK to the newbies!
Fan of AutoHotkey? Consider an occasional donation to its developer, Chris Mallett.