其他分享
首页 > 其他分享> > pyqt5写的qq刷屏器

pyqt5写的qq刷屏器

作者:互联网

pyqt5写的qq刷屏器,坐标获取的时候把右上角放到输入框里之后点击获取坐标即可

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'QMAINDIMDOWUI.ui'
#
# Created by: PyQt5 UI code generator 5.15.0
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.

import sys
import time
import pyautogui
import pyperclip
import pywintypes
import win32api
import win32con
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtWidgets import *
from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(300, 208)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.pushButton = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton.setGeometry(QtCore.QRect(50, 100, 75, 23))
        self.pushButton.setObjectName("pushButton")
        self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_2.setGeometry(QtCore.QRect(150, 100, 75, 23))
        self.pushButton_2.setObjectName("pushButton_2")
        self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit.setGeometry(QtCore.QRect(50, 50, 191, 20))
        self.lineEdit.setToolTip("")
        self.lineEdit.setObjectName("lineEdit")
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(50, 20, 171, 20))
        self.label.setObjectName("label")
        self.radioButton = QtWidgets.QRadioButton(self.centralwidget)
        self.radioButton.setGeometry(QtCore.QRect(100, 130, 89, 17))
        self.radioButton.setObjectName("radioButton")
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 300, 21))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.pushButton.setText(_translate("MainWindow", "开始发送"))
        self.pushButton_2.setText(_translate("MainWindow", "获取坐标"))
        self.lineEdit.setPlaceholderText(_translate("MainWindow", "输入想刷屏的句子"))
        self.label.setText(_translate("MainWindow", "坐标为(,)"))
        self.radioButton.setText(_translate("MainWindow", "持续点击"))




class MAINWINDOW(QMainWindow):
    def __init__(self):
        super(MAINWINDOW, self).__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.BANG()

    def BANG(self):
        self.ui.pushButton.clicked.connect(self.cao1)
        self.ui.pushButton_2.clicked.connect(self.cao2)

    def cao2(self):
        self.x = self.x()
        self.y = self.y()
        self.ui.label.setText(f'坐标为({self.x},{self.y})')

    def cao1(self):
        i = 0
        pyautogui.click(self.x, self.y)
        while True:
            if self.ui.radioButton.isChecked():
                pyautogui.click(self.x, self.y)
            else:
                pass
            pyperclip.copy(f'{self.ui.lineEdit.text()}{i}')
            win32api.keybd_event(162, 0, 0, 0)
            win32api.keybd_event(86, 0, 0, 0)
            win32api.keybd_event(86, 0, win32con.KEYEVENTF_KEYUP, 0)
            win32api.keybd_event(162, 0, win32con.KEYEVENTF_KEYUP, 0)
            time.sleep(0.02)
            win32api.keybd_event(162, 0, 0, 0)
            win32api.keybd_event(13, 0, 0, 0)
            time.sleep(0.02)
            win32api.keybd_event(13, 0, win32con.KEYEVENTF_KEYUP, 0)
            win32api.keybd_event(162, 0, win32con.KEYEVENTF_KEYUP, 0)
            time.sleep(0.02)
            i = i + 1

if __name__ == '__main__':
    app = QApplication(sys.argv)
    main = MAINWINDOW()
    main.show()
    sys.exit(app.exec_())

标签:qq,pushButton,刷屏,self,pyqt5,QtWidgets,import,QtCore,MainWindow
来源: https://blog.csdn.net/suqernb/article/details/110732851