sibson/vncdotool

ineffective nocursor argument

Willard-Robbins opened this issue · 2 comments

vncdotool version 1.0.0
python version 3.10

The VNC server is an old binary. I believe it came from Real VNC.

I'm passing the output screenshot of vncdotool to OpenCV to confirm on-screen UI elements. I would like the screenshot to exclude the cursor so that it does not interfere with template matching. Despite using the nocursor argument, my screenshots still contain the cursor... Am I missing something?

    vnc_client = api.connect(host, password=None)
    vnc_client.timeout = 10
    vnc_client.nocursor = True  # Appears to be ineffective. Want to remove the cursor from screenshots to prevent occlusion.
    vnc_client.captureScreen('screenshot.png')  # Resulting screenshot contains the cursor.

nocursor onyl works when client-side rendering is negotiated with the server: In that case the cursor shape and position are sent to the client, which is then supposed to merge the cursor shape into the screen before displaying it to the user.
Without the extension the server will handle that and will instead sent the screen with the cursor already merged in, which the client cannot undo.
Please check if your server does the merging — in which case this issue would be invalid — or the client is supposed to do it. Sadly there is no easy way in vncdotool to see, if PSEUDO_CURSOR = -239 is negotiated: If you're experienced with pdb you can add a break _handleDecodePsuedoCursor or you might want to use wireshark to see, if you an updateRectangle with that encoding is received by the client — or use another VNC client, which is more verbose.

I just want to add that before closing this issue it might be worth it to add some of @pmhahn's explanation in the documentation. At first I looked at the nocursor and pseudocursor options in https://vncdotool.readthedocs.io/en/latest/modules.html?highlight=cursor#vncdotool.client.VNCDoToolClient.cursor (since my initial guess for nocursor from just looking at the source code had no effect as above) but there are no docstrings explaining the meaning of either of these, even a single short sentence might be quite helpful. Then also adding the above detail could be very helpful so that other users don't have to look up the issues on Github to figure this out.