受欢迎的博客标签

SendMessage to browser in the across application( process) with c++

Published

There is Selenium and I used that but there is BOT detection available. Just forget about slenium

 

I am writing a code in C/C++ with Win32API which Automates Chrome.In my code There are extra features too ie.-If you have multiple Chrome Profile you can chose to run how many Profiles to Run at Once. To change the Tabs in Google Chrome they have the Shortcut Key Ctrl+TAB. I want to Simulate that.

The Problems --->

1.To Run Multiple Profiles at Once.

2.Detecting The Window Handles of Every Profile.

3.Automating Certain Keyboard Events.

I have solved Problem 1 and 2.

Even Problem 3 is easy.To automate Chrome Tab changes I have done something like this ----

void clicktabs()
{
    SetForegroundWindow(hwnd);
    INPUT ip[4];
    ip[0] = ip[1] = ip[2] = ip[3] = { 0 };
    
    ip[0].type = ip[1].type = ip[2].type = ip[3].type = INPUT_KEYBOARD;
    ip[0].ki.wVk = ip[3].ki.wVk = VK_CONTROL;
    
    ip[0].ki.wScan = ip[3].ki.wScan = 0x1D; //scancode of CTRL for my Keyboard
    ip[1].ki.wScan = ip[2].ki.wScan = 0x0F;//scancode of TAB for my Keyboard
    //You can also check for yours by observing the lParam Parameter of WndProc().bit 16 to 23 of lParam is your scan code for that particular key.Though it does not matter.

    ip[3].ki.dwFlags = ip[2].ki.dwFlags = KEYEVENTF_KEYUP;
    ip[1].ki.wVk = ip[2].ki.wVk = VK_TAB;
    
    for(int count = 1;;count++)
    {
        if (count == //number of tabs you want to open)
        {count = 0;}
            SendInput(4, ip, sizeof(INPUT));
            Sleep(2000);
    }
}

come from:https://stackoverflow.com/questions/65158114/chrome-automation-with-c-c-postmessage-can-send-message-even-to-a-minimized

 

c# https://stackoverflow.com/questions/30156913/sending-keyboard-key-to-browser-in-c-sharp-using-sendkey-function