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 

Extract Informations about TrayIcons
Goto page Previous  1, 2, 3, 4, 5  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
SKAN



Joined: 26 Dec 2005
Posts: 5890

PostPosted: Tue May 01, 2007 6:37 pm    Post subject: Reply with quote

Dear Sean, Smile

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.

Smile

PS: Self-Teminating script that leaves it Icon orphaned.
Code:
Process, Close, % DllCall("GetCurrentProcessId")
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1338

PostPosted: Tue May 01, 2007 11:52 pm    Post subject: Reply with quote

Hi Skan,

Skan wrote:
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.
Back to top
View user's profile Send private message
kenomby
Guest





PostPosted: Wed May 02, 2007 7:22 am    Post subject: Reply with quote

Sean wrote:

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
Back to top
SKAN



Joined: 26 Dec 2005
Posts: 5890

PostPosted: Wed May 02, 2007 8:40 pm    Post subject: Reply with quote

Sean wrote:
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. Very Happy
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1338

PostPosted: Wed May 02, 2007 10:34 pm    Post subject: Reply with quote

Skan wrote:
I thought you would find a way. Very Happy

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:

Code:
sTrayIcons := TrayIcons(pid)
nOffset := 0
Loop
{
   If !nOffset := RegExMatch(sTrayIcons, "(?<=idx: )\d+", idx, nOffset + 1)
      Break
   DeleteButton(idx)
}
Back to top
View user's profile Send private message
badbob001



Joined: 29 Jul 2007
Posts: 3

PostPosted: Sun Jul 29, 2007 8:55 pm    Post subject: Reply with quote

Update: NEVER MIND. I see all lines. This is now super super awesome.

Quote:
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!
Back to top
View user's profile Send private message
Mousie
Guest





PostPosted: Mon Oct 01, 2007 7:14 pm    Post subject: Reply with quote

Hey!

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

Thanks!
Back to top
engunneer



Joined: 30 Aug 2005
Posts: 6772
Location: Pacific Northwest, US

PostPosted: Mon Oct 01, 2007 7:22 pm    Post subject: Reply with quote

first you must get the pid of the process, using Process, Exist.
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
Mousie



Joined: 01 Oct 2007
Posts: 3

PostPosted: Mon Oct 01, 2007 9:30 pm    Post subject: Reply with quote

OK, I have a pid of my process, what shall I do now?
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1338

PostPosted: Wed Oct 03, 2007 7:36 am    Post subject: Reply with quote

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

Assuming it has only one trayicon you may use this:
Code:
RegExMatch(TrayIcons(pid), "(?<=idn: )\d+", idn)
MsgBox, % idn
Back to top
View user's profile Send private message
Mousie



Joined: 01 Oct 2007
Posts: 3

PostPosted: Wed Oct 03, 2007 4:05 pm    Post subject: Reply with quote

OK, I have pid, I have idn, but how can I hide tray icon, for other process?
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1338

PostPosted: Thu Oct 04, 2007 1:16 am    Post subject: Reply with quote

Mousie wrote:
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.

Code:
sTrayIcons := TrayIcons(pid)
nOffset := 0
Loop
{
   If Not   nOffset := RegExMatch(sTrayIcons, "(?<=idn: )\d+", idn, nOffset + 1)
      Break
   HideTrayIcon(idn)
}
Back to top
View user's profile Send private message
Mousie



Joined: 01 Oct 2007
Posts: 3

PostPosted: Thu Oct 04, 2007 9:35 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1338

PostPosted: Thu Oct 04, 2007 9:58 am    Post subject: Reply with quote

Mousie wrote:
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.
Back to top
View user's profile Send private message
Guestb4u
Guest





PostPosted: Sun Oct 07, 2007 5:01 pm    Post subject: Reply with quote

Sean wrote:
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 ! Laughing
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4, 5  Next
Page 2 of 5

 
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