简体   繁体   English

如何在 Python 上使用 webbot 浏览器一次按下多个键

[英]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.我正在使用 webbot 的浏览器在浏览器上做一些事情。 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.但是,当我尝试一次按下 2 个键时,我遇到了一个问题,即按下 1 号键,然后按下 2 号键然后抬起,然后将 1 号键重新抬起。 For instance, when there is text, and you are trying to select all of it by pressing CTRL + A or copying with CTRL + C.例如,当有文本时,您尝试通过按 CTRL + A 或使用 CTRL + C 复制所有文本 select。

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.但是,这会在按下按钮 A 之前按下并抬起 CTRL 按钮。

How do I solve this, such that it presses down the CTRL button, presses and releases the A button, then releases the CTRL button?我该如何解决这个问题,例如它按下 CTRL 按钮,按下并释放 A 按钮,然后释放 CTRL 按钮?

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找到有关 webbot 的文档,这里是https://buildmedia.readthedocs.org/media/pdf/webbot/latest/webbot.pdf

Search for: Press any special key or a key combination involving Ctrl, Alt, Shift搜索:按任何特殊键或包含 Ctrl、Alt、Shift 的组合键

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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