pythonwebbot

How to press multiple keys at once using webbot Browser on Python


I am using Browser from webbot to do some things on a browser. However, I ran into a problem when I am trying to press 2 keys at once such that key number 1 is pressed down, then key number 2 is pressed down then lifted up, then key number 1 is lifted back up. For instance, when there is text, and you are trying to select all of it by pressing CTRL + A or copying with CTRL + C.

I currently have:

from webbot import Browser
web = Browser()

web.go_to(any_website)
web.press(web.Key.CONTROL) + web.type('a')

However, this presses and lifts back up the CTRL button before it presses button A.

How do I solve this, such that it presses down the CTRL button, presses and releases the A button, then releases the CTRL button?


Solution

  • how about this?

    web.press(web.Key.CONTROL + 'a')
    

    Found documentation about webbot, here's the https://buildmedia.readthedocs.org/media/pdf/webbot/latest/webbot.pdf

    Search for: Press any special key or a key combination involving Ctrl , Alt , Shift