基于python 开发 微信机器人自动回复 app
# coding:utf-8
__author__ = "zhou"
# create by zhou on 2020/3/3
from flask import Flask,render_template,request
import threading
import time
import pywinauto
from pywinauto.controls.hwndwrapper import DialogWrapper, BaseWrapper
import time
import typing
from PyQt5 import QtCore, QtWidgets, QtGui
from PyQt5.QtWidgets import QMainWindow,QApplication,QMessageBox
import json
import sys
from queue import Queue, Empty
desktop = pywinauto.Desktop()
class WeChatApi(object):
def __init__(self):
self.chat_list = []
self.chat_list_uptime = 0
self._fresh_window()
self.queue = Queue(10000)
self.chat_window_titles = []
def _fresh_window(self):
global desktop
buff = []
buff_1 = []
for i in range(10):
try:
windows:typing.List[DialogWrapper] = desktop.windows()
except Exception as e:
print(str(e))
desktop = pywinauto.Desktop()
for i in windows:
if i.friendly_class_name() == 'ChatWnd':
_ = i.window_text()
buff.append([i, _])
buff_1.append(_)
buff_1 = list(set(buff_1))
buff_1.sort()
self.chat_list = buff
self.chat_window_titles = buff_1
self.chat_list_uptime = time.time()
def send_to_chat_window(self, window_title, message):
self.queue.put((window_title