Patrick
Patrick

Reputation: 381

C# Find If SendMessage Has Actually Clicked

I have code that will send left and right clicks to applications running locally in the background and it works flawlessly. I am trying to manage an application on another machine using TeamViewer running in the background. Even when all that is showing in the TeamViewer window is Firefox, I can't send a right click. Is there a way to tell if SendMessage is even sending a click to TeamViewer?

private void BtnRightClickTeamViewer_Click(object sender, EventArgs e)
{
    IntPtr handle = WinGetHandle("voyager");
    if (handle != IntPtr.Zero)
    {
        MoveWindow(handle, MainOffsetX, MainOffsetY, HorizontalPixels, VerticalPixels, true);
        int X = Convert.ToInt32(TxtX.Text);
        int Y = Convert.ToInt32(TxtY.Text);
        Point clickHere = new Point(X, Y);
        var panelParent = FindWindowEx(handle, IntPtr.Zero, "ATL:00007FF74F803610", null);
        var panelGrandChild = FindWindowEx(panelParent, IntPtr.Zero, "TV_REMOTEDESKTOP_CLASS", null);
        DoRightClick(panelGrandChild, clickHere);
    }
}

void DoRightClick(IntPtr hwnd, Point point)
{
    var pointPtr = MakeLParam(point.X, point.Y);
    SendMessage(hwnd, WM_MOUSEMOVE, IntPtr.Zero, pointPtr);
    SendMessage(hwnd, WM_RBUTTONDOWN, IntPtr.Zero, pointPtr);
    SendMessage(hwnd, WM_RBUTTONUP, IntPtr.Zero, pointPtr);
}

Upvotes: 0

Views: 84

Answers (0)

Related Questions