Design study https://qiita.com/asahi4549/items/b63affa193a2f422586a I tried to implement it based on.
AK003_V1002.py
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 16 19:37:35 2020
Program memo
note :I created a gui in MainWindow with Qt desiner, so Ui_Different from Form
note:imported.Give a class name when calling an object on a py file
@author: asahi
"""
import os #Like when getting the file name from path
import sys #System module
import re #Regular expression module
from PyQt5 import QtWidgets,QtCore
from PyQt5.QtWidgets import QMainWindow
from PyQt5.QtWidgets import QMessageBox
from AK003_V1001ui import Ui_MainWindow
import AK003_V1001_func as pc_op
import pathlib #For converting absolute path to relative path
import time #Required for timeout
import threading
import pyautogui as pg #To close all windows
#Success / Failure Definition
SUCCESS = True
FAIL = False
class AK003(QMainWindow, Ui_MainWindow):
def __init__(self,parent=None):
super(AK003, self).__init__(parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
#Modeling listview
self.list_model = QtCore.QStringListModel()
#Function execution list
self.list_exec_func = []
#List for function arguments
self.list_exec_args = []
#Code text reading
default_code_path = "./code/default.txt"
#code_file open of path
#It will be closed automatically by using with
with open(default_code_path ) as df_code_file:
#Get the entire text
default_code = df_code_file.read()
#print(default_code)
#Set the acquired text as code text
self.ui.plainTextEdit_code_text.appendPlainText(default_code)
#Read initial image folder
#Get filename from defalutpath
self.dir_path_rel = "./picture/grope_0"
file_name = os.listdir(self.dir_path_rel)
#file_name = os.path.basename(file_path)
print(file_name)
#.Set png file name to Picture list
#Add filename to list model
#self.list_model.setStringList([file_name])
self.list_model.setStringList(file_name)
#Add list model to list view
#It will be reflected in the widget by adding it to the list view
self.ui.listView_picture_list.setModel(self.list_model)
#note
def click_read_file(self):
#Displaying the file open dialog
#(file_path, selectedFilter) = QtWidgets.QFileDialog.getOpenFileName(self,filter="png jpeg (*.png *.jpeg)")
#Change to select only folders
#The second argument is the title of the dialog,The third argument is the path you want to initially display
dir_path_tmp = QtWidgets.QFileDialog.getExistingDirectory(self, 'Open Directory', "./picture")
if(dir_path_tmp != ""):
#path_abs is absolute path
path_abs = pathlib.Path(dir_path_tmp)
#relative_Convert to relative path with to,The argument is the starting path
#path_abs.cwd()Get the path of the current directory with
self.dir_path_rel = path_abs.relative_to( path_abs.cwd() )
#Get file name from path
file_name = os.listdir(self.dir_path_rel)
#file_name = os.path.basename(file_path)
print(file_name)
#.Set png file name to Picture list
#Add filename to list model
#self.list_model.setStringList([file_name])
self.list_model.setStringList(file_name)
#Add list model to list view
#It will be reflected in the widget by adding it to the list view
self.ui.listView_picture_list.setModel(self.list_model)
def click_execute(self):
#code_text analysis processing
#get string of code text
code = self.ui.plainTextEdit_code_text.toPlainText()
#Pass code as an argument to the grammar check function. check_Perform line break judgment in syntax and extract instructions
#I have to pass self as an argument,I can't handle ui variables
syntax_result = Check_syntax(self,code)
#If there is no problem with the text code, execute the execution list
if(syntax_result != FAIL):
self.ui.plainTextEdit_result.appendPlainText("executed successfully")
#Display desktop screen
msg_ret = QMessageBox.question(None,"Verification","Are you sure you want to run the automation program??", QMessageBox.Ok,QMessageBox.Cancel )
if(msg_ret != QMessageBox.Cancel ):
#Execute the execution list from the top
pg.sleep(2)
QMessageBox.information(None, "information","This screen should be displayed 2 seconds after displaying the desktop screen")
args_cnt = 0
for func in self.list_exec_func:
exec_handler(self,func, self.list_exec_args[args_cnt])
time.sleep(0.5)
args_cnt = args_cnt + 1
#Clear the array for execution
#Don't leave the previous instruction when executing the second code
self.list_exec_func.clear()
self.list_exec_args.clear()
else:
self.ui.plainTextEdit_result.appendPlainText("program cancelled")
return
#Error handling when grammar check is ng
else:
self.ui.plainTextEdit_result.appendPlainText("execution failure")
return
def click_save_code(self):
#code_Get string from txt
code = self.ui.plainTextEdit_code_text.toPlainText()
#Get save file name
(file_name_path, selectedFilter) = QtWidgets.QFileDialog.getSaveFileName(self, 'Open Directory', './code')
if(file_name_path != ''):
#Get file name from path
file_name = os.path.basename(file_name_path)
self.ui.plainTextEdit_result.appendPlainText(file_name+"Saved")
#Export the acquired character string to the file you want to tenon
#It will be closed automatically by using with
with open('./code/'+file_name,"w" ) as save_code_file:
save_code_file.write(code)
#Callback function
def exec_handler(self,func , *arg):
func(self,*arg)
#Grammar check function
def Check_syntax(self,txt_code):
#Extract instructions up to the line feed character string
list_code_tmp = []
#I tried to get the location of a specific character string and delete it so far, but since there was a function to list with line breaks, I will use that
#List by line break
list_code_tmp = txt_code.splitlines()
print(list_code_tmp)
#Check the grammar of the contents of the code list from above
for code in list_code_tmp: #Extract the character of click with a regular expression
#note:Does match match from the first character?
if(re.match('click',code)):
#note Add characters without erasing past characters
#There is also setPlainText, but this ignores past characters
#self.ui.plainTextEdit_result.appendPlainText(code_tmp)
#()Is there
#note()Is also one of the regular expressions\Escaped with
#(From)Extract the end of characters ending with
ob_recode_tmp = re.search('\(.*\)',code)
print(ob_recode_tmp)
#()Error handling if is not found
#note Use is to determine object match
if(ob_recode_tmp is not None):
#group()Extract the string matched by
code_tmp = ob_recode_tmp.group()
#Argument cod_Extract arg
#note 0th character and-Extract other than the first character
code_arg = code_tmp[1:-1]
print(code_arg)
#Since the argument of click is given by the image id, list the id_Make it a member of the model index and list_Get the data in the model
#Specify index.You can get the data registered in the list model with data
#Since the argument of index is int, it is converted to int
code_arg = self.list_model.index(int(code_arg),0).data()
#Search for arguments in selectpicture
#note string List with list_Extract list from model,
#Perform an exact match search from if in. Use the match function if you want to determine if even one character matches
str_list = self.list_model.stringList()
#str_code in list_Determine if there is arg
if code_arg in str_list:
self.ui.plainTextEdit_result.appendPlainText("Image found")
#Add click to execution list
self.list_exec_func.append(pc_op.click)
self.list_exec_args.append(code_arg)
else:
self.ui.plainTextEdit_result.appendPlainText("Incorrect argument")
return FAIL
else:
self.ui.plainTextEdit_result.appendPlainText("()there is not")
return FAIL
elif(re.match('dclick',code)):
#note Add characters without erasing past characters
#There is also setPlainText, but this ignores past characters
#self.ui.plainTextEdit_result.appendPlainText(code_tmp)
#()Is there
#note()Is also one of the regular expressions\Escaped with
#(From)Extract the end of characters ending with
ob_recode_tmp = re.search('\(.*\)',code)
print(ob_recode_tmp)
#()Error handling if is not found
#note Use is to determine object match
if(ob_recode_tmp is not None):
#group()Extract the string matched by
code_tmp = ob_recode_tmp.group()
#Argument cod_Extract arg
#note 0th character and-Extract other than the first character
code_arg = code_tmp[1:-1]
print(code_arg)
#Since the argument of click is given by the image id, list the id_Make it a member of the model index and list_Get the data in the model
#Specify index.You can get the data registered in the list model with data
#Since the argument of index is int, it is converted to int
code_arg = self.list_model.index(int(code_arg),0).data()
#Search for arguments in selectpicture
#note string List with list_Extract list from model,
#Perform an exact match search from if in. Use the match function if you want to determine if even one character matches
str_list = self.list_model.stringList()
#str_code in list_Determine if there is arg
if code_arg in str_list:
self.ui.plainTextEdit_result.appendPlainText("Image found")
#Add dclick and its arguments to the execution list
self.list_exec_func.append(pc_op.dclick)
self.list_exec_args.append(code_arg)
else:
self.ui.plainTextEdit_result.appendPlainText("Incorrect argument")
return FAIL
else:
self.ui.plainTextEdit_result.appendPlainText("()there is not")
return FAIL
elif(re.match('typekey',code)):
#()Is there
#note()Is also one of the regular expressions\Escaped with
#(From)Extract the end of characters ending with
ob_recode_tmp = re.search('\(.*\)',code)
#()Error handling if is not found
#note Use is to determine object match
if(ob_recode_tmp is not None):
#group()Extract the string matched by
code_tmp = ob_recode_tmp.group()
#Argument cod_Extract arg
#note 0th character and-Extract other than the first character
code_arg = code_tmp[1:-1]
print(code_arg)
#Add typekey function and its arguments to the execution list
self.list_exec_func.append(pc_op.typekey)
self.list_exec_args.append(code_arg)
else:
self.ui.plainTextEdit_result.appendPlainText("()there is not")
return FAIL
elif(re.match('wait',code)):
#()Is there
#note()Is also one of the regular expressions\Escaped with
#(From)Extract the end of characters ending with
ob_recode_tmp = re.search('\(.*\)',code)
#()Error handling if is not found
#note Use is to determine object match
if(ob_recode_tmp is not None):
#group()Extract the string matched by
code_tmp = ob_recode_tmp.group()
#Argument cod_Extract arg
#note 0th character and-Extract other than the first character
code_arg = code_tmp[1:-1]
#Add typekey function and its arguments to the execution list
self.list_exec_func.append(pc_op.wait)
self.list_exec_args.append(code_arg)
else:
self.ui.plainTextEdit_result.appendPlainText("()there is not")
return FAIL
elif(re.match('enter',code)):
self.list_exec_func.append(pc_op.enter)
code_arg = 0
self.list_exec_args.append(code_arg)
elif(re.match('desktop',code)):
self.list_exec_func.append(pc_op.desktop)
code_arg = 0
self.list_exec_args.append(code_arg)
else:
self.ui.plainTextEdit_result.appendPlainText("invalid function")
return FAIL
return SUCCESS
#Main function
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
window = AK003()
window.show()
sys.exit(app.exec_())
AK003_V1001ui.py
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'AK003_V1001ui.ui'
#
# Created by: PyQt5 UI code generator 5.9.2
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(508, 493)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.frame = QtWidgets.QFrame(self.centralwidget)
self.frame.setGeometry(QtCore.QRect(10, 0, 261, 221))
self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame.setObjectName("frame")
self.plainTextEdit_code_text = QtWidgets.QPlainTextEdit(self.frame)
self.plainTextEdit_code_text.setGeometry(QtCore.QRect(20, 60, 231, 151))
self.plainTextEdit_code_text.setObjectName("plainTextEdit_code_text")
self.label_2 = QtWidgets.QLabel(self.frame)
self.label_2.setGeometry(QtCore.QRect(20, 40, 71, 16))
font = QtGui.QFont()
font.setFamily("Segoe UI")
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.pushButton__execute = QtWidgets.QPushButton(self.frame)
self.pushButton__execute.setGeometry(QtCore.QRect(140, 10, 111, 23))
font = QtGui.QFont()
font.setFamily("Segoe UI")
self.pushButton__execute.setFont(font)
self.pushButton__execute.setObjectName("pushButton__execute")
self.frame_4 = QtWidgets.QFrame(self.frame)
self.frame_4.setGeometry(QtCore.QRect(10, 290, 471, 291))
self.frame_4.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame_4.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame_4.setObjectName("frame_4")
self.pushButton_read_picture_2 = QtWidgets.QPushButton(self.frame_4)
self.pushButton_read_picture_2.setGeometry(QtCore.QRect(20, 10, 111, 23))
font = QtGui.QFont()
font.setFamily("Segoe UI")
self.pushButton_read_picture_2.setFont(font)
self.pushButton_read_picture_2.setObjectName("pushButton_read_picture_2")
self.plainTextEdit_code_text_2 = QtWidgets.QPlainTextEdit(self.frame_4)
self.plainTextEdit_code_text_2.setGeometry(QtCore.QRect(20, 70, 211, 181))
self.plainTextEdit_code_text_2.setObjectName("plainTextEdit_code_text_2")
self.label_15 = QtWidgets.QLabel(self.frame_4)
self.label_15.setGeometry(QtCore.QRect(20, 50, 71, 16))
font = QtGui.QFont()
font.setFamily("Segoe UI")
self.label_15.setFont(font)
self.label_15.setObjectName("label_15")
self.pushButton__execute_2 = QtWidgets.QPushButton(self.frame_4)
self.pushButton__execute_2.setGeometry(QtCore.QRect(20, 260, 111, 23))
font = QtGui.QFont()
font.setFamily("Segoe UI")
self.pushButton__execute_2.setFont(font)
self.pushButton__execute_2.setObjectName("pushButton__execute_2")
self.pushButton__execute_3 = QtWidgets.QPushButton(self.frame)
self.pushButton__execute_3.setGeometry(QtCore.QRect(20, 10, 111, 23))
font = QtGui.QFont()
font.setFamily("Segoe UI")
self.pushButton__execute_3.setFont(font)
self.pushButton__execute_3.setObjectName("pushButton__execute_3")
self.frame_2 = QtWidgets.QFrame(self.centralwidget)
self.frame_2.setGeometry(QtCore.QRect(280, 0, 211, 221))
self.frame_2.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame_2.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame_2.setObjectName("frame_2")
self.label = QtWidgets.QLabel(self.frame_2)
self.label.setGeometry(QtCore.QRect(40, 40, 71, 16))
font = QtGui.QFont()
font.setFamily("Segoe UI")
self.label.setFont(font)
self.label.setObjectName("label")
self.listView_picture_list = QtWidgets.QListView(self.frame_2)
self.listView_picture_list.setGeometry(QtCore.QRect(40, 60, 161, 151))
self.listView_picture_list.setObjectName("listView_picture_list")
self.label_8 = QtWidgets.QLabel(self.frame_2)
self.label_8.setGeometry(QtCore.QRect(10, 40, 21, 16))
font = QtGui.QFont()
font.setFamily("Segoe UI")
self.label_8.setFont(font)
self.label_8.setObjectName("label_8")
self.label_9 = QtWidgets.QLabel(self.frame_2)
self.label_9.setGeometry(QtCore.QRect(10, 60, 21, 21))
font = QtGui.QFont()
font.setFamily("Segoe UI")
self.label_9.setFont(font)
self.label_9.setObjectName("label_9")
self.label_10 = QtWidgets.QLabel(self.frame_2)
self.label_10.setGeometry(QtCore.QRect(10, 80, 21, 21))
font = QtGui.QFont()
font.setFamily("Segoe UI")
self.label_10.setFont(font)
self.label_10.setObjectName("label_10")
self.label_11 = QtWidgets.QLabel(self.frame_2)
self.label_11.setGeometry(QtCore.QRect(10, 100, 21, 21))
font = QtGui.QFont()
font.setFamily("Segoe UI")
self.label_11.setFont(font)
self.label_11.setObjectName("label_11")
self.label_12 = QtWidgets.QLabel(self.frame_2)
self.label_12.setGeometry(QtCore.QRect(10, 120, 21, 21))
font = QtGui.QFont()
font.setFamily("Segoe UI")
self.label_12.setFont(font)
self.label_12.setObjectName("label_12")
self.label_13 = QtWidgets.QLabel(self.frame_2)
self.label_13.setGeometry(QtCore.QRect(10, 140, 21, 21))
font = QtGui.QFont()
font.setFamily("Segoe UI")
self.label_13.setFont(font)
self.label_13.setObjectName("label_13")
self.pushButton_read_picture = QtWidgets.QPushButton(self.frame_2)
self.pushButton_read_picture.setGeometry(QtCore.QRect(40, 10, 111, 23))
font = QtGui.QFont()
font.setFamily("Segoe UI")
self.pushButton_read_picture.setFont(font)
self.pushButton_read_picture.setObjectName("pushButton_read_picture")
self.frame_5 = QtWidgets.QFrame(self.centralwidget)
self.frame_5.setGeometry(QtCore.QRect(10, 230, 481, 101))
self.frame_5.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame_5.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame_5.setObjectName("frame_5")
self.label_3 = QtWidgets.QLabel(self.frame_5)
self.label_3.setGeometry(QtCore.QRect(20, 0, 71, 16))
font = QtGui.QFont()
font.setFamily("Segoe UI")
self.label_3.setFont(font)
self.label_3.setObjectName("label_3")
self.plainTextEdit_result = QtWidgets.QPlainTextEdit(self.frame_5)
self.plainTextEdit_result.setGeometry(QtCore.QRect(20, 20, 451, 71))
self.plainTextEdit_result.setObjectName("plainTextEdit_result")
self.frame_3 = QtWidgets.QFrame(self.centralwidget)
self.frame_3.setGeometry(QtCore.QRect(10, 340, 481, 111))
self.frame_3.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame_3.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame_3.setObjectName("frame_3")
self.label_4 = QtWidgets.QLabel(self.frame_3)
self.label_4.setGeometry(QtCore.QRect(20, 10, 71, 16))
font = QtGui.QFont()
font.setFamily("Segoe UI")
self.label_4.setFont(font)
self.label_4.setObjectName("label_4")
self.label_5 = QtWidgets.QLabel(self.frame_3)
self.label_5.setGeometry(QtCore.QRect(20, 30, 251, 16))
font = QtGui.QFont()
font.setFamily("Segoe UI")
self.label_5.setFont(font)
self.label_5.setObjectName("label_5")
self.label_6 = QtWidgets.QLabel(self.frame_3)
self.label_6.setGeometry(QtCore.QRect(20, 70, 201, 16))
font = QtGui.QFont()
font.setFamily("Segoe UI")
self.label_6.setFont(font)
self.label_6.setObjectName("label_6")
self.label_7 = QtWidgets.QLabel(self.frame_3)
self.label_7.setGeometry(QtCore.QRect(20, 50, 321, 16))
font = QtGui.QFont()
font.setFamily("Segoe UI")
self.label_7.setFont(font)
self.label_7.setObjectName("label_7")
self.label_14 = QtWidgets.QLabel(self.frame_3)
self.label_14.setGeometry(QtCore.QRect(20, 90, 191, 16))
font = QtGui.QFont()
font.setFamily("Segoe UI")
self.label_14.setFont(font)
self.label_14.setObjectName("label_14")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 508, 21))
self.menubar.setObjectName("menubar")
self.menuFile = QtWidgets.QMenu(self.menubar)
self.menuFile.setObjectName("menuFile")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.menubar.addAction(self.menuFile.menuAction())
self.retranslateUi(MainWindow)
self.pushButton__execute.clicked.connect(MainWindow.click_execute)
self.pushButton__execute_3.clicked.connect(MainWindow.click_save_code)
self.pushButton_read_picture.clicked.connect(MainWindow.click_read_file)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.label_2.setText(_translate("MainWindow", "Code text"))
self.pushButton__execute.setText(_translate("MainWindow", "Execute"))
self.pushButton_read_picture_2.setText(_translate("MainWindow", "Read picture"))
self.label_15.setText(_translate("MainWindow", "Code text"))
self.pushButton__execute_2.setText(_translate("MainWindow", "Execute"))
self.pushButton__execute_3.setText(_translate("MainWindow", "Save code"))
self.label.setText(_translate("MainWindow", "Picture list"))
self.label_8.setText(_translate("MainWindow", "ID"))
self.label_9.setText(_translate("MainWindow", "0"))
self.label_10.setText(_translate("MainWindow", "1"))
self.label_11.setText(_translate("MainWindow", "2"))
self.label_12.setText(_translate("MainWindow", "3"))
self.label_13.setText(_translate("MainWindow", "..."))
self.pushButton_read_picture.setText(_translate("MainWindow", "Read picture"))
self.label_3.setText(_translate("MainWindow", "Result"))
self.label_4.setText(_translate("MainWindow", "Function list"))
self.label_5.setText(_translate("MainWindow", "click(Picture list ID)・ ・ ・ Click the corresponding image"))
self.label_6.setText(_translate("MainWindow", "typekey(Sentence)・・・Sentenceを入力します"))
self.label_7.setText(_translate("MainWindow", "double_click(Picture list ID)・ ・ ・ Double-click the corresponding image"))
self.label_14.setText(_translate("MainWindow", "enter ・ ・ ・ press enter key"))
self.menuFile.setTitle(_translate("MainWindow", "File"))
AK003_V1001func.py
# -*- coding: utf-8 -*-
"""
Created on Sun Dec 27 16:27:00 2020
@author: asahi
"""
import time
import pyautogui as pg
import threading
def click(self,args):
print("click was called argument{}".format(args))
#state_search = 'STATE_SEARCH_CHROME'
#Returns the coordinate system of where the search image was found
nsec = 0
timeout = 5
while True:
#state_search = 'STATE_SEARCH_CHROME'
#Returns the coordinate system of where the search image was found
#button_position = get_locate_from_filename(args)
#pg.hotkey doesn't work right away?
#note
#.Is the folder where the python files are(Current directory)And take the image in the picture folder as an argument
#+You can expand variables in strings by using
#print(str(self.dir_path_rel)+"\\"+args)
#print("./picture/grope_0/"+args)
#dir_path_rel is the windows path(¥¥)Because it is a notation+Cannot be connected with
#So use str to convert it to a string
button_position = get_locate_from_filename("./"+str(self.dir_path_rel)+"/"+args)
#button_position = get_locate_from_filename("./picture/grope_0/"+args)
#button_position = get_locate_from_filename("C:/Users/asahi/Documents/30_business/40_Improvement proposal/FF_kitada/00_program/AK003_V1001/picture/grope_0/chrome.png ")
if(button_position != None):
#pg.click(button_position)
print("button_position = {}".format(button_position) )
pg.click(button_position)
break
else:
time.sleep(0.5)
print("I will look for it again")
nsec += 1
if( nsec > timeout):
pg.alert(text = 'time out', button ='OK')
break
def dclick(self,args):
print("dclick was called argument{}".format(args))
#state_search = 'STATE_SEARCH_CHROME'
#Returns the coordinate system of where the search image was found
nsec = 0
timeout = 5
print(str(self.dir_path_rel))
while True:
button_position = get_locate_from_filename("./"+str(self.dir_path_rel)+"/"+args)
if(button_position != None):
print("button_position = {}".format(button_position) )
pg.doubleClick(button_position)
break
else:
time.sleep(0.5)
print("I will look for it again")
nsec += 1
if( nsec > timeout):
pg.alert(text = 'time out', button ='OK')
break
def typekey(self,args):
print("typekey was called argument{}".format(args))
pg.typewrite(args)
def enter(self,args):
print("enter was called argument{}".format(args))
pg.press('enter',presses = 2, interval = 0.5)
def wait(self,args):
print("wait was called argument{}".format(args))
#I'm casting because the argument of sleep must be an int
time.sleep(int(args))
def press_key(self,args):
print("press_key was called")
pass
def desktop(self,args):
print("desktop was called")
pg.hotkey('win','d')
#Processing to get coordinates from image file
def get_locate_from_filename(filename):
locate = None
time.sleep(1)
#95 with grayscale processing%Match judgment
#Get coordinates of search image
print(filename)
try:
locate = pg.locateCenterOnScreen(filename,grayscale = True,confidence=0.8)
return locate
except:
print("No image")
return False