python pyautogui应用 点击屏幕任意位置
import pyautogui
print(pyautogui.size())#显示当前显示器分辩率
pyautogui.moveTo(525,455)#移动鼠标到指定位置
pyautogui.click()#当前位置单击
pyautogui.doubleClick()#当前位置双击
pyautogui.getActiveWindowTitle()#当前窗口标题
pyautogui.getAllWindows()#获得所有窗口的句柄
pyautogui.getActiveWindow()#获得活动窗口的句柄
pyautogui.getAllTitles()#获得所有窗口的标题
pyautogui.position()获取鼠标的当前位置:先将鼠标定位到指定位置,在命令行输入pyautogui.position()回车即可显示,例如:
>>> pyautogui.position()
Point(x=86, y=53)
>>> pyautogui.size()
Size(width=1920, height=1080)
>>> pyautogui.getActiveWindowTitle()
'*Python 3.7.8 Shell*'
>>> pyautogui.getAllWindows()
[Win32Window(hWnd=132064), Win32Window(hWnd=65780), Win32Window(hWnd=525610), Win32Window(hWnd=328374), Win32Window(hWnd=525010), Win32Window(hWnd=2097942), Win32Window(hWnd=262278), Win32Window(hWnd=263224), Win32Window(hWnd=918788), Win32Window(hWnd=721000), Win32Window(hWnd=65932), Win32Window(hWnd=65926), Win32Window(hWnd=66560), Win32Window(hWnd=328416), Win32Window(hWnd=328946), Win32Window(hWnd=66424), Win32Window(hWnd=66426), Win32Window(hWnd=65862), Win32Window(hWnd=197278)]
>>> pyautogui.getActiveWindow()
Win32Window(hWnd=525610)
>>> pyautogui.getAllTitles()
['', '', '*Python 3.7.8 Shell*', '*untitled*', 'Python 3.7.8 documentation', 'Python 3.7.8 documentation', 'jxjy3.py - C:/python37/jxjy3.py (3.7.8)', '管理员: 命令提示符', '学习 - 博客园', '0424.bat - 记事本', '', '', 'MainWindow', '', '', '', '', 'Program Manager', '']
pyautogui.getInfo()
('win32', '3.7.8 (tags/v3.7.8:4b47a5b6ba, Jun 28 2020, 08:53:46) [MSC v.1916 64 bit (AMD64)]', '0.9.53', 'C:\\python37\\pythonw.exe', Size(width=1920, height=1080), datetime.datetime(2022, 4, 25, 12, 38, 57, 848275))