Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-08-24
3
Medium Priority
?
242 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 1000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

772 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