pip 代理安装库:

pip install requests -i http://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn

python -m pip install --upgrade pip -i http://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn






win32:

//获取窗口句柄(clsNmae,标题)
hwin = win32gui.FindWindow("TianLongBaBu WndClass", None);
//获取窗口title(句柄)
win32gui.GetWindowText(hwin);
//设置窗口标题(句柄,标题)
win32gui.SetWindowText(hwin,"newTitle");
//获取当前坐标的句柄
hw = win32gui.WindowFromPoint(win32api.GetCursorPos());
//窗口大小
left, top, right, bottom = win32gui.GetWindowRect(hw);
//toast
win32api.MessageBox(0,"Hello PYwin32","MessageBox",win32con.MB_OK | win32con.MB_ICONWARNING);



//所有窗口句柄

import win32gui;
import win32api;
hwinList =[];
win32gui.EnumWindows(lambda hWnd, param: param.append(hWnd), hwinList);
for hwnd in hwinList:
title =win32gui.GetWindowText(hwnd);
clsName=win32gui.GetClassName(hwnd);
print(title+"--"+clsName);

 

 

//模拟鼠标左键

import os;
import sys;
import requests;
import win32api;
import win32gui;
import win32con;
import psutil;
import time;
def move_click(x, y, t=0): # 移动鼠标并点击左键
win32api.SetCursorPos((x, y)) # 设置鼠标位置(x, y)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN |
win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0) # 点击鼠标左键
move_click(50, 30);

 

 

//屏幕截图通过句柄id

from PyQt5.QtWidgets import QApplication
from PyQt5.QtGui import *
import win32gui
import sys
hwnd =win32gui.FindWindow(None, 'Everything');
print(hwnd);
app = QApplication(sys.argv);
screen = QApplication.primaryScreen();
img = screen.grabWindow(hwnd).toImage();
img.save("screenshot.jpg")

posted on 2020-01-05 00:33  iscys  阅读(183)  评论(0编辑  收藏  举报