需要:
PYQT5仲器,用PYQT5作為GUI;
pynput皿渗,利用pynput斩芭,做鼠標(biāo)轻腺、鍵盤監(jiān)控;
class loginui(QWidget):
def __init__(self):
super().__init__()
self.initUI()#GUI
self.tutu()#鼠標(biāo)監(jiān)控
self.key()#鍵盤監(jiān)控
先開始構(gòu)建基本GUI界面划乖,此處涉及PYQT5 Qwidget/QLineEdit/QLabel/QPushButton/tableWidget贬养,此處不詳細(xì)說(shuō)明,請(qǐng)自行百度琴庵,或仔細(xì)看實(shí)例說(shuō)明误算。
'''
def initUI(self):
screen = QDesktopWidget().screenGeometry()# 獲取屏幕坐標(biāo)系str(i[0])
size = self.geometry()# 獲取窗口坐標(biāo)系
newLeft = (screen.width() - size.width()) / 2
newTop = (screen.height() - size.height()) / 2
self.setGeometry(newLeft,newTop,500,600)
self.setWindowTitle("按鍵助手V0.1")
self.setWindowFlags(Qt.WindowStaysOnTopHint)
self.lineEdit_1 = QLineEdit()
self.lineEdit_2 = QLineEdit()
self.xlable = QLabel("X實(shí)時(shí)坐標(biāo)")
self.ylable = QLabel("Y實(shí)時(shí)坐標(biāo)")
self.lineEdit_1.setReadOnly(True)
self.lineEdit_2.setReadOnly(True)
self.okButton = QPushButton("導(dǎo)出規(guī)則")
#self.okButton.clicked.connect()
hbox = QHBoxLayout()
hbox.addWidget(self.xlable)
hbox.addWidget(self.lineEdit_1)
hbox.addWidget(self.ylable)
hbox.addWidget(self.lineEdit_2)
hbox.addWidget(self.okButton)
h2box = QHBoxLayout()
QCURN=QLabel('''<font color=red face='宋體' size=5>F2 按鍵記錄鼠標(biāo)位置<font>''')
self.stratButton = QPushButton("運(yùn)行")
self.clearButton = QPushButton("清除全部數(shù)據(jù)")
h2box.addWidget(QCURN)
h2box.addWidget(self.clearButton)
h2box.addWidget(self.stratButton)
vbox =QVBoxLayout()
vbox.addLayout(hbox)
vbox.addLayout(h2box)
self.tableWidget = QTableWidget(0,5)
self.tableWidget.setHorizontalHeaderLabels(['X坐標(biāo)','y坐標(biāo)','事件','延時(shí)ms(默認(rèn)600)','循環(huán)次數(shù)(默認(rèn)1次)'])
vbox.addWidget(self.tableWidget)
self.setLayout(vbox)
self.clearButton.clicked.connect(lambda:self.tableWidget.setRowCount(0))
self.stratButton.clicked.connect(self.thread3)
'''