How do you open the context menu of a window (the normal Windows context that appears when you Right-Click the title-bar of a window).
Things I've tried (on a button click)
ReleaseCapture();
SendMessage(this.Handle, WM_NCRBUTTONDOWN, 0, 0);
SendMessage(this.Handle, WM_RBUTTONUP, 0, 0);
SendMessage(this.Handle, WM_CONTEXTMENU, 0, 0);
And this:
ReleaseCapture();
SendMessage(this.Handle, WM_NCRBUTTONDOWN, HT_CAPTION, 0);
SendMessage(this.Handle, WM_RBUTTONUP, HT_CAPTION, 0);
SendMessage(this.Handle, WM_CONTEXTMENU, HT_CAPTION, 0);
To open the system context menu on a window you can press Alt+Space. So in your case you could send those keys to that window, which should open the context menu for you.
The part you did with SendMessage
actually only sends a notification that the specified window that simulate right clicks. But it's still important where the mouse is.
Also important: If you use "SendKeys.Send" (for windows forms), this will only affect the window that is currently active.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With