借助有道词典识别屏幕字符串

 

import win32api
import time
import win32clipboard
import win32con

# 捕获模拟器窗口 160-56 仅可单击打
# 遍历url连接 -移动 126-766
# 有道-更多释义-鼠标左单击 411-813
# 有道查询口-鼠标左双击 959-270
# 有道查询口-鼠标右单击 959-270
# 有道查询口-鼠标左单击-剪切 1065-313
time.sleep(12)
x, y = 160, 56
win32api.SetCursorPos([x, y])
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y)
time.sleep(0.05)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y)
time.sleep(10)

x, y = 126, 766
win32api.SetCursorPos([x, y])
time.sleep(10)

x, y = 411, 813
win32api.SetCursorPos([x, y])
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y)
time.sleep(0.05)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y)
time.sleep(10)

x, y = 959, 270
win32api.SetCursorPos([x, y])
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y)
time.sleep(0.05)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y)
time.sleep(0.05)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y)
time.sleep(0.05)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y)
time.sleep(2)

time.sleep(1)
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, x, y)
time.sleep(0.05)
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, x, y)
time.sleep(2)

win32clipboard.OpenClipboard()
# win32clipboard.EmptyClipboard()
time.sleep(0.2)
x, y = 1065, 313
win32api.SetCursorPos([x, y])
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y)
time.sleep(0.05)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y)
time.sleep(2)

# 之前,必须设置鼠标右键后关闭win输入法
cs = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT)

x, y = 126, 766
win32api.SetCursorPos([x, y])
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y)
time.sleep(0.05)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y)
time.sleep(10)




posted @ 2018-01-25 22:46  papering  阅读(368)  评论(0编辑  收藏  举报