sendkeys是python的一个扩展包,其中有一些常用的符号来表示键盘的快捷键或者输入的字符,对于pywinauto来说,非常的实用。使用SendKeys将键击和组合键击发送到活动应用程序。
按键 | 键码 | sendkeys使用方式 |
---|---|---|
Shift | + | {"+"} |
tab | TAB | {“TAB”} |
ctrl | ^ | {"^"} |
alt | % | {"%"} |
f1~fn | F1 ~ Fn | {"F1"} ~ {"Fn"} |
向上键 | UP | {"UP"} |
向下键 | DOWN | {"DOWN"} |
回车 | ENTER | {"ENTER"} |
Num键 | NUM LOCK | {“NUMLOCK”} |
#coding:utf-8 import webbrowser as web import SendKeys import time # 开三个网页 url1 = "http://blog.sina.com.cn/s/blog_46d7df020102dvfz.html" web.open_new_tab(url1) url2 = "http://www.jeapedu.com" web.open_new_tab(url2) url3 = "http://www.chinagame.me" web.open_new_tab(url3) i = 0 while i < 10: time.sleep(1) # 发送 Ctrl + F5 刷新 SendKeys.SendKeys("^{F5}") # 延时5 s time.sleep(5) # 切换网页 SendKeys.SendKeys("^+{TAB}") time.sleep(1) SendKeys.SendKeys("^{F5}") time.sleep(5) SendKeys.SendKeys("^+{TAB}") time.sleep(1) SendKeys.SendKeys("^{F5}") time.sleep(5) SendKeys.SendKeys("^+{TAB}") i += 1 # 发送 Alt + F4 SendKeys.SendKeys("%{F4}")
python小爬虫SendKey自动刷博刷视频外挂,布布扣,bubuko.com
原文:http://blog.csdn.net/jeapeducom/article/details/23510457