sibson/vncdotool

"type" not working with python code

Closed this issue · 3 comments

I am using python 3.11 with vncdotool and following is my code

client = api.connect('server')
client.keyPress('enter')
client.captureScreen('screenshot.png')
client.type('cmd')

I am getting below error on client.type('cmd'):

  Message=type object 'VNCDoToolClient' has no attribute 'type'
    client.type('cmd')
    ^^^^^^^^^^^
AttributeError: type object 'VNCDoToolClient' has no attribute 'type'

Because VNCDoToolClient does not have a method named type;

type is a command implemented by only by the CLI wrapper vncdotool.command.

If you want to use the API directly yourself, see documenation using client.keyPress(…).

Hey ,

Thanks for looking into it.

As per your suggestion of keypress , i tried below :

client = api.connect('server')
client.keyPress('enter')
client.captureScreen('screenshot.png')
client.keyPress('cmd')

but it again gives me error:

ord() expected a character, but string of length 3 found

I wanted to open command prompt and run commands in another machine using VNC Session , can anyone please help me out ?

Thanks

Again: RTFM!
keyPress works on single keys, e.g. a single character. To type a string you have to press multiple keys.

And be warned: there is not a single mapping from "character" to "key": to type some characters you have to press Shift/Alt/Ctrl/Compose/… keys before pressing a key and then releasing them again in the (correct) order. That is a deficiency of VNC; see #269 (comment) for details