python 实现 ctrl + 左键 单击刷新网页
import sys
from pywinauto.application import Application
import mouse
import keyboard
import time
class App(object):
def __init__(self, pid):
app = Application(backend='uia').connect(process=int(pid))
self.win = app.top_window()
self.wait = False
def _refresh(self):
self.win.maximize()
self.win.wait('visible')
keyboard.send('ctrl+r') #发送快捷键 刷新
def check(self):
def callback():
if self.wait == True:
self._refresh()
self.wait = False
mouse.on_click(callback)
return self
def hotkey(self):
def callback():
self.wait = True
time.sleep(0.5)
self.wait = False
keyboard.add_hotkey('ctrl', callback)
return self
def run(self):
while True:
pass
# 通过进程id 连接到浏览器: python <file.py> <9092>
App(sys.argv[1]).hotkey().check().run()