C# FindWindowEx - I Can't Find Teamviewer Panel

Solution 1:

Assuming by WinGetHandle("axie_machine"), you're getting the handle of the TeamViewer window using (part of) its title, then, you're actually getting the handle of the top-level window which your target window whose class is "TV_REMOTEDESKTOP_CLASS" is not a child of. It is one of its descendants, but not a direct child. There's one parent window in between as you can see here:

enter image description here

So, change your code to get the parent window of your target "panel" and then use that to get to the target. The code should looks something like the following:

IntPtr tvWindowHandle = WinGetHandle("axie_machine");
if (tvWindowHandle != IntPtr.Zero)
{
    var panelParent = FindWindowEx(tvWindowHandle, IntPtr.Zero, "ATL:03B8D350", null);
    if (panelParent != IntPtr.Zero)
    {
        var panel = FindWindowEx(panelParent, IntPtr.Zero, "TV_REMOTEDESKTOP_CLASS", null);
        PerformRightClick(panel, new Point(200, 200));
    }
}

Note: You might want to double-check the class of the parent window. It was "ATL:03B8D350" in my version of TV but it might be different for you if you're using another version.