Search code examples
c#sendmessagepostmessageuser32

How to click on Menu items with PostMessage/SendMessage User32


Hello i have Windows aplication,i need to click on One on Menu/Tabs items.I can find the Menu with all options,files,help.... tabs ,but i can't find the way how to get to my item.

I can't send picture of my aplication,but i will send the same example/logic with IE where i need to Click on Greek(IOS).

1.I need to click on View

2.Hover Encoding

3.Hover More

and 4. Click Greek(IOS).

enter image description here

I can find the all bar Menu with File,Edut,View,Tools,Help

intWhdr = FindWindow(Step1Window.Class, Step1Window.Name);//Program 
currChild = FindWindowEx(intWhdr, 0, "WindowsForms10.Window.", "mainMenu");//Menu

here i have my Main menu , here i stuck i can't find the way to press on menu item(like in Ie example)View menu. I don't even need the hover action i can user SendMessage DownArrow and RightArrow to get to my item, but i neeed to click on View first.

Any ideas how to click on View menu form Menu bar?with SendMessage/PostMessage

UPDATE

enter image description here


Solution

  • After long research and with help of dvasanth,i find the salution

    1.Yon need to find WM_LBUTTONUP/DOWN NOT WM_SETCURSOR like in img,than open the properties and find wParam and lParam

    2.Change format 011C16A8 just by adding 0x+lParam/wParam

    Ex: 011C16A8 = 0x011C16A8

    EX: 00000001= 0x01

    EX: 00000012=0x12

    I think i get an idea....

    In my case i find in properties :

    WM_LBUTTONUP

    lParam=00000001
    wParam=000C0348
    

    WM_LBUTTONDOWN

    lParam=00000000
    wParam=000C0348
    

    sow after edit they look like this:

    WM_LBUTTONUP

    lParam=0x01
    wParam=0x000C0348
    

    WM_LBUTTONDOWN

     lParam=0x00
     wParam=0x000C0348
    

    3.Just insert this to your code.

    My code that worked:

    intRes1 = PostMessage(currChild, WM_LBUTTONDOWN, 0x01, 0x000C0348);
    System.Threading.Thread.Sleep(100);
    intRes1 = PostMessage(currChild, WM_LBUTTONUP, 0x00, 0x000C0348);