From 16cd26896014c1e4d7924309b09dae304a6f3fa4 Mon Sep 17 00:00:00 2001 From: Ivan Maslov Date: Sun, 14 Jul 2019 10:46:06 +0300 Subject: [PATCH] =?UTF-8?q?#WaitAppear=5FFix=20#WaitDisappear=5FNewFeature?= =?UTF-8?q?=20#WaitDisappear=5FList=5FNewFeature=20#GetUIOList=5FFix=20#St?= =?UTF-8?q?udioAddLinkToUnicodeLabsSite=20#RobotCalledLogger=5FRobotLogger?= =?UTF-8?q?=20#Clipboard=5FFix=20#WaitAppear=5FFix=20-=20(=D0=9F=D0=BE?= =?UTF-8?q?=D0=B8=D1=81=D0=BA=20=D0=BF=D0=BE=20=D1=8D=D0=BB=D0=B5=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D1=82=D1=83=20=D0=BF=D0=B5=D1=80=D0=B5=D1=82=D0=B8?= =?UTF-8?q?=D1=80=D0=B0=D0=BB=20backend=20=D0=B8=D0=B7-=D0=B7=D0=B0=20?= =?UTF-8?q?=D1=82=D0=BE=D0=B3=D0=BE,=20=D1=87=D1=82=D0=BE=20=D0=BE=D0=BD?= =?UTF-8?q?=20=D0=BC=D0=B5=D1=88=D0=B0=D0=B5=D1=82=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D0=B2=D0=BD=D1=83=D1=82=D1=80=D0=B5=D0=BD=D0=BD=D0=B5=D0=BC=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=D0=B5)=20#GetUIOList=5FFix=20-?= =?UTF-8?q?=20(=D0=9D=D0=B5=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=B5=D1=82?= =?UTF-8?q?=20=D0=BD=D0=B8=D0=BA=D0=B0=D0=BA=D0=B8=D1=85=20=D0=B8=D1=81?= =?UTF-8?q?=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D0=B9,=20=D0=B5?= =?UTF-8?q?=D1=81=D0=BB=D0=B8=20=D0=B2=D1=85=D0=BE=D0=B4=D0=BD=D0=BE=D0=B9?= =?UTF-8?q?=20=D1=84=D0=BB=D0=B0=D0=B3=20=D0=BD=D0=B5=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D1=81=D0=B8=D1=82=20=D1=81=D0=BE=D0=B7=D1=85=D0=B4=D0=B0=D0=B2?= =?UTF-8?q?=D0=B0=D1=82=D1=8C=20=D0=B8=D1=81=D0=BA=D0=BB=D1=8E=D1=87=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B9)=20#Clipboard=5FFix=20-=20(=D0=A1=D0=B8?= =?UTF-8?q?=D0=BD=D1=85=D1=80=D0=BE=D0=BD=D0=B8=D0=B7=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=BF=D0=BE=D0=B4=20=D0=B5=D0=B4=D0=B8=D0=BD=D1=83?= =?UTF-8?q?=D1=8E=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8E=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20=D1=81=20=D0=B1=D1=83=D1=84?= =?UTF-8?q?=D1=84=D0=B5=D1=80=D0=BE=D0=BC=20(SetClipboardText=20->=20SetCl?= =?UTF-8?q?iopboardData))?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ivan Maslov --- Robot/Clipboard.py | 4 +- .../Examples/PythonDebug_32_ScriptTestGUI.cmd | 3 + Robot/Examples/ScriptTestGUI.py | 15 ++++ Robot/GUI.py | 82 +++++++++++++++++-- Studio/Web/Index.xhtml | 4 +- 5 files changed, 99 insertions(+), 9 deletions(-) create mode 100644 Robot/Examples/PythonDebug_32_ScriptTestGUI.cmd create mode 100644 Robot/Examples/ScriptTestGUI.py diff --git a/Robot/Clipboard.py b/Robot/Clipboard.py index d081e55c..12b43186 100644 --- a/Robot/Clipboard.py +++ b/Robot/Clipboard.py @@ -9,7 +9,7 @@ import win32clipboard ################ def ClipboardGet(): win32clipboard.OpenClipboard() - lResult = win32clipboard.GetClipboardData() + lResult = win32clipboard.GetClipboardData(win32clipboard.CF_UNICODETEXT) win32clipboard.CloseClipboard() return lResult ################ @@ -18,5 +18,5 @@ def ClipboardGet(): def ClipboardSet(inText): win32clipboard.OpenClipboard() win32clipboard.EmptyClipboard() - win32clipboard.SetClipboardText(inText) + win32clipboard.SetClipboardData(win32clipboard.CF_UNICODETEXT,inText) win32clipboard.CloseClipboard() diff --git a/Robot/Examples/PythonDebug_32_ScriptTestGUI.cmd b/Robot/Examples/PythonDebug_32_ScriptTestGUI.cmd new file mode 100644 index 00000000..1de6dbbf --- /dev/null +++ b/Robot/Examples/PythonDebug_32_ScriptTestGUI.cmd @@ -0,0 +1,3 @@ +cd %~dp0 +.\..\..\Resources\WPy32-3720\python-3.7.2\python.exe ScriptTestGUI.py +pause >nul \ No newline at end of file diff --git a/Robot/Examples/ScriptTestGUI.py b/Robot/Examples/ScriptTestGUI.py new file mode 100644 index 00000000..ba554883 --- /dev/null +++ b/Robot/Examples/ScriptTestGUI.py @@ -0,0 +1,15 @@ +import sys +sys.path.append('../') +import GUI +import keyboard +import time +lI=0 +lResult=GUI.UIOSelectorsSecs_WaitDisappear_List( + [ + [{"title":"PuTTY Configuration","class_name":"PuTTYConfigBox","backend":"uia"},{"ctrl_index":20},{"ctrl_index":2}], + [{"title":"OpenRPA","class_name":"CabinetWClass","backend":"uia"},{"ctrl_index":2},{"ctrl_index":0},{"ctrl_index":2},{"ctrl_index":0},{"ctrl_index":7},{"ctrl_index":2}] + ], + 60, + True +) +print(lResult) \ No newline at end of file diff --git a/Robot/GUI.py b/Robot/GUI.py index 385fd4f9..8b6c70c0 100644 --- a/Robot/GUI.py +++ b/Robot/GUI.py @@ -23,7 +23,20 @@ import copy # add filemode="w" to overwrite if not os.path.exists("Reports"): os.makedirs("Reports") -logging.basicConfig(filename="Reports\ReportRobotGUIRun_"+datetime.datetime.now().strftime("%Y_%m_%d")+".log", level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s") +########################## +#Подготовка логгера Robot +######################### +mRobotLogger=logging.getLogger("RobotLogger") +mRobotLogger.setLevel(logging.INFO) +# create the logging file handler +mRobotLoggerFH = logging.FileHandler("Reports\ReportRobotGUIRun_"+datetime.datetime.now().strftime("%Y_%m_%d")+".log") +mRobotLoggerFormatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') +mRobotLoggerFH.setFormatter(mRobotLoggerFormatter) +# add handler to logger object +mRobotLogger.addHandler(mRobotLoggerFH) + + +#logging.basicConfig(filename="Reports\ReportRobotGUIRun_"+datetime.datetime.now().strftime("%Y_%m_%d")+".log", level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s") #####Внимание####### #TODO В перспективе нужно реализовать алгоритм определения разрядности не в Robot.py, а в GUI.py, тк начинают появляться функции, на входе в которые еще неизвестна разрядность элемента + селектор может охватить сразу два элемента из 2-х разных разрядностей - обрабатываться это должно непосредственно при выполнении @@ -105,6 +118,8 @@ mDefaultPywinautoBackend="win32" #inFlagRaiseException - Флаг True - выкинуть ошибку в случае обнаружении пустого списка #old name - PywinautoExtElementsGet def UIOSelector_Get_UIOList (inSpecificationList,inElement=None,inFlagRaiseException=True): + #Создать копию входного листа, чтобы не менять массив в других верхнеуровневых функциях + inSpecificationList=copy.deepcopy(inSpecificationList) lResultList=[] lChildrenList=[] #Получить родительский объект если на вход ничего не поступило @@ -125,14 +140,16 @@ def UIOSelector_Get_UIOList (inSpecificationList,inElement=None,inFlagRaiseExcep #Получить дочерний элемент - точное добавление lChildrenList.append(lElementChildrenList[inSpecificationList[0]['index']]) else: - raise ValueError('Object has no children with index: ' + str(inSpecificationList[0]['index'])) + if inFlagRaiseException: + raise ValueError('Object has no children with index: ' + str(inSpecificationList[0]['index'])) #Поступил ctrl_index - точное добавление elif 'ctrl_index' in inSpecificationList[0]: if inSpecificationList[0]['ctrl_index']0: + #Условие выполнено + lResultFlag=True + #Если флаг не изменился - увеличить время и уснуть + if lResultFlag == False: + lSecsDone=lSecsDone+lSecsSleep + time.sleep(lSecsSleep) + return lResultList +################################################################################################# #Wait for UIO is appear (at least one of them or all at the same time) #inSpecificationList - UIOSelector #inWaitSecs - Время ожидания объекта в секундах @@ -292,6 +349,18 @@ def UIOSelectorSecs_WaitAppear_Bool (inSpecificationList,inWaitSecs): lResult=True return lResult ################################################################################################# +#Wait for UIO is disappear (at least one of them or all at the same time) +#inSpecificationList - UIOSelector +#inWaitSecs - Время ожидания пропажи объекта в секундах +#return: Bool - True - UIO is Disappear +#old name - - +def UIOSelectorSecs_WaitDisappear_Bool (inSpecificationList,inWaitSecs): + lWaitDisappearList=UIOSelectorsSecs_WaitDisappear_List([inSpecificationList],inWaitSecs) + lResult=False + if len(lWaitDisappearList)>0: + lResult=True + return lResult +################################################################################################# #Get process bitness (32 or 64) #inSpecificationList - UIOSelector #old name - None @@ -546,6 +615,9 @@ def UIOSelector_IsExist_Bool (inSpecificationList): #inSpecificationList - UIOSelector #result - { } #old name - PywinautoExtElementWaitAppear +############# +#Внимание! Старая функция (на замену ей пришла UIOSelectorSecs_WaitAppear_Bool) +############# def UIOSelector_WaitAppear_Dict(inSpecificationList,inTimeout=60): lTimeoutSeconds = 0 while (not UIOSelector_IsExist_Bool(inSpecificationList) and inTimeout>lTimeoutSeconds): @@ -1084,10 +1156,10 @@ if (len(sys.argv)>=2): mFlagIsDebug=False #Оповещение о выбранном режиме if mFlagIsDebug: - logging.info("Robot/GUI: Debug mode, x"+lProcessBitnessStr) + mRobotLogger.info("Robot/GUI: Debug mode, x"+lProcessBitnessStr) print ("Robot/GUI: Debug mode, x"+lProcessBitnessStr) else: - logging.info("Robot/GUI: Release mode, x"+lProcessBitnessStr) + mRobotLogger.info("Robot/GUI: Release mode, x"+lProcessBitnessStr) #Нельзя делать print в release mode тк print делает вывод в PIPE поток, что нарушает последовательность взаимодействия с родительским процессом #print ("Robot/GUI: Release mode, x"+lProcessBitnessStr) #for line in sys.stdin: diff --git a/Studio/Web/Index.xhtml b/Studio/Web/Index.xhtml index 93100806..82974825 100644 --- a/Studio/Web/Index.xhtml +++ b/Studio/Web/Index.xhtml @@ -763,7 +763,7 @@

OpenRPA

-
by UnicodeLabs
+
by UnicodeLabs
@@ -891,7 +891,7 @@