Skip to content

Commit

Permalink
V1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
lissettecarlr committed Dec 24, 2021
1 parent d802d09 commit 6b0260a
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 36 deletions.
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ pip install -r requirements.txt
|---|---|
|true|存在|
|false|不存在|
|end|结束判断|


* 参数4:如果是按键则其值就为键值或文本,如果是鼠标则值为横坐标,纵坐标,如果是寻找图片,则是其地址
Expand Down Expand Up @@ -148,9 +149,13 @@ pip install -r requirements.txt
图片判断示例:
```
[3000,"ifpic","True","./scripts/youdao.png"],
[100,"keyboard","txt","find it"],
[100,"keyboard","down","1"],
[100,"keyboard","up","1"],
[0,"ifpic","end",""],
[3000,"ifpic","False","./scripts/youdao.png"],
[100,"keyboard","txt","not find"],
[100,"keyboard","down","2"],
[100,"keyboard","up","2"],
[0,"ifpic","end",""],
[100,"keyboard","txt","over"]
```

Expand All @@ -164,9 +169,11 @@ pyinstaller -Fw .\autogui.py --paths="C:\Users\dell\AppData\Local\Programs\Pytho
## 版本说明

### v1.5
增加按键,刷新脚本选择下拉框X
配置文件中增加脚本路径的字段X
增加按键,刷新脚本选择下拉框
配置文件中增加脚本路径的字段
帮助里添加脚本编写说明网页快链
现在picif下面可以增加多条语句
处理了UI显示当前执行命令不完整的问题

### V1.4
增加了图片识别判断语句
Expand Down
16 changes: 16 additions & 0 deletions exampleScripts/WOW-SM-debug.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
[1000,"ifpic","True","1.png"],
[100,"keyboard","down","1"],
[81,"keyboard","up","1"],
[1000,"ifpic","True","2.png"],
[1000,"keyboard","down","2"],
[81,"keyboard","up","2"],
[100,"ifpic","True","3.png"],
[1000,"keyboard","down","3"],
[81,"keyboard","up","3"],
[100,"ifpic","True","4.png"],
[1000,"keyboard","down","4"],
[81,"keyboard","up","4"],
[100,"keyboard","down","5"],
[81,"keyboard","up","5"],
]
11 changes: 11 additions & 0 deletions exampleScripts/图片查找示例.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
[3000,"ifpic","True","./scripts/youdao.png"],
[100,"keyboard","down","1"],
[100,"keyboard","up","1"],
[0,"ifpic","end",""],
[3000,"ifpic","False","./scripts/youdao.png"],
[100,"keyboard","down","2"],
[100,"keyboard","up","2"],
[0,"ifpic","end",""],
[100,"keyboard","txt","over"]
]
50 changes: 29 additions & 21 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ def close(self):
self.closeFlag = False

def getNowCmdLog(self):
return self.nowCmdLog
#缩减长度不然显示不完整
temp = str(self.nowCmdLog).replace("\"","")
temp = temp.replace("\'","")
temp = temp.strip("[")
temp = temp.strip("]")
return temp

def getFlag(self):
return self.flag
Expand Down Expand Up @@ -149,9 +154,11 @@ def runScripts(self):
if(self.closeFlag == False or self.flag == False): #如果中途退出,则不在执行脚本了
logger.info("scripts exit")
return True
# 是否不执行当前命令
if(isContinue == True):
# 是否不执行当前命令
if(s[i][1] == "ifpic" and s[i][2] == "end"):
isContinue = False
if(isContinue == True):
logger.info("jump"+ str(s[i]))
continue

