简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM