GUI Handling: Right clicking and selecting an option for a icon on the windows taskbar

I almost gave up searching for this option when I was coding on something. I tried using spy++ and wininspector to do this. These were pretty helpful but not that I could get the end result.
Consider this scenario, you have a icon on the taskbar. You need to right click and select an element on the menu which pops up. Ok..you might think of using a spy++ to do this, but you will not able to get the correct command to click there. Dont try to hard on this. All the sequence of commands wont work.
A simple thing would be to search for this command —> WM_COMMAND in the logs that appear in spy++ or win inspector and note its control ID.
The control id is unique to each item on the pop up menu when you right click the icon.
Now search for the window, and get its handle. After you get its handle use the sendmessage to send a message to the icon.
SendMessage( h, WM_COMMAND, 0x8011(this is the control id in hexadecimal), (LPARAM)  0 );
This should solve your issue.

Leave a Reply

Your email address will not be published. Required fields are marked *