self.nowCmdLog = s[i]
Expand Down Expand Up @@ -233,24 +240,25 @@ def runScripts(self):
self.status = "当前语句执行错误,状态未知"
# 判断图标是否存在的条件语句
elif(taskType == "ifpic"):
try:
picPos=pyautogui.locateCenterOnScreen(msg,confidence=self.pifConfidence)
except:
self.suspend()
self.status = "[E]判断图语句执行错误,已停止"
logger.error("ifpic script error")
return True
if(picPos == None):
logger.error("not find pic : " + msg)
if(sta == "True" and picPos != None):
logger.info("ifpic is OK1")
isContinue = False
elif(sta == "False" and picPos == None):
logger.info("ifpic is OK2")
isContinue = False
else:
logger.info("ifpic is NOT")
isContinue = True
if(sta != "end"):
try:
picPos=pyautogui.locateCenterOnScreen(msg,confidence=self.pifConfidence)
except:
self.suspend()
self.status = "[E]判断图语句执行错误,已停止"
logger.error("ifpic script error")
return True
if(picPos == None):
logger.error("not find pic : " + msg)
if(sta == "True" and picPos != None):
logger.info("ifpic is OK1")
isContinue = False
elif(sta == "False" and picPos == None):
logger.info("ifpic is OK2")
isContinue = False
else:
logger.info("ifpic is NOT")
isContinue = True
else:
logger.error("script error:taskType")
self.status = "当前语句执行错误,类型未知"
Expand Down
14 changes: 6 additions & 8 deletions wincore.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def __init__(self):
super(wincore,self).__init__()
self.setupUi(self)
self.init()


#读取config.ini中的配置
def readConfig(self):
try:
logger.info("read config.....")
Expand Down Expand Up @@ -92,19 +93,14 @@ def init(self):
self.refresh.triggered.connect(self.reloadScriptsList)
self.NetExample.triggered.connect(self.netExample)
self.NetScriptsHelp.triggered.connect(self.netScriptsHelp)

# 实例脚本执行器
self.runnerThread = run.Runner()
self.runnerThread.start()

#默认值
self.setCycleCount("1")

#状态更新定时器
# 定时器
self.timer = QTimer() # 初始化定时器
self.timer.timeout.connect(self.statusUpdate)

#开启监听
hm = pyWinhook.HookManager()
#键盘
Expand All @@ -114,6 +110,7 @@ def init(self):
hm.MouseAll = self.onMouseEvent
hm.HookMouse()

#重新加载脚本列表
def reloadScriptsList(self):
self.comboBox.clear()
#for file in os.listdir("./scripts"):
Expand Down Expand Up @@ -301,8 +298,9 @@ def openConfig(self):
thread.start()
else:
logger.info("open config fail,creat")
cfg = "[runCfg]\nConfidence = 0.7\n\n[winCfg]\nmouseCmdInterval = 200\nstartKey = \"F9\"\nstopKey = \"F10\"\ncaptureKey = \"F8\"\nstopRecordKey = \"F7\""
open("config.ini","w").write(cfg)
runCfgTxt = "[runCfg]\nConfidence = 0.7\n\n"
winCfgTxt = "[winCfg]\nmouseCmdInterval = 200\nstartKey = \"F9\"\nstopKey = \"F10\"\ncaptureKey = \"F8\"\nstopRecordKey = \"F7\"\nscriptsPath = \"./scripts/\""
open("config.ini","w").write(runCfgTxt + winCfgTxt)
thread = threading.Thread(target=openTxt)
thread.start()

Expand Down
6 changes: 3 additions & 3 deletions winshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# run again. Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5 import QtCore, QtWidgets


class Ui_MainWindow(object):
Expand Down Expand Up @@ -55,7 +55,7 @@ def setupUi(self, MainWindow):
self.lineEdit.setObjectName("lineEdit")
self.horizontalLayout_2.addWidget(self.lineEdit)
self.label_2 = QtWidgets.QLabel(self.horizontalLayoutWidget_2)
self.label_2.setMaximumSize(QtCore.QSize(60, 16777215))
self.label_2.setMaximumSize(QtCore.QSize(40, 16777215))
self.label_2.setObjectName("label_2")
self.horizontalLayout_2.addWidget(self.label_2)
self.label_3 = QtWidgets.QLabel(self.horizontalLayoutWidget_2)
Expand Down Expand Up @@ -167,7 +167,7 @@ def retranslateUi(self, MainWindow):
self.pushButton.setText(_translate("MainWindow", "开始(F9)"))
self.pushButton_2.setText(_translate("MainWindow", "停止(F10)"))
self.label.setText(_translate("MainWindow", "循环次数:"))
self.label_2.setText(_translate("MainWindow", "当前指令:"))
self.label_2.setText(_translate("MainWindow", "指令:"))
self.label_4.setText(_translate("MainWindow", "鼠标坐标:"))
self.label_6.setText(_translate("MainWindow", "F8单次抓取"))
self.pushButton_3.setText(_translate("MainWindow", "抓取"))
Expand Down

0 comments on commit 6b0260a

Please sign in to comment.