Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"type" not working with python code #285

Closed
TejasPatadiya10 opened this issue May 1, 2024 · 3 comments
Closed

"type" not working with python code #285

TejasPatadiya10 opened this issue May 1, 2024 · 3 comments
Assignees

Comments

@TejasPatadiya10
Copy link

TejasPatadiya10 commented May 1, 2024

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'
@pmhahn pmhahn self-assigned this May 1, 2024
@pmhahn
Copy link
Collaborator

pmhahn commented May 1, 2024

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(…).

@pmhahn pmhahn closed this as completed May 1, 2024
@TejasPatadiya10
Copy link
Author

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

@pmhahn
Copy link
Collaborator

pmhahn commented May 2, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants