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
Solved

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

Posted on 2004-08-24
3
232 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

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…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

766 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