Solved

procedure to select an item in the popup menu of an arbitrary icon in the system tray

Posted on 2004-08-24
3
230 Views
Last Modified: 2010-04-05
I would like a procedure to select (simulate a mouse click on) an item in the right-click popup menu of an arbitrary (i.e. third-party) icon (application) in the system tray.

I imagine the parameters would be something like

Blah(TrayIconHandle: THandle; MenuCaption: String);

or

Blah(TrayApplicationEXEName: String; MenuCaption: String);

or

Blah(WindowClassName: String; MenuCaption: String);

...or something similar.

0
Comment
Question by:gary_williams
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
Wim ten Brink earned 250 total points
ID: 11886242
It works more different than you think, unfortunately... I've done quite a few interesting things with trayicon applications and often use the raw API functions to make them do what I want them to do. So let's explain how the mechanism works...

Behind a treeview there's a messageloop that is responding to messages send to it. This messageloop is linked to a popup menu and this popup menu is just sending messages to the message loop. So you (right) click on the icon and it gets a message to show the popup menu. Then you click on a menuitem and a message is posted to execute some action.

A messageloop is represented by a handle of a visible or non-visible window. This window captures the GUI related messages. So you need to know to which handle you have to send the messages. The application can contain multiple messageloops each in their own thread so it's not easy to determine to which messageloop you have to post a new message. (Or which window) And you need to know which message for the menu-item you want to post. (You can actually skipping the right-click here, btw.)

It's not an easy task but a tool like winspy or spy++ can show you the messages that are sent around and to which messageloops they are sent.
0
 
LVL 2

Author Comment

by:gary_williams
ID: 11886849
Unfortunately, there are many programs called "winspy", and I'm having difficulty filtering the Google search results down to the appropriate tool.  Can you provide a URL?
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 11941211
Try D:\Borland\Delphi5\Bin\ws32.exe or wherever else you have Delphi installed. Delphi has a tool called WinSight that's doing something similar to WinSpy and those tools. ;-)
And to be honest, there are hundreds of these kinds of message spy tools. They're not too hard to make yourself once you're familiar with Windows hooks...
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now