Jump to content

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

Extract Informations about TrayIcons


  • Please log in to reply
149 replies to this topic
SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Dear Sean, :)

This is very useful. Thanks.

When we use AHK command Process, Close to teminate a Process, its Tray Icon gets orphaned and can be cleared from TNA (only) by hovering the mouse over it.

It would be nice & useful if you could wrap up a function: ProcessClose() that deletes the tray icon before terminating the process.

:)

PS: Self-Teminating script that leaves it Icon orphaned.
Process, Close, % DllCall("GetCurrentProcessId")


Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007
Hi Skan,

It would be nice & useful if you could wrap up a function: ProcessClose() that deletes the tray icon before terminating the process.

It's already possible. There is one problem, though.
How will you specify the process to be terminated?
I'm currently using process names to pick up the tray icons, TrayIcons("app.exe").
The problem with it is that it'll pick up all running processes corresponding to app.exe.

kenomby
  • Guests
  • Last active:
  • Joined: --

I'm currently using process names to pick up the tray icons, TrayIcons("app.exe").
The problem with it is that it'll pick up all running processes corresponding to app.exe.

what about using PID when there's multiple instances of app.exe?

i often run multiple instances of some progs that have identical titles, so i use either ahk_id or PID to distinguish between them, and it works great

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

How will you specify the process to be terminated?
I'm currently using process names to pick up the tray icons, TrayIcons("app.exe").
The problem with it is that it'll pick up all running processes corresponding to app.exe.


I thought you would find a way. :D

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

I thought you would find a way. :D

Looks like there was a misunderstanding.
I was simply asking if a process name would be enough even with the limitation, as it indeed did for me, or there is your prefered way to do it if not enough.
Seems that the process name is not enough.

I edited the script as TrayIcons() accepts not only the ProcessName but also the ProcessID as the optional parameter.

After that you may add the following code before closing the process:

sTrayIcons := TrayIcons(pid)
nOffset := 0
Loop
{
	If !nOffset := RegExMatch(sTrayIcons, "(?<=idx: )\d+", idx, nOffset + 1)
	   Break
	DeleteButton(idx)
}


badbob001
  • Members
  • 3 posts
  • Last active: Aug 05 2007 05:05 AM
  • Joined: 29 Jul 2007
Update: NEVER MIND. I see all lines. This is now super super awesome.

This is SO awesome. I have been looking so long for a way to grab tooltip text. One issue is that for multi-line tooltips, the function only returns the last line of the tooltip. Any way to show all tooltip lines?

Thanks!



Mousie
  • Guests
  • Last active:
  • Joined: --
Hey!

Can you help me and tell me, how to optain 'idn' of process i want?

Thanks!

engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
first you must get the pid of the process, using Process, Exist.

Mousie
  • Members
  • 3 posts
  • Last active: Oct 04 2007 10:58 AM
  • Joined: 01 Oct 2007
OK, I have a pid of my process, what shall I do now?

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

OK, I have a pid of my process, what shall I do now?

Assuming it has only one trayicon you may use this:
RegExMatch(TrayIcons(pid), "(?<=idn: )\d+", idn)
MsgBox, % idn


Mousie
  • Members
  • 3 posts
  • Last active: Oct 04 2007 10:58 AM
  • Joined: 01 Oct 2007
OK, I have pid, I have idn, but how can I hide tray icon, for other process?

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

OK, I have pid, I have idn, but how can I hide tray icon, for other process?

Why didn't you ask about what you really wanted to do from the start if you're not going to figure it out yourself?
Anyway, the answer was already there two posts before your first post.

sTrayIcons := TrayIcons(pid)
nOffset := 0
Loop
{
	If Not	nOffset := RegExMatch(sTrayIcons, "(?<=idn: )\d+", idn, nOffset + 1)
		Break
	HideTrayIcon(idn)
}


Mousie
  • Members
  • 3 posts
  • Last active: Oct 04 2007 10:58 AM
  • Joined: 01 Oct 2007
Umm, I'm sorry about that. The thing i want to do, is to hide specific tray icon, with pid i specified.

It doesn't work for me, what you wrote, it hides only tray icon of the script, or all tray icons.

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

Umm, I'm sorry about that. The thing i want to do, is to hide specific tray icon, with pid i specified.

It doesn't work for me, what you wrote, it hides only tray icon of the script, or all tray icons.

Then, don't use it, user/azure/Mousie.

Guestb4u
  • Guests
  • Last active:
  • Joined: --

Then, don't use it, user/azure/Mousie.

now isn't that being a bit extreme!

After all, he can still use it to hide only tray icon of the script, or all tray icons ! :lol: