Solved

WM_SYSCOMMAND & SC_MOUSEMENU

Posted on 2004-04-08
8
1,614 Views
Last Modified: 2013-12-03
SendMessage( targetWindow, WM_SYSCOMMAND, SC_MOUSEMENU, lParam );

The documentation for SC_MOUSEMENU says "Retrieves the window menu as a result of a mouse click.". Now I know the parameters I send are correct, but it does nothing. Can someone explain why it doesnt work? Or possibly explain how I could get it to work?

Additionally, while watching with Spy++, when a window normally gets a WM_SYSCOMMAND and SC_MOUSEMENU it is only sent and theres no matching return. When I send the message it is send and and returned always.

Alternatively I will give points to any technique that will open a menubar item normally givin the items screen position, ie not getting the submenu and calling TrackPopupMenu, but allowing the OS to handle it normally as if it was clicked with a mouse ( btw, the mouse is not actually over the item ).

Thanks,

Jason
0
Comment
Question by:mite51
  • 3
  • 2
8 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 500 total points
ID: 10786206
What are you passing in lParam?

lParam
The low-order word specifies the horizontal position of the cursor, in screen coordinates, if a window menu command is chosen with the mouse. Otherwise, this parameter is not used.
The high-order word specifies the vertical position of the cursor, in screen coordinates, if a window menu command is chosen with the mouse. This parameter is –1 if the command is chosen using a system accelerator, or zero if using a mnemonic.

To open a menu, use the SendInput() or keybd_event() API functions to simulate ALT-[X] key presses.
0
 
LVL 1

Author Comment

by:mite51
ID: 10786269
LPARAM lParam;
lParam = MAKELPARAM( screenIntersect.x, screenIntersect.y );

I have matched my screenIntersect to the values I got from Spy++ just to ensure they were correct compared to normal ( not gernerated by me ) messages.

I know I can send ALT+downarrow key command to open the first menu.. only problem with that is if the menu is already in tht "ALT" state sending another ALT will turn that state off. Also its not really the same since the ALT state will wait for a hotkey, not what normall happens when you open a menu with a mouse click.

0
 
LVL 86

Expert Comment

by:jkr
ID: 10786296
>>The documentation for SC_MOUSEMENU says "Retrieves the window menu as a result
>>of a mouse click.".

There seems to be a misconception, these messages are only sent to inform applications about menu access, not to actually open them (which is done by the system) - if you want to open a menubar item, send a 'mouse_event()' to the coordinates of your menubar item.
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 23

Expert Comment

by:chensu
ID: 10786309
>I know I can send ALT+downarrow key command to open the first menu.. only problem with that is if the menu is already in tht "ALT" state sending another ALT will turn that state off.

I didn't mean ALT+downarrow. For example, to open the window menu, send a ALT+Space key press.
0
 
LVL 1

Author Comment

by:mite51
ID: 10786318
Ah, that does make sense, I supposed. But there must be a way to do this without SendInput. One problem I have with SendInput or mouse_event is that unless the corrdinates of the mouse position are over the item ( ie not obscured by another window ) the event will not be routed to the desired windows.

btw, the menu may not actually be on the screen or topmost ;)

0
 
LVL 1

Author Comment

by:mite51
ID: 10786330
chesu, same deal. space opens system menu , down arrow opens the first menu. In either case is not the same as a mouse click. Tho that is probably what I will end up having to do.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video discusses moving either the default database or any database to a new volume.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now