← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #701165]: [request] Windows: act on a non-forground app-window (not or not fully visible)

 

Question #701165 on SikuliX changed:
https://answers.launchpad.net/sikuli/+question/701165

johnny doe posted a new comment:
Send message is use for sending keytroke and mouse input to the target window without actually using the mouse and keyboard. The user can still use the mouse and keyboard.
//send left click at target 250,250 without using the mouse
SendMouseJB(hwnd, 'L', 250, 250);
 //send right click at target 350,350 without using the mouse
SendMouseJB(hwnd, 'R', 350, 350);
//open inventory of the game
SendKeyboardJB(hwnd, 'I', 'I');

void SendMouseJB(HWND hwnd, const char button, int x, int y)
{
    //left mouse at x,y
    if (button == 'L')
    {
        SendMessage(hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y));
        SendMessage(hwnd, WM_LBUTTONUP, MK_LBUTTON, MAKELPARAM(x, y));
    }
    //right mouse at x,y
    else if (button == 'R')
    {
        SendMessage(hwnd, WM_RBUTTONDOWN, MK_RBUTTON, MAKELPARAM(x, y));
        SendMessage(hwnd, WM_RBUTTONUP, MK_RBUTTON, MAKELPARAM(x, y));
    }
}
void SendKeyboardJB(HWND window, WORD key, char letter)
{
    SendMessage(window, WM_KEYDOWN, key, 0);
    if (letter != 0)
        SendMessage(window, WM_CHAR, letter, 1);
    SendMessage(window, WM_KEYUP, key, 1);
}

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for SikuliX.