i know move the mouse for where i want. but how can send a click message to another program?

I donĀ“t think thos is a C++ problem. It seems an operating system problem. Which is your operating system?

finally i did it:

void AccaoDoRato(int x, int y, HWND Destino, int Butao=0)
{
    //get the actual window
    HWND JanelaActual = GetForegroundWindow();

    //get the position mouse
    POINT PosicaoCursor;
    GetCursorPos(&PosicaoCursor);
    Sleep(1000);

    //change mouse position
    POINT CursorNovaPosicao;
    CursorNovaPosicao.x=x;
    CursorNovaPosicao.y=y;
    ClientToScreen(Destino,&CursorNovaPosicao);
    SetCursorPos(CursorNovaPosicao.x,CursorNovaPosicao.y);

    //send the message mouse... seems that i must use the 2(up and down)
    INPUT Input={0};
    // left down
    Input.type = INPUT_MOUSE;
    if(Butao==ButaoEsquerdo)
        Input.mi.dwFlags  = MOUSEEVENTF_LEFTDOWN;
    else if(Butao==ButaoDireito)
        Input.mi.dwFlags  = MOUSEEVENTF_RIGHTDOWN;
    else if(Butao==ButaoDireito)
        Input.mi.dwFlags  = MOUSEEVENTF_MIDDLEDOWN;
    SendInput(1,&Input,sizeof(INPUT));

    // left up
    ZeroMemory(&Input,sizeof(INPUT));
    Input.type = INPUT_MOUSE;
    if(Butao==ButaoEsquerdo)
        Input.mi.dwFlags  = MOUSEEVENTF_LEFTUP;
    else if(Butao==ButaoDireito)
        Input.mi.dwFlags  = MOUSEEVENTF_RIGHTUP;
    else if(Butao==ButaoDireito)
        Input.mi.dwFlags  = MOUSEEVENTF_MIDDLEUP;
    SendInput(1,&Input,sizeof(INPUT));
    Sleep(1000);

    //back to the used window
    SetFocus(JanelaActual);

    //back to the mouse position
    SetCursorPos(PosicaoCursor.x,PosicaoCursor.y);
}

thansk for all

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.