Solved

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

Posted on 2004-08-24
3
237 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month5 days, 11 hours left to enroll

627 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