win32.gui.api.con(前置,鼠标点击,发送数据的Dome)
# -*- coding: UTF-8 -*- import win32gui, win32con import os import time import win32gui import win32api import win32con import pythoncom import glob # import autoit from PIL import ImageGrab global window SVClient=u"SVClient" hwndChildList = [] def mouse(opt): global window opt=opt.decode(encoding='UTF-8',errors='strict') option = win32gui.FindWindowEx(window, None, None, opt) # 获取选项的句柄 left, top, right, bottom = win32gui.GetWindowRect(option) win32api.SetCursorPos((left+10,top+5)) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0) time.sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0) def show(winname): global window window = win32gui.FindWindow(0, winname) if winname=='resource access': win32gui.EnumChildWindows(window, lambda hwnd, param: param.append(hwnd), hwndChildList) #遍历子句柄 win32gui.ShowWindow(window, win32con.SW_SHOW) #显示 # win32gui.SetForegroundWindow(hwd) #获取焦点 win32gui.ShowWindow(window, win32con.SW_NORMAL) #显示最前 def sendmessage(hwnd,text): win32api.SendMessage(hwnd, win32con.WM_SETTEXT, 0, text.encode('gbk')) #向控件发送数据 show(SVClient) mouse('显示资源') show('resource access') sendmessage(hwndChildList[1],u'NA_1_170')