I need to right-click on another application, get the context menu (open after right-clicking) and select an item from it.
I can use postMessage with another application descriptor, and as a result the requested context menu appears, but I have no idea how to select it.
public const int WM_RBUTTONDOWN = 0x0204; public const int WM_RBUTTONUP = 0x0205; [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SendMessage", CharSet = System.Runtime.InteropServices.CharSet.Auto)] public static extern void SendMessage(IntPtr hWnd, int msg, int wParam, int lParam); [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "PostMessage", CharSet = System.Runtime.InteropServices.CharSet.Auto)] public static extern void PostMessage(IntPtr hWnd, int msg, int wParam, int lParam); Point p = Cursor.Position; PostMessage((IntPtr)123456, WM_RBUTTONDOWN, 0, 0); PostMessage((IntPtr)123456, WM_RBUTTONUP, 0, 0);
code>
what should I do next (now the context menu is open)?
thanks, tomer.
Tomer
source share