I'd like to control menus on a apps created by myself.

Apps A.exe:
Windows Form apps (C#)
It has menus
Menu1-MenuItem1(MenuItem of Menu1)
MenuItem1 calls a EventHandler that shows a message box

Apps B.exe:
Windows Form apps (C#)
It has a button

If I click the button, I'd like to launch A and select Menu1-MenuItem1.

I can launch A by

But I'm not sure how can I click the MenuItem1 from B.

I saw some web sites, and SendMessage seems to be a method I can use.
[DllImport("user32.dll", CharSet=CharSet.Auto)]
private static extern int SendMessage (IntPtr hwnd, int wMsg, int wParam, int lParam);

But I'm not sure what value should be set for wMsg, int wParam, int lParam for my case.

Could you please answer it?
Thank you in advance.

If app A is not running prior to clicking the button in app B, then simply create a command line argument that is of type int, and set up the app to check for it, and select the menu item based on that command line argument.

Then in app B, instead of just using


instead use something like

public void startAwithMenu(int menuNumber)
            System.Diagnostics.Process appA = new Process();
            appA.StartInfo.FileName = "A.exe";
            appA.StartInfo.Arguments = menuNumber.ToString();

Oh, I see. It works fine. Thanks for your answer.