Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

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
?
240 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 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

719 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