0

我有代码可以向在后台本地运行的应用程序发送左键和右键单击,并且可以完美运行。我正在尝试使用在后台运行的 TeamViewer 管理另一台机器上的应用程序。即使 TeamViewer 窗口中显示的所有内容都是 Firefox,我也无法发送右键单击。有没有办法判断 SendMessage 是否甚至向 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);
}
4

0 回答 0