AutoHotkey Community

It is currently May 25th, 2012, 5:19 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 139 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 10  Next
Author Message
 Post subject:
PostPosted: May 1st, 2007, 6:37 pm 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
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.
Code:
Process, Close, % DllCall("GetCurrentProcessId")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 1st, 2007, 11:52 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 2nd, 2007, 7:22 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 2nd, 2007, 8:40 pm 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
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. :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 2nd, 2007, 10:34 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Skan wrote:
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:

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 29th, 2007, 8:55 pm 
Offline

Joined: July 29th, 2007, 7:01 pm
Posts: 3
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 1st, 2007, 7:14 pm 
Hey!

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

Thanks!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 1st, 2007, 7:22 pm 
Online
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8657
Location: Salem, MA
first you must get the pid of the process, using Process, Exist.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 1st, 2007, 9:30 pm 
Offline

Joined: October 1st, 2007, 9:28 pm
Posts: 3
OK, I have a pid of my process, what shall I do now?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 3rd, 2007, 7:36 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 3rd, 2007, 4:05 pm 
Offline

Joined: October 1st, 2007, 9:28 pm
Posts: 3
OK, I have pid, I have idn, but how can I hide tray icon, for other process?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 4th, 2007, 1:16 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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)
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 4th, 2007, 9:35 am 
Offline

Joined: October 1st, 2007, 9:28 pm
Posts: 3
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 4th, 2007, 9:58 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 7th, 2007, 5:01 pm 
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 ! :lol:


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 139 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 10  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: nothing, toddintr, Yahoo [Bot] and 22 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group