Is it possible to activate a tab in another program using an IntPtr?

后端 未结 3 1119
萌比男神i
萌比男神i 2021-01-25 12:15

Thanks in advance.

Is it possible to activate a tab in another program using an IntPtr? If so, how?

SendKeys is not an option.

Perhaps what I need is a

3条回答
  •  青春惊慌失措
    2021-01-25 13:00

    It is almost not possible if SendKeys is not an option but read more

    Now more important part of the question- why:

    We have to look how win32 application works: it has a WndProc/WindowProc method which is resposible for processing "events" form the UI. So every event in the windows application must go through above method. SendKeys method is a special of SendMessage (MSDN), so you can use SendMessage to control other exe than your.

    Simple code could look like:

    IntPtr hwnd = FindWindow("Notepad++", null);
    SendMessageA(hwnd, WM_COMMAND, SOMETHING1, SOMETHING2);
    

    There is already on StackOverflow example how to do that with chrome: C# - Sending messages to Google Chrome from C# application , but this is only a start. You will have to find out what exactly message you want to send.

    In exactly situation which you described I will try to send WM_MOUSE and WM_KEYBORD events to Notepad++ events, but it is only an idea :)

提交回复
热议问题