#Robot_GUI_RefactoringReady_Fixed #Studio_Created_NeedUpdate_20%

dev-linux
Ivan Maslov 5 years ago
parent eb05fcd322
commit 4cd9a5f462

@ -13,6 +13,7 @@ import win32clipboard
import time
import traceback
import ProcessCommunicator
import JSONNormalize
from threading import Timer
####################################
@ -198,6 +199,7 @@ def PWASpecification_Get_UIO(inControlSpecificationArray):
lBackend=mDefaultPywinautoBackend
if "backend" in inControlSpecificationArray[0]:
lBackend=inControlSpecificationArray[0]["backend"]
inControlSpecificationArray[0].pop("backend")
#Подготовка входного массива
inControlSpecificationArray=UIOSelector_SearchNormalize_UIOSelector(inControlSpecificationArray)
#Выполнить идентификацию объектов, если передан массив
@ -555,7 +557,7 @@ def UIOXY_SearchChild_ListDict(inRootElement,inX,inY,inHierarchyList=[]):
#Get list of child UIO's by Parent UIOSelector
#inControlSpecificationArray- UIOSelector
#old name - ElementGetChildElementList
def UIOSelector_GetChildList_UIOList(inControlSpecificationArray=[]):
def UIOSelector_GetChildList_UIOList(inControlSpecificationArray=[],inBackend=mDefaultPywinautoBackend):
#Подготовка входного массива
inControlSpecificationArray=UIOSelector_SearchNormalize_UIOSelector(inControlSpecificationArray)
#Выполнить идентификацию объектов, если передан массив
@ -578,7 +580,7 @@ def UIOSelector_GetChildList_UIOList(inControlSpecificationArray=[]):
#Инкремент счетчика
lIterator=lIterator+1
else:
lResultList=BackendStr_GetTopLevelList_UIOInfo()
lResultList=BackendStr_GetTopLevelList_UIOInfo(inBackend)
return lResultList
####################################################################################################
@ -721,7 +723,7 @@ def UIOEI_Convert_UIOInfo(inElementInfo):
#old name - GetRootElementList
def BackendStr_GetTopLevelList_UIOInfo(inBackend):
#Получить список объектов
lResultList=pywinauto.findwindows.find_elements(top_level_only=True,backend=mPywinautoActiveBackend)
lResultList=pywinauto.findwindows.find_elements(top_level_only=True,backend=mDefaultPywinautoBackend)
lResultList2=[]
for lI in lResultList:
lTempObjectInfo=lI
@ -825,20 +827,24 @@ if len(sys.argv) > 1:
mFlagIsDebug=True
#Выполнить чтение буфера, если не отладка библиотеки
if not mFlagIsDebug:
#{'functionName':'', 'argsArray':[]}
while True:
lProcessResponse={"ErrorFlag":False}
try:
#Ожидаем синхронно поступление объекта
lJSONInput = ProcessCommunicator.ProcessParentReadWaitObject()
lJSONInputString=str(lJSONInput)
#{'outputObject':''}
lProcessResponse["ActivitySpecificationDict"]=lJSONInput
#Выполнить вызов функции
lResult=locals()[lJSONInput['ActivityName']](*lJSONInput['ArgumentList'])
lJSONInput['Result']=JSONNormalizeDictList(lResult)
ProcessCommunicator.ProcessParentWriteObject(lJSONInput)
lProcessResponse["Result"]=JSONNormalize.JSONNormalizeDictList(locals()[lJSONInput['ActivityName']](*lJSONInput['ArgumentList'],**lJSONInput['ArgumentDict']))
except Exception as e:
#Вывод ошибки в родительский поток
ProcessCommunicator.ProcessParentWriteObject({'Error':str(e) + traceback.format_exc(), 'ArgObject':str(lJSONInputString)})
#ctypes.windll.user32.MessageBoxW(0, str(e), "Your title", 1)
#Установить флаг ошибки
lProcessResponse["ErrorFlag"]=True
#Зафиксировать traceback
lProcessResponse["ErrorTraceback"]=traceback.format_exc()
#Зафиксировать Error message
lProcessResponse["ErrorMessage"]=str(e)
#Отправить ответ в родительский процесс
ProcessCommunicator.ProcessParentWriteObject(lProcessResponse)
else:
print('Debug mode is turned on!')

@ -28,7 +28,7 @@ def JSONNormalizeDict(inDictionary):
lFlagRemoveAttribute=True
#Рекурсивный вызов, если объект является словарем
if type(lItemValue) is dict:
lResult[lItemKey]=JSONNormalizeDictionary(lItemValue)
lResult[lItemKey]=JSONNormalizeDict(lItemValue)
#Рекурсивный вызов, если объект является списком
if type(lItemValue) is list:
lResult[lItemKey]=JSONNormalizeList(lItemValue)
@ -51,7 +51,7 @@ def JSONNormalizeList(inList):
lResult.append(lItemValue)
#Если является словарем - вызвать функцию нормализации словаря
if type(lItemValue) is dict:
lResult.append(JSONNormalizeDictionary(lItemValue))
lResult.append(JSONNormalizeDict(lItemValue))
#Если является массиваом - вызвать функцию нормализации массива
if type(lItemValue) is list:
lResult.append(JSONNormalizeList(lItemValue))
@ -61,7 +61,7 @@ def JSONNormalizeList(inList):
def JSONNormalizeDictList(inDictList):
lResult={}
if type(inDictList) is dict:
lResult=JSONNormalizeDictionary(inDictList)
lResult=JSONNormalizeDict(inDictList)
if type(inDictList) is list:
lResult=JSONNormalizeList(inDictList)
return lResult;

@ -51,7 +51,7 @@ import traceback
#Section: Module initialization
####################
#Start childprocess - GUI Module 32 bit
mProcessGUI_x32 = subprocess.Popen(['..\\Resources\\WPy32-3720\\python-3.7.2\\python.exe','GUI.py'],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
mProcessGUI_x32 = subprocess.Popen(['..\\Resources\\WPy32-3720\\python-3.7.2\\python.exe','..\\Robot\\GUI.py'],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
#Start childprocess - GUI Module 64 bit - uncomment after WPy64 installation
#mProcessGUI_x64 = subprocess.Popen(['..\\Resources\\WPy64-3720\\python-3.7.2\\python.exe','GUI.py'],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
@ -60,8 +60,13 @@ mProcessGUI_x32 = subprocess.Popen(['..\\Resources\\WPy32-3720\\python-3.7.2\\py
#Section: Activity
####################
def ActivityRun(inActivitySpecificationDict):
#Выполнить отправку в модуль GUI, если ModuleName == "GUI"
if inActivitySpecificationDict["ModuleName"] == "GUI":
if "ArgumentList" not in inActivitySpecificationDict:
inActivitySpecificationDict["ArgumentList"]=[]
if "ArgumentDict" not in inActivitySpecificationDict:
inActivitySpecificationDict["ArgumentDict"]={}
#TODO: Доделать определение разрядности (32 и 64)
#Отправить запрос в дочерний процесс, который отвечает за работу с Windows окнами
ProcessCommunicator.ProcessChildSendObject(mProcessGUI_x32,inActivitySpecificationDict)
@ -70,14 +75,14 @@ def ActivityRun(inActivitySpecificationDict):
#Вернуть результат
#Остальные модули подключать и выполнять здесь
else:
#Подготовить результирующую структуру
lResponseObject={"ActivitySpecificationDict":inActivitySpecificationDict,"ErrorFlag":False}
lArgumentList=[]
if "ArgumentList" in inActivitySpecificationDict:
lArgumentList=inActivitySpecificationDict["ArgumentList"]
lArgumentDict={}
if "ArgumentDict" in inActivitySpecificationDict:
lArgumentDict=inActivitySpecificationDict["ArgumentDict"]
#Подготовить результирующую структуру
lResponseObject={"ActivitySpecificationDict":inActivitySpecificationDict,"ErrorFlag":False}
try:
#Подключить модуль для вызова
lModule=importlib.import_module(inActivitySpecificationDict["ModuleName"])

@ -0,0 +1,69 @@
import json
####################################
#Info: Internal JSONNormalize module of the Robot app (OpenRPA - Robot)
####################################
# JSONNormalize Module - Prepare dict or list for JSON (delete object from the structure)
###############################
####Нормализация под JSON (в JSON нельзя передавать классы - только null, числа, строки, словари и массивы)
###############################
#Нормализация словаря под JSON
def JSONNormalizeDict(inDictionary):
#Сделать копию объекта
lResult=inDictionary.copy()
#Перебор всех элементов
for lItemKey,lItemValue in inDictionary.items():
#Флаг удаления атрибута
lFlagRemoveAttribute=False
#Если строка или число или массив или объект или None - оставить
if (
type(lItemValue) is dict or
type(lItemValue) is int or
type(lItemValue) is str or
type(lItemValue) is list or
lItemValue is None):
True==True
else:
lFlagRemoveAttribute=True
#Рекурсивный вызов, если объект является словарем
if type(lItemValue) is dict:
lResult[lItemKey]=JSONNormalizeDict(lItemValue)
#Рекурсивный вызов, если объект является списком
if type(lItemValue) is list:
lResult[lItemKey]=JSONNormalizeList(lItemValue)
#############################
#Конструкция по удалению ключа из словаря
if lFlagRemoveAttribute:
lResult.pop(lItemKey)
#Вернуть результат
return lResult
#Нормализация массива под JSON
def JSONNormalizeList(inList):
lResult=[]
#Циклический обход
for lItemValue in inList:
#Если строка или число или массив или объект или None - оставить
if (
type(lItemValue) is int or
type(lItemValue) is str or
lItemValue is None):
lResult.append(lItemValue)
#Если является словарем - вызвать функцию нормализации словаря
if type(lItemValue) is dict:
lResult.append(JSONNormalizeDict(lItemValue))
#Если является массиваом - вызвать функцию нормализации массива
if type(lItemValue) is list:
lResult.append(JSONNormalizeList(lItemValue))
#Вернуть результат
return lResult
#Определить объект - dict or list - и нормализовать его для JSON
def JSONNormalizeDictList(inDictList):
lResult={}
if type(inDictList) is dict:
lResult=JSONNormalizeDict(inDictList)
if type(inDictList) is list:
lResult=JSONNormalizeList(inDictList)
return lResult;

@ -0,0 +1,141 @@
import json
import subprocess
import zlib
import sys
import os
import JSONNormalize
############################################
####Межпроцессное взаимодействие
############################################
#ProcessParentReadWaitString
def ProcessParentReadWaitString():
#Выполнить чтение строки
#ctypes.windll.user32.MessageBoxW(0, "Hello", "Your title", 1)
lResult = sys.stdin.buffer.readline()
#Вернуть потенциальные \n
lResult = lResult.replace(b'{{n}}',b'\n')
lResult = zlib.decompress(lResult[0:-1])
lResult = lResult.decode("utf-8")
#Вернуть результат
return lResult
#ParentProcessWriteString
def ProcessParentWriteString(lString):
lByteString = zlib.compress(lString.encode("utf-8"))
#Выполнить отправку строки в родительский процесс
#Вернуть потенциальные \n
lByteString = lByteString.replace(b'\n',b'{{{n}}}')
#Вернуть \r
lByteString = lByteString.replace(b'\r',b'{{{r}}}')
#Вернуть \0
lByteString = lByteString.replace(b'\0',b'{{{0}}}')
#Вернуть \a
lByteString = lByteString.replace(b'\a',b'{{{a}}}')
#Вернуть \b
lByteString = lByteString.replace(b'\b',b'{{{b}}}')
#Вернуть \t
lByteString = lByteString.replace(b'\t',b'{{{t}}}')
#Вернуть \v
lByteString = lByteString.replace(b'\v',b'{{{v}}}')
#Вернуть \f
lByteString = lByteString.replace(b'\f',b'{{{f}}}')
############################
#print(b"Result: "+lByteString)
#lByteString= b'x\x9c\xdd\x95]O\xc20\x14\x86\xffJ\xb3[5\xa1Cqz\x07\xc4\xe8\x8d\x1fQ\x13.\x0cYJw\xb6U\xbav\xe9\xce"\x84\xf0\xdfm\'"\xb8\xa0L%Q\xb3\x9b\xf6=\xdfO\x9a\xb3\x99\x17\x97\x8a\xa3\xd0\xea\x8ae\xe0\x9d\x12\xaf[\xa2\xce\x98S\xee\x80\x19\x9e^\xea\xb2\x803\t\x19(\xbc\x10`\x9c6\xf5\xf6\x89\xc7LRt\x8daS\x1b\xf5\xf00\xf3\xd4"\xc1u\x0e\xea\xf6\xa6K\x0e\xc8\xb9\xd6\x89\x04\xd2O\x8d\xb6&\x1bb\x04OC\x84\t~\xe2\x97\x1b\xcd\xa1(B\x11YG\xdaj\xfb\xc1\x9b\xb8\xa2\xa4LE\xd2\xd5\xa4\xf6\xdenY\x85Kf\xc3^;yI\x18\x0eD\x94\x00\x0e\x84{{n}}\xa9K\xce\xb5B\xa3e\x88\xd3\xbc\xf2Z\xd5\xaa\x82\xaa\x94\xd25\x0b\x1c\x99J\xaa\x023OB\xec\xbavEP\xe7\x8b\x93\x11I\xeaTz\xe2\xbb\xebH\xa3eW5\xe8\xb7\xe6\xce^*\x14\xb6\x83e\xda\xf9phe]b^\xe2\xf5\xe8\xd1Vp\xf0\xfe.\xbb\x1b\xa6`\x87\xfc8\x1a\x9bSE0q\xa2\x15\xeer\xe0"\x16\xbcz\x9f\xfdT\xc8h\x9d\xdf\xc7\xd4\xbe\xcdj1\xd9:\xa9\x1f\xe1B7\x81\xa1\xef\xc0\xd0:\x98\xc3-\xc0\xd4X\xfc\xda\xf1i\xbb\xe9\xfc\xdb<\x8c\xff2\x7f\'\xa8\x8d\xdf\xdab\xfc\x9e\xd6\xe3\x8c\x99qQ\xe3\xb0f\xd9\x19\x90{\xade\x8f\x99/3\xa1AC(\xfe\x16P\x06F \x90\xb3\t\x07Iba\x17\x83P\xa4\xbf\xb7G\x9e\x04\xa6vE\x13\xb6\xfc\x13\xd6\xa85\x0b\xdd\x19\xd6^i\x11\xa8FT;G\xfe\x06\xac\xc1q\xb0N\x956\xd84\xae\xe4p\xbe\xfa=\x03\x01\xce\x95\x9a'
#lByteString = b"x\x9c\xb5\x91\xcfO\xc3 \x14\xc7\xff\x95\xa6\xd7uI\xf9Q\x8a\xde\xd4\x93\x07\xbdx\xf00\x97\x05)[I(\x90\x8ef3\xcb\xfew\x81M\xbb\xd9M]\x8c!y\xd0\xf7}\xbc\xef\xe3\xd3\xc9&\xd5\xac\x11\xe9u\x92j\xb1J@2N\x1e\x8d\x13\x96U\xa3Q\x9a%i+y=sb\xed\xceV\xd8\xd6p\xb1\\\xced\xe5K{{n}}\x80`\x9f\xeb\x135\xd3\x95{{n}}.\x08RR\xe4>\xc3\x15\xf3\x97>\xbc\x8f:r\xa3]k\xd4\xcc\xbd\xd9(>K]\x99\xd5\xa1\x12\xbd\x00\xc6\xb0\xcc\xcb0\xa4\xe0\x8e\xe9E4\xd8\xa4J\xcc\xc3\xb44\x07^r\xc6\xfa3\x04(\xbeeQ\x07\x05P\x1a\xa4W\xe3\x9ci\xfc\xf7\x15(\xb6A\xee\xb4\x93\x8d\xd85\x9f`?\xf6n\xd8i0v\xadw\xd5\x95X\x87n>\xf1d\x05\x97s\xc9\x99\x93F\xdf\xd5R\xc5K=\xcc\x1bk\xd5^\x1d`\xfc\xa2]\x06PwJ\r\xf0\x9d\xa2\xf6 tw\xcb\xda\x01\xb6}\x83\xd3\xcc\x00\xec\x99\x15\xf4\x88Y\x99\x1f2\x83\xb4\xfc\x8e\x99\xdf\xb3d\x0c\x01.1E\x04\x93l\xff\x8e\xcf\x7f6\xa4Z\xfc\x82\xeaK\x97c BD\xf3\x101\x89g\xba\x8b\x03\xd0?\x97\xff#\xfb{'\x9a\x8b\xe0\x03H\xc89\xfa\x08\x15\x7f\xa2\x0f >\x80_\x0e\xe0\x93\xb3\xf0\xc3\xc4\xd3m\\\xef\xf8\x958\xa0"
#lt=open("logSendByteStringWithoutN.log","wb")
#lt.write(lByteString)
#lt.close()
############################
sys.stdout.buffer.write(lByteString+bytes("\n","utf-8"))
sys.stdout.flush();
return
#ProcessParentWriteObject
def ProcessParentWriteObject(inObject):
#Выполнить нормализацию объекта перед форматированием в JSON
JSONNormalize.JSONNormalizeDictList(inObject)
#Выполнить отправку сконвертированного объекта в JSON
ProcessParentWriteString(json.dumps(inObject))
return
#ProcessParentReadWaitObject
def ProcessParentReadWaitObject():
#Выполнить получение и разбор объекта
lResult=json.loads(ProcessParentReadWaitString());
return lResult;
#ProcessChildSendString
def ProcessChildSendString(lProcess,lString):
lByteString = zlib.compress(lString.encode("utf-8"))
#Вернуть потенциальные \n
lByteString = lByteString.replace(b'\n',b'{{n}}')
#Отправить сообщение в дочерний процесс
lProcess.stdin.write(lByteString+bytes('\n',"utf-8"))
#print(str(lByteString+bytes('\n',"utf-8")))
lProcess.stdin.flush()
#Вернуть результат
return
#ProcessChildReadWaitString
def ProcessChildReadWaitString(lProcess):
#Ожидаем ответ от процесса
lResult = lProcess.stdout.readline()
#Обработка спец символов
#print(b'NewLine: '+lResult)
#Вернуть потенциальные \n
lResult = lResult.replace(b'{{{n}}}',b'\n')
#Вернуть \r
lResult = lResult.replace(b'{{{r}}}',b'\r')
#Вернуть \0
lResult = lResult.replace(b'{{{0}}}',b'\0')
#Вернуть \a
lResult = lResult.replace(b'{{{a}}}',b'\a')
#Вернуть \b
lResult = lResult.replace(b'{{{b}}}',b'\b')
#Вернуть \t
lResult = lResult.replace(b'{{{t}}}',b'\t')
#Вернуть \v
lResult = lResult.replace(b'{{{v}}}',b'\v')
#Вернуть \f
lResult = lResult.replace(b'{{{f}}}',b'\f')
#print("check")
#print(str(lResult))
lResult = zlib.decompress(lResult[0:-1])
lResult = lResult.decode("utf-8")
#Вернуть результат
return lResult
#ProcessChildSendObject
def ProcessChildSendObject(inProcess,inObject):
#Выполнить отправку сконвертированного объекта в JSON
ProcessChildSendString(inProcess,json.dumps(inObject))
return
#ProcessChildReadWaitObject
def ProcessChildReadWaitObject(inProcess):
#Выполнить получение и разбор объекта
lResult=json.loads(ProcessChildReadWaitString(inProcess));
return lResult;
#ProcessChildSendReadWaitString
def ProcessChildSendReadWaitString(lProcess,lString):
ProcessChildSendString(lProcess,lString)
#Вернуть результат
return ProcessChildReadWaitString(lProcess)
#ProcessChildSendReadWaitObject
def ProcessChildSendReadWaitObject(inProcess,inObject):
ProcessChildSendObject(inProcess,inObject)
#Вернуть результат
return ProcessChildReadWaitString(inProcess)
#ProcessChildSendReadWaitQueue
#QueueObject - [Object,Object,...]
def ProcessChildSendReadWaitQueueObject(inProcess,inQueueObject):
lOutputObject=[]
#Циклическая отправка запросов в дочерний объект
for lItem in inQueueObject:
#Отправить запрос в дочерний процесс, который отвечает за работу с Windows окнами
ProcessChildSendObject(inProcess,lItem)
#Получить ответ от дочернего процесса
lResponseObject=ProcessChildReadWaitObject(inProcess)
#Добавить в выходной массив
lOutputObject.append(lResponseObject)
#Сформировать ответ
return lOutputObject

@ -0,0 +1,3 @@
cd %~dp0
.\..\Resources\WPy32-3720\python-3.7.2\python.exe
pause >nul

@ -0,0 +1,162 @@
from http.server import BaseHTTPRequestHandler, HTTPServer
import pdb
import pywinauto
import json
import subprocess
import zlib
import os
import ProcessCommunicator
import sys
sys.path.append('../Robot')
import Robot
# HTTPRequestHandler class
class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
#ResponseContentTypeFile
def SendResponseContentTypeFile(self,inContentType,inFilePath):
# Send response status code
self.send_response(200)
# Send headers
self.send_header('Content-type',inContentType)
self.end_headers()
lFileObject = open(inFilePath, "rb")
# Write content as utf-8 data
self.wfile.write(lFileObject.read())
#Закрыть файловый объект
lFileObject.close()
# GET
def do_GET(self):
#Мост между файлом и http запросом (новый формат)
if self.path == "/":
self.SendResponseContentTypeFile('text/html',"Web\\Index.xhtml")
#Мост между файлом и http запросом (новый формат)
if self.path == '/3rdParty/Semantic-UI-CSS-master/semantic.min.css':
self.SendResponseContentTypeFile('text/css',"..\\Resources\\Web\\Semantic-UI-CSS-master\\semantic.min.css")
#Мост между файлом и http запросом (новый формат)
if self.path == '/3rdParty/Semantic-UI-CSS-master/semantic.min.js':
self.SendResponseContentTypeFile('application/javascript',"..\\Resources\\Web\\Semantic-UI-CSS-master\\semantic.min.js")
#Мост между файлом и http запросом (новый формат)
if self.path == '/3rdParty/jQuery/jquery-3.1.1.min.js':
self.SendResponseContentTypeFile('application/javascript',"..\\Resources\\Web\\jQuery\\jquery-3.1.1.min.js")
#Мост между файлом и http запросом (новый формат)
if self.path == '/3rdParty/Google/LatoItalic.css':
self.SendResponseContentTypeFile('font/css',"..\\Resources\\Web\\Google\\LatoItalic.css")
#Мост между файлом и http запросом (новый формат)
if self.path == '/3rdParty/Semantic-UI-CSS-master/themes/default/assets/fonts/icons.woff2':
self.SendResponseContentTypeFile('font/woff2',"..\\Resources\\Web\\Semantic-UI-CSS-master\\themes\\default\\assets\\fonts\\icons.woff2")
#Мост между файлом и http запросом (новый формат)
if self.path == '/favicon.ico':
self.SendResponseContentTypeFile('image/x-icon',"Web\\favicon.ico")
#Action ObjectInspector GetObjectList
if self.path == '/ObjectDetector/JSONGetWindowList':
#ReadRequest
#lInputByteArray=self.rfile.read()
#print(str(len(os.stat(self.rfile).st_size)))
# Send response status code
self.send_response(200)
# Send headers
self.send_header('Content-type','application/json')
self.end_headers()
# Send message back to client
#{'functionName':'', 'argsArray':[]}
lRequestObject={'functionName':'ElementGetChildElementList','argsArray':[]}
#Отправить запрос в дочерний процесс, который отвечает за работу с Windows окнами
ProcessChildSendObject(p,lRequestObject)
#Получить ответ от дочернего процесса
lResponseObject=ProcessCommunicator.ProcessChildReadWaitObject(p)
message = json.dumps(lResponseObject)
# Write content as utf-8 data
self.wfile.write(bytes(message, "utf8"))
# POST
def do_POST(self):
#Action ObjectInspector GetObjectList
if self.path == '/ObjectDetector/JSONGetWindowListArgs':
#ReadRequest
lInputByteArrayLength = int(self.headers.get('Content-Length'))
lInputByteArray=self.rfile.read(lInputByteArrayLength)
#Превращение массива байт в объект
print(lInputByteArray.decode('utf8'))
lInputObject=json.loads(lInputByteArray.decode('utf8'))
# Send response status code
self.send_response(200)
# Send headers
self.send_header('Content-type','application/json')
self.end_headers()
# Send message back to client
#{'functionName':'', 'argsArray':[]}
lRequestObject={'functionName':'ElementGetChildElementList','argsArray':lInputObject}
#Отправить запрос в дочерний процесс, который отвечает за работу с Windows окнами
ProcessCommunicator.ProcessChildSendObject(p,lRequestObject)
#Получить ответ от дочернего процесса
lResponseObject=ProcessCommunicator.ProcessChildReadWaitObject(p)
print(str(lResponseObject))
message = json.dumps(lResponseObject)
# Write content as utf-8 data
self.wfile.write(bytes(message, "utf8"))
if self.path == '/GUIAction':
#ReadRequest
lInputByteArrayLength = int(self.headers.get('Content-Length'))
lInputByteArray=self.rfile.read(lInputByteArrayLength)
#Превращение массива байт в объект
lInputObject=json.loads(lInputByteArray.decode('utf8'))
# Send response status code
self.send_response(200)
# Send headers
self.send_header('Content-type','application/json')
self.end_headers()
# Send message back to client
#{'functionName':'', 'argsArray':[]}
#pdb.set_trace()
lRequestObject=lInputObject
#Отправить команду роботу
lResponseObject=Robot.ActivityRun(lRequestObject)
message = json.dumps(lResponseObject)
# Write content as utf-8 data
self.wfile.write(bytes(message, "utf8"))
if self.path == '/GUIActionList':
#ReadRequest
lInputByteArrayLength = int(self.headers.get('Content-Length'))
lInputByteArray=self.rfile.read(lInputByteArrayLength)
#Превращение массива байт в объект
lInputObject=json.loads(lInputByteArray.decode('utf8'))
# Send response status code
self.send_response(200)
# Send headers
self.send_header('Content-type','application/json')
self.end_headers()
# Send message back to client
#{'functionName':'', 'argsArray':[]}
lRequestObject=lInputObject
lOutputObject=[]
#pdb.set_trace()
#Циклическая отправка запросов в дочерний объект
for lItem in lRequestObject:
#Отправить запрос в дочерний процесс, который отвечает за работу с Windows окнами
ProcessCommunicator.ProcessChildSendObject(p,lItem)
#Получить ответ от дочернего процесса
lResponseObject=ProcessCommunicator.ProcessChildReadWaitObject(p)
#Добавить в выходной массив
lOutputObject.append(lResponseObject)
#Сформировать текстовый ответ
message = json.dumps(lOutputObject)
# Write content as utf-8 data
self.wfile.write(bytes(message, "utf8"))
return
def run():
print('starting server...')
# Server settings
# Choose port 8080, for port 80, which is normally used for a http server, you need root access
server_address = ('127.0.0.1', 8081)
httpd = HTTPServer(server_address, testHTTPServer_RequestHandler)
print('running server...')
httpd.serve_forever()
#Start childprocess 32 bit
p = subprocess.Popen(['..\\Resources\\WPy32-3720\\python-3.7.2\\python.exe','winGUI.py'],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
#print(ChildProcessReadWaitString(p))
run()

@ -0,0 +1,3 @@
cd %~dp0
.\..\Resources\WPy32-3720\python-3.7.2\python.exe Studio.py
pause >nul

@ -0,0 +1,21 @@
#valueVerify
#inTypeClass int, str, dict, list, NoneType
def valueVerify(inValue,inTypeClass,inNotValidValue):
lResult = inNotValidValue
if inValue is not None:
if type(inValue) == inTypeClass:
lResult = inValue
#Вернуть результат
return lResult
#valueVerifyDict
def valueVerifyDict(inDict,inKey,inTypeClass,inNotValidValue):
lResult = inNotValidValue
if inKey in inDict:
lResult = valueVerify(inDict[inKey],inTypeClass,inNotValidValue)
return lResult
#valueVerifyList
def valueVerifyList(inList,inIndex,inTypeClass,inNotValidValue):
lResult = inNotValidValue
if inIndex in inList:
lResult = valueVerify(inList[inIndex],inTypeClass,inNotValidValue)
return lResult

@ -0,0 +1,875 @@
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="utf-8">
<title>OpenRPA</title>
<link rel="stylesheet" type="text/css" href="3rdParty/Semantic-UI-CSS-master/semantic.min.css">
<script
src="3rdParty/jQuery/jquery-3.1.1.min.js"
crossorigin="anonymous"></script>
<script src="3rdParty/Semantic-UI-CSS-master/semantic.min.js"></script>
<script>
var mGlobal={}
$(document)
.ready(function() {
mGlobal.GUIElement={}
mGlobal.GenerateUniqueID=function(inPrefix="ID") {
return inPrefix+Math.round(Math.random()*1000)+"-"+Math.round(Math.random()*10000)+"-"+Math.round(Math.random()*1000)
}
///Инициализация
mGlobal.ElementTree={}
mGlobal.Actions={}
mGlobal.ActionSpecificationList = []
mGlobal.CodeList={}
mGlobal.ClipboardSet=function(lText) {
const el = document.createElement('textarea');
el.value = lText;
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);
};
///Функция клонирования объекта
mGlobal.iSysClone=function(obj,lIsCloneSubProperty,lSubItemCallback) {
///Выполнить инициализацию переменной, если она не была передана
if (typeof(lIsCloneSubProperty)=="undefined") {
lIsCloneSubProperty=true;
}
///Вернуть значение, если передан простой тип данных
if (null == obj || "object" != typeof obj) return obj;
///Выполнить инициализацию новой переменной
var copy = obj.constructor();
///Циклический обход по всем свойствам объекта
for (var attr in obj) {
///Исключить присваивание тех свойств, которые унаследованы от прототипа
if (obj.hasOwnProperty(attr)) {
///Проверить, является ли вложенное свойство объектом
if (typeof(obj[attr])=="object" && lIsCloneSubProperty) {
///Рекурсивный вызов клонирования дочернего элемента
copy[attr] = mGlobal.iSysClone(obj[attr],lIsCloneSubProperty);
} else {
///Клонируемое свойство не является объектом - выполнить копирование
copy[attr] = obj[attr];
}
///Вызов callback функции в которую передается текущий атрибут
if (typeof(lSubItemCallback)!="undefined") {
lSubItemCallback(copy[attr]);
}
}
}
///Вернуть результат функции клонирования
return copy;
}
///Функция запуска поиска по окну
mGlobal.Actions.fAutomationSearchMouseElementHierarchyRun= function(inElementId)
{
//Подгрузка массива спецификаций
lSpecificationArray = mGlobal.GUIElement[inElementId].GUISelectorFull;
///Загрузка данных
$.ajax({
type: "POST",
url: 'GUIAction',
data: '{"functionName":"AutomationSearchMouseElementHierarchy","argsArray":['+JSON.stringify(lSpecificationArray)+']}',
success:
function(lData,l2,l3)
{
var lResponseJSON=JSON.parse(lData);
///Подготовить структуру рендеринга, если у текущего объекта имееется родитель
var lStructureToRender=lResponseJSON.outputObject;
if (lSpecificationArray.length>1) {
var lStructureToRenderParent=[]
var lStructureToRenderLocal=lStructureToRenderParent;
for (var i=0;i<lSpecificationArray.length-1;i++) {
lStructureToRenderLocal.push(lSpecificationArray[i]);
///Добавить SpecificationChild, если итератор не заканчивается
if (i<lSpecificationArray.length-2) {
lStructureToRenderLocal[0]["SpecificationChild"]=[]
lStructureToRenderLocal=lStructureToRenderLocal[0]["SpecificationChild"]
}
///Если последнее звено - добавить структуру, которая поступила с сервера
if (i==lSpecificationArray.length-2) {
lStructureToRenderLocal[0]["SpecificationChild"]=lStructureToRender
lStructureToRender=lStructureToRenderParent
}
}
}
///Очистить дерево
mGlobal.ElementTree.fClear();
///Прогрузить новое дерево
mGlobal.ElementTree.fRender(lStructureToRender);
if (lResponseJSON.hasOwnProperty("Error")) {
mGlobal.ShowModal("GUI Error",lResponseJSON.Error);
}
},
dataType: "text"
});
}
//Функция очистки объектов интерфейса
mGlobal.ElementTree.fClear=function()
{
///Очистить HTML код
$(".rpa-object-tree").html("");
}
///Функция визуализации дерева
mGlobal.ElementTree.fRender = function(inElementsTreeDataArray)
{
var lHTMLList='<div class="ui list" style="height:350px;overflow:scroll;">';
///Циклический обход списка
for (var i = 0; i< inElementsTreeDataArray.length;i++) {
///Добавить HTML код позиции
lHTMLList+=mGlobal.ElementTree.fItemGenerateHTML_JS(inElementsTreeDataArray[i])
}
///Закрывающая список HTML
lHTMLList+="</div>"
///Установить HTML код в родителя
$(".rpa-object-tree").html(lHTMLList);
}
///Функция визуализации дерева
///Вызов создания вложенного листа, если имеется атрибут SpecificationChild
mGlobal.ElementTree.fItemGenerateHTML_JS = function(inItem,inParentSpecification=[]){
///Генерация уникального кода для элемента
var lElementId = mGlobal.GenerateUniqueID()
//Добавить информацию об элементе в словарь JS
///Урезанная часть селектора (сделать, чтобы была без SpecificationChild)
var lSelectorLocal={};
Object.assign(lSelectorLocal,inItem);
delete lSelectorLocal.SpecificationChild;
///Установка данных JS
mGlobal.GUIElement[lElementId]={};
mGlobal.GUIElement[lElementId]['GUISelectorLocal']=lSelectorLocal
mGlobal.GUIElement[lElementId]['GUISelectorFull']=Array.from(inParentSpecification);
mGlobal.GUIElement[lElementId]['GUISelectorFull'].push(lSelectorLocal)
///Генерация кода HTML
var lResultString="";
var lSubItemActionOnClick=' onclick="mGlobal.TreeLoadSubTree(\''+lElementId+'\');" '
var lSubItemActionOnRightClick=' oncontextmenu="mGlobal.ElementHighlightNew(\''+lElementId+'\');" '
var lIconSelectOnClick=' onclick="mGlobal.TreeObjectInfoLoad(\''+lElementId+'\');" '
var lIconTestOnClick=' onclick="mGlobal.Test(\''+lElementId+'\');" '
var lIconUpOnClick=' onclick="mGlobal.Actions.fAutomationSearchMouseElementHierarchyRun(\''+lElementId+'\');" '
var lSubListHTML="";
///Проверка вложенных объектов SpecificationChild
if (Array.isArray(inItem.SpecificationChild)) {
if (inItem.SpecificationChild.length>0) {
var lSubListHTML='<div class="ui list">';
for (var i=0;i<inItem.SpecificationChild.length;i++) {
if (inItem.SpecificationChild[i] != null) {
///Генерация кода
lSubListHTML+=mGlobal.ElementTree.fItemGenerateHTML_JS(inItem.SpecificationChild[i],mGlobal.GUIElement[lElementId]['GUISelectorFull'])
}
}
lSubListHTML+="</div>"
}
}
///Генерация кода текущего элемента
lResultString+='\
<div class="item" id="'+lElementId+'">\
<i class="folder icon"></i>\
<i class="angle double right icon" '+lIconSelectOnClick+'></i>\
<i class="angle double right icon" '+lIconTestOnClick+'></i>\
<i class="angle double up icon" '+lIconUpOnClick+'></i>\
<div class="content">\
<div class="header" '+lSubItemActionOnClick+lSubItemActionOnRightClick+'>'+inItem.title+'</div>\
<div class="description" '+lSubItemActionOnClick+lSubItemActionOnRightClick+'>process_id:'+inItem.process_id+'; handle:'+inItem.handle+'; class_name: '+inItem.class_name+'; RECT:L'+inItem.rectangle.left+' T'+inItem.rectangle.top+' R'+inItem.rectangle.right+' B'+inItem.rectangle.bottom+'</div>\
'+lSubListHTML+'\
</div>\
</div>'
return lResultString;
}
mGlobal.TreeLoadSubTree =function (inElementId) {
//Подгрузка массива спецификаций
lSpecificationArray = mGlobal.GUIElement[inElementId].GUISelectorFull
///Загрузка данных
$.ajax({
type: "POST",
url: 'GUIAction',
data: '{"functionName":"ElementGetChildElementList","argsArray":['+JSON.stringify(lSpecificationArray)+']}',
success:
function(lData,l2,l3)
{
var lHTMLTree='<div class="ui list">'
var lResponseJSON=JSON.parse(lData)
for (i=0;i<lResponseJSON.outputObject.length;i++) {
var lElementId = mGlobal.GenerateUniqueID()
var lSubItemHandleId=lResponseJSON.outputObject[i].handle;
var lSubItemActionOnClick=' onclick="mGlobal.TreeLoadSubTree(\''+lElementId+'\');" '
var lSubItemActionOnRightClick=' oncontextmenu="mGlobal.ElementHighlightNew(\''+lElementId+'\');" '
var lIconSelectOnClick=' onclick="mGlobal.TreeObjectInfoLoad(\''+lElementId+'\');" '
var lIconTestOnClick=' onclick="mGlobal.Test(\''+lElementId+'\');" '
var lIconUpOnClick=' onclick="mGlobal.Actions.fAutomationSearchMouseElementHierarchyRun(\''+lElementId+'\');" '
lHTMLTree+='\
<div class="item handle_'+lSubItemHandleId+'" handle_id="'+lSubItemHandleId+'" id="'+lElementId+'">\
<i class="folder icon"></i>\
<i class="angle double right icon" '+lIconSelectOnClick+'></i>\
<i class="angle double right icon" '+lIconTestOnClick+'></i>\
<i class="angle double up icon" '+lIconUpOnClick+'></i>\
<div class="content">\
<div class="header" '+lSubItemActionOnClick+lSubItemActionOnRightClick+'>'+lResponseJSON.outputObject[i].title+'</div>\
<div class="description" '+lSubItemActionOnClick+lSubItemActionOnRightClick+'>process_id:'+lResponseJSON.outputObject[i].process_id+'; handle:'+lSubItemHandleId+'; class_name: '+lResponseJSON.outputObject[i].class_name+'; RECT:L'+lResponseJSON.outputObject[i].rectangle.left+' T'+lResponseJSON.outputObject[i].rectangle.top+' R'+lResponseJSON.outputObject[i].rectangle.right+' B'+lResponseJSON.outputObject[i].rectangle.bottom+'</div>\
</div>\
</div>'
//Добавить информацию об элементе в словарь JS
mGlobal.GUIElement[lElementId]={};
mGlobal.GUIElement[lElementId]['GUISelectorLocal']=lResponseJSON.outputObject[i]
mGlobal.GUIElement[lElementId]['GUISelectorFull']=Array.from(lSpecificationArray);
mGlobal.GUIElement[lElementId]['GUISelectorFull'].push(lResponseJSON.outputObject[i])
}
lHTMLTree+='</div>'
$("#"+inElementId+" .content").append(lHTMLTree)
///Отображение ошибки
if (lResponseJSON.hasOwnProperty("Error")) {
mGlobal.ShowModal("GUI Error",lResponseJSON.Error);
}
},
dataType: "text"
});
}
mGlobal.TreeObjectInfoLoad =function (inElementId) {
//Подгрузка массива спецификаций
lSpecificationArray = mGlobal.GUIElement[inElementId].GUISelectorFull
var lHTMLList='<div class="ui relaxed divided list" style="height:350px;overflow:scroll;">'
var lSpecificationArrayNew=[]
for (i=0;i<lSpecificationArray.length;i++) {
lSpecificationArrayNew.push(lSpecificationArray[i])
var lElementId = mGlobal.GenerateUniqueID()
var lOnClickSelect= ' onclick="mGlobal.ElementPropertyListLoad(\''+lElementId+'\');" '
lHTMLList+='\
<div class="item" id="'+lElementId+'" '+lOnClickSelect+'>\
<div class="content">\
<div class="description"><p style="word-wrap: break-word;"><b>Level '+i+': </b> '+JSON.stringify(lSpecificationArray[i])+'</p></div>\
</div>\
</div>'
mGlobal.GUIElement[lElementId]={};
mGlobal.GUIElement[lElementId]['GUISelectorLocal']=lSpecificationArray[i]
mGlobal.GUIElement[lElementId]['GUISelectorFull']=Array.from(lSpecificationArrayNew);
}
lHTMLList+='</div>'
$(".rpa-hierarchy").html(lHTMLList)
$(".rpa-object-tree .item").css("background-color","");
$("#"+inElementId).css("background-color","RGB(128,128,128)");
///Создать урезанную версию селектора
lTextAreaSpecificationArray=mGlobal.iSysClone(lSpecificationArray,true);
for (var i = 0; i< lTextAreaSpecificationArray.length; i++) {
//lTextAreaSpecificationArray[i]=mGlobal.iSysClone(lTextAreaSpecificationArray[i],true)
//Object.assign(lTextAreaSpecificationArray[i],lTextAreaSpecificationArray[i]);
///Очистить ненужные ключи для выборки
delete lTextAreaSpecificationArray[i]['rich_text']
delete lTextAreaSpecificationArray[i]['process_id']
delete lTextAreaSpecificationArray[i]['rectangle']
delete lTextAreaSpecificationArray[i]['control_id']
delete lTextAreaSpecificationArray[i]['process']
delete lTextAreaSpecificationArray[i]['name']
delete lTextAreaSpecificationArray[i]['handle']
delete lTextAreaSpecificationArray[i]['control_type']
delete lTextAreaSpecificationArray[i]['runtime_id']
if (i!=0) {
delete lTextAreaSpecificationArray[i]['title']
delete lTextAreaSpecificationArray[i]['class_name']
}
}
$(".rpa-gui-selector")[0].value=(JSON.stringify(lTextAreaSpecificationArray))
}
mGlobal.ElementPropertyListLoad=function(inElementId) {
//Подгрузка массива спецификаций
lSpecificationArray = mGlobal.GUIElement[inElementId].GUISelectorFull
$.ajax({
type: "POST",
url: 'GUIAction',
data: '{"functionName":"ElementRunAction","argsArray":['+JSON.stringify(lSpecificationArray)+',"get_properties"]}',
success:
function(lData,l2,l3)
{
var lHTMLList='<div class="ui relaxed divided list">'
var lResponseJSON = JSON.parse(lData)
///Ошибка
if (lResponseJSON.hasOwnProperty("Error")) {
mGlobal.ShowModal("GUI Error",lResponseJSON.Error);
} else {
var lJSONData = JSON.parse(lData).outputObject
var lSpecificationArray=Object.keys(lJSONData)
for (i=0;i<lSpecificationArray.length;i++) {
var lItemKey = lSpecificationArray[i]
var lItemValue = lJSONData[lItemKey]
lHTMLList+='\
<div class="item">\
<div class="content">\
<div class="description"><p style="word-wrap: break-word;"><b> '+lItemKey+':</b> '+JSON.stringify(lItemValue)+'</p></div>\
</div>\
</div>'
}
lHTMLList+='</div>'
$(".rpa-property-list").html(lHTMLList)
}
},
dataType: "text"
});
}
mGlobal.ElementHighlight =function (inHandleId) {
///Загрузка данных
$.ajax({
type: "POST",
url: 'GUIAction',
data: '{"functionName":"ElementRunAction","argsArray":[[{"handle":'+inHandleId+'}],"draw_outline"]}',
success:
function(lData,l2,l3)
{
console.log('Success handle:'+inHandleId)
var lResponseJSON = JSON.parse(lData)
///Ошибка
if (lResponseJSON.hasOwnProperty("Error")) {
mGlobal.ShowModal("GUI Error",lResponseJSON.Error);
}
},
dataType: "text"
});
}
mGlobal.ElementHighlightNew =function (inElementId) {
//Подгрузка массива спецификаций
lSpecificationArray = mGlobal.GUIElement[inElementId].GUISelectorFull
///Загрузка данных
$.ajax({
type: "POST",
url: 'GUIAction',
data: '{"functionName":"ElementDrawOutlineNew","argsArray":['+JSON.stringify(lSpecificationArray)+']}',
success:
function(lData,l2,l3)
{
lDataJSON=JSON.parse(lData);
///Показать ошибку, если таковая возникла
if (lDataJSON.hasOwnProperty("Error")) {
mGlobal.ShowModal("GUI Error",lDataJSON.Error);
}
},
dataType: "text"
});
}
mGlobal.ElementHighlightNewGUISelectorString =function (inGUISelector) {
//Подгрузка массива спецификаций
lSpecificationArray = inGUISelector
///Загрузка данных
$.ajax({
type: "POST",
url: 'GUIAction',
data: '{"functionName":"ElementDrawOutlineNewFocus","argsArray":['+lSpecificationArray+']}',
success:
function(lData,l2,l3)
{
lDataJSON=JSON.parse(lData);
if (lDataJSON.hasOwnProperty("Error")) {
mGlobal.ShowModal("GUI Error",lDataJSON.Error);
}
},
dataType: "text"
});
}
mGlobal.ElementValidateGUISelectorString =function (inGUISelector) {
//Подгрузка массива спецификаций
lSpecificationArray = inGUISelector
///Загрузка данных
$.ajax({
type: "POST",
url: 'GUIAction',
data: '{"functionName":"PywinautoExtElementsGetInfo","argsArray":['+lSpecificationArray+']}',
success:
function(lData,l2,l3)
{
lDataJSON=JSON.parse(lData);
if (Array.isArray(lDataJSON.outputObject)) {
lHTMLData=""
for (i=0;i<lDataJSON.outputObject.length;i++) {
lHTMLData+='<p>'+
JSON.stringify(lDataJSON.outputObject[i])+
'</p>'
}
$(".openrpa-validate-result").html(lHTMLData)
}
if (lDataJSON.hasOwnProperty("Error")) {
mGlobal.ShowModal("GUI Error",lDataJSON.Error);
}
},
dataType: "text"
});
}
mGlobal.Test = function (inElementId) {
//Подгрузка массива спецификаций
lSpecificationArray = mGlobal.GUIElement[inElementId].GUISelectorFull
///Загрузка данных
$.ajax({
type: "POST",
url: 'GUIAction',
data: '{"functionName":"ElementActionGetList","argsArray":['+JSON.stringify(lSpecificationArray)+']}',
success:
function(lData,l2,l3)
{
//lDataJSON=JSON.parse(lData.outputObject);
var lDataJSON=JSON.parse(lData)
var lDataKeyList=lDataJSON.outputObject
var lValueList=[]
for (var i = 0; i< lDataKeyList.length;i++) {
if (lDataKeyList[i].length>0)
if (lDataKeyList[i][0]!="_")
lValueList.push({'name':lDataKeyList[i],'value':lDataKeyList[i]})
}
///Установка значений в dropdown
$('.ui.dropdown.gui-action')
.dropdown({
values: lValueList
})
;
///Показать ошибку, если таковая возникла
if (lDataJSON.hasOwnProperty("Error")) {
mGlobal.ShowModal("GUI Error",lDataJSON.Error);
}
},
dataType: "text"
});
}
///Выполнить действие
mGlobal.GUIActionLoadList = function () {
var lActionElementSpecification = $('.rpa-gui-selector')[0].value
///Загрузка данных
$.ajax({
type: "POST",
url: 'GUIAction',
data: '{"functionName":"ElementActionGetList","argsArray":['+lActionElementSpecification+']}',
success:
function(lData,l2,l3)
{
//lDataJSON=JSON.parse(lData.outputObject);
lDataJSON=JSON.parse(lData)
var lDataKeyList=lDataJSON.outputObject
var lValueList=[]
for (var i = 0; i< lDataKeyList.length;i++) {
if (lDataKeyList[i].length>0)
if (lDataKeyList[i][0]!="_")
lValueList.push({'name':lDataKeyList[i],'value':lDataKeyList[i]})
}
///Установка значений в dropdown
$('.ui.dropdown.gui-action')
.dropdown({
values: lValueList
})
;
///Показать ошибку, если таковая возникла
if (lDataJSON.hasOwnProperty("Error")) {
mGlobal.ShowModal("GUI Error",lDataJSON.Error);
}
},
dataType: "text"
});
}
///Добавить действие в список на исполнение
mGlobal.GUIActionAddToList= function() {
var lActionName =$('.dropdown.gui-action .selected')[0].attributes['data-value'].value
var lActionElementSpecification = $('.rpa-gui-selector')[0].value
var lActionArgumentList = $('.rpa-argument-list')[0].value
if (lActionArgumentList=="") lActionArgumentList="[]"
///Сформировать строку спецификации действия
lActionSpecificationObject = {"functionName":"ElementRunAction","argsArray":[JSON.parse(lActionElementSpecification),lActionName,JSON.parse(lActionArgumentList)]}
lActionSpecificationString = '{"functionName":"ElementRunAction","argsArray":['+lActionElementSpecification+',"'+lActionName+'",'+lActionArgumentList+']}'
///Добавить в массив действий
mGlobal.ActionSpecificationList.push(lActionSpecificationObject)
///Обновить визуализацию
mGlobal.CodeList.fRender()
}
///Добавить действие ожидания в список на исполнение
mGlobal.GUIActionWaitAddToList = function() {
var lActionElementSpecification = $('.rpa-gui-selector')[0].value
var lActionArgumentList = $('.rpa-argument-list')[0].value
if (lActionArgumentList=="") lActionArgumentList="[]"
///Сформировать строку спецификации действия
lActionSpecificationObject = {"functionName":"PywinautoExtElementWaitAppear","argsArray":[JSON.parse(lActionElementSpecification)]}
lActionSpecificationString = '{"functionName":"PywinautoExtElementWaitAppear","argsArray":['+lActionElementSpecification+']}'
///Добавить в массив действий
mGlobal.ActionSpecificationList.push(lActionSpecificationObject)
///Обновить визуализацию
mGlobal.CodeList.fRender()
}
///Добавить действие сон 2 секунды в список на исполнение
mGlobal.GUIActionSleep2sAddToList = function() {
///Сформировать строку спецификации действия
lActionSpecificationObject = {"functionName":"GeneralSleep2s","argsArray":[]}
lActionSpecificationString = '{"functionName":"GeneralSleep2s","argsArray":[]}'
///Добавить в массив действий
mGlobal.ActionSpecificationList.push(lActionSpecificationObject)
///Обновить визуализацию
mGlobal.CodeList.fRender()
}
///Выполнить список действий
mGlobal.GUICodeListRun = function () {
///Загрузка данных
$.ajax({
type: "POST",
url: 'GUIActionList',
data: JSON.stringify(mGlobal.ActionSpecificationList),
success:
function(lData,l2,l3)
{
var lDataJSON=JSON.parse(lData)
$(".gui-code-list-run-result").html(lDataJSON.outputObject)
///Показать ошибку, если таковая возникла
if (lDataJSON.hasOwnProperty("Error")) {
mGlobal.ShowModal("GUI Error",lDataJSON.Error);
}
},
dataType: "text"
});
}
///////////////////
///CodeList
///////////////////
///Визуализация текущего списка
mGlobal.CodeList.fRender=function() {
///Сформировать текстовые данные для вывода
var lHTMLData = ""
for (var i = 0; i< mGlobal.ActionSpecificationList.length;i++) {
lHTMLData+='<p>'+
JSON.stringify(mGlobal.ActionSpecificationList[i])+
'</p>'
}
$(".gui-code-result").html(lHTMLData)
}
///Выполнить импорт спецификации из JSON
mGlobal.CodeList.fActionSpecificationImportFromJSON=function() {
mGlobal.ActionSpecificationList=JSON.parse($(".ui.modal.openrpa-code-list-gui-import-modal textarea")[0].value)
///Обновить список на странице
mGlobal.CodeList.fRender()
}
///Выполнить действие
mGlobal.GUIActionRun = function () {
var lActionName =$('.dropdown.gui-action .selected')[0].attributes['data-value'].value
var lActionElementSpecification = $('.rpa-gui-selector')[0].value
var lActionArgumentList = $('.rpa-argument-list')[0].value
if (lActionArgumentList=="") lActionArgumentList="[]"
///Загрузка данных
$.ajax({
type: "POST",
url: 'GUIAction',
data: '{"functionName":"ElementRunAction","argsArray":['+lActionElementSpecification+',"'+lActionName+'",'+lActionArgumentList+']}',
success:
function(lData,l2,l3)
{
var lDataJSON=JSON.parse(lData)
$(".gui-result").html(lDataJSON.outputObject)
///Показать ошибку, если таковая возникла
if (lDataJSON.hasOwnProperty("Error")) {
mGlobal.ShowModal("GUI Error",lDataJSON.Error);
}
},
dataType: "text"
});
}
// fix main menu to page on passing
$('.main.menu').visibility({
type: 'fixed'
});
$('.overlay').visibility({
type: 'fixed',
offset: 80
});
// lazy load images
$('.image').visibility({
type: 'image',
transition: 'vertical flip in',
duration: 500
});
// show dropdown on hover
$('.main.menu .ui.dropdown').dropdown({
on: 'hover'
});
mGlobal.GUIRefreshTree=function()
{
///Загрузка данных
$.ajax({
type: "POST",
url: 'GUIAction',
data: '{"ModuleName":"GUI","ActivityName":"UIOSelector_GetChildList_UIOList","ArgumentList":[[]],"ArgumentDict":{"inBackend":"'+$(".openrpa-value-backend")[0].value+'"}}',
success:
function(lData,l2,l3)
{
var lResponseJSON=JSON.parse(lData)
///Очистить дерево
mGlobal.ElementTree.fClear();
///Прогрузить новое дерево
mGlobal.ElementTree.fRender(lResponseJSON.Result);
///Показать ошибку, если таковая возникла
if (lResponseJSON.hasOwnProperty("Error")) {
mGlobal.ShowModal("GUI Error",lResponseJSON.Error);
}
},
dataType: "text"
});
}
mGlobal.GUIRefreshTree();
mGlobal.ShowModal=function(inHeaderText,inMessageText)
{
//Установка заголовка
$('.ui.basic.modal div.header').html(inHeaderText);
//Установка текста
$('.ui.basic.modal div.content p').html(inMessageText);
//Активация модального окна
$('.ui.basic.modal').modal('show');
}
})
;
</script>
<style type="text/css">
body {
background-color: #FFFFFF;
}
.main.container {
margin-top: 2em;
}
.overlay {
float: left;
margin: 0em 3em 1em 0em;
}
.overlay .menu {
position: relative;
left: 0;
transition: left 0.5s ease;
}
.main.menu.fixed {
background-color: #FFFFFF;
border: 1px solid #DDD;
box-shadow: 0px 3px 5px rgba(0, 0, 0, 0.2);
}
.overlay.fixed .menu {
left: 800px;
}
.text.container .left.floated.image {
margin: 2em 2em 2em -4em;
}
.text.container .right.floated.image {
margin: 2em -4em 2em 2em;
}
.ui.footer.segment {
margin: 5em 0em 0em;
padding: 5em 0em;
}
</style>
</head>
<body>
<div class="ui internally celled grid">
<div class="row black">
<div class="three wide column">
<h1>Studio</h1>
</div>
<div class="eleven wide column">
<div class="ui input">
<input class="openrpa-value-backend" type="text" placeholder="Backend" value="win32">
</div>
</div>
<div class="two wide column">
<h2 class="ui header inverted" style="margin-bottom:5px;">OpenRPA</h2>
<h5 style="margin-top:5px;">by UnicodeLabs</h5>
</div>
</div>
<div class="row">
<div class="six wide column rpa-object-tree" >
</div>
<div class="six wide column rpa-hierarchy" >
<p>This example shows how to use lazy loaded images, a sticky menu, and a simple text container</p>
</div>
<div class="four wide column rpa-property-list" >
</div>
</div>
<div class="row black">
<div class="two wide column">
<button class="ui button grey labeled icon mini" onclick="mGlobal.GUIRefreshTree()">
<i class="up refresh icon"></i>
Refresh tree
</button>
</div>
<div class="two wide column">
<button class="ui button grey labeled icon mini">
<i class="up arrow icon"></i>
From
</button>
</div>
<div class="two wide column">
<button class="ui button grey labeled icon mini">
<i class="down arrow icon"></i>
To
</button>
</div>
<div class="ten wide column">
</div>
</div>
<div class="row">
<div class="eight wide column">
<div class="ui tiny header">Edit GUI selector</div>
<textarea style="width:100%; font-size:12pt" class="rpa-gui-selector" rows="6" cols="60"></textarea>
<button class="large ui blue button rpa-action-highlight" onclick="mGlobal.ElementHighlightNewGUISelectorString($('.rpa-gui-selector')[0].value);">Highlight element</button>
<button class="large ui grey button rpa-action-validate" onclick="mGlobal.ElementValidateGUISelectorString($('.rpa-gui-selector')[0].value);">Validate element</button>
<div class="ui tiny header">Validate Result</div>
<div class="content openrpa-validate-result divided list" style="overflow:scroll; height: 100px;"></div>
</div>
<div class="eight wide column">
<div class="ui tiny header">Select action</div>
<button class="ui button blue labeled icon" onclick="mGlobal.GUIActionLoadList();">
<i class="right arrow icon"></i>
Load actions
</button>
<div class="ui search selection dropdown gui-action" style="width:410px;">
<input type="hidden" name="country">
<i class="dropdown icon"></i>
<div class="default text">Select action</div>
<div class="menu">
</div>
</div>
<div class="ui tiny header">Set arguments</div>
<div class="ui input" style="width:500px;">
<input type="text" placeholder="[GUAActionArg1, GUAActionArg2...]" class="rpa-argument-list">
</div>
<p></p>
<button class="large ui green button" onclick="mGlobal.GUIActionRun();">Run action</button>
<button class="large ui grey button" onclick="mGlobal.GUIActionAddToList();">+ Code list</button>
<div class="ui tiny header">Result</div>
<div class="content gui-result"></div>
</div>
</div>
<div class="row black">
<div class="sixteen wide column">
</div>
</div>
<div class="row">
<div class="eight wide column">
<div class="ui tiny header">Additional actions</div>
<div class="content gui-code-list-run-result"></div>
<button class="large ui pink button" onclick="mGlobal.GUIActionWaitAddToList();">Wait element 60s: add to list</button>
<button class="large ui pink button" onclick="mGlobal.GUIActionSleep2sAddToList();">Sleep 2s: add to list</button>
</div>
<div class="eight wide column">
<div class="ui tiny header">Code list</div>
<div class="content gui-code-result"></div>
<button class="large ui green button" onclick="mGlobal.GUICodeListRun();">Run code list</button>
<button class="large ui pink button" onclick="$('.ui.modal.openrpa-code-list-gui-import-modal textarea')[0].value=''; $('.ui.modal.openrpa-code-list-gui-import-modal').modal('show');">Import from JSON</button>
<button class="large ui blue button openrpa-save-to-clipboard" onclick="mGlobal.ClipboardSet(JSON.stringify(mGlobal.ActionSpecificationList)); alert('Saved to clipboard!')">Export JSON to clipboard</button>
</div>
</div>
</div>
<div class="ui inverted vertical footer segment">
<div class="ui center aligned container">
<div class="ui stackable inverted divided grid">
<div class="three wide column">
<h4 class="ui inverted header">Pywinauto</h4>
<div class="ui inverted link list">
<a href="https://pywinauto.readthedocs.io/en/latest/code/pywinauto.findwindows.html" class="item" target="_blank">Specification manual</a>
<a href="https://pywinauto.readthedocs.io/en/latest/code/code.html#main-user-modules" class="item" target="_blank">Classes manual</a>
<a href="https://pywinauto.readthedocs.io/en/latest/code/code.html#main-user-modules" class="item" target="_blank">How to use manual</a>
<a href="https://pywinauto.readthedocs.io/en/latest/code/pywinauto.base_wrapper.html" class="item" target="_blank">Base wrapper manual</a>
</div>
</div>
<div class="three wide column">
<h4 class="ui inverted header">Semantic UI</h4>
<div class="ui inverted link list">
<a href="https://semantic-ui.com/usage/theming.html" class="item" target="_blank">Color manual</a>
<a href="https://semantic-ui.com/elements/input.html" class="item" target="_blank">Input manual</a>
<a href="https://semantic-ui.com/elements/icon.html" class="item" target="_blank">Icon list</a>
<a href="https://semantic-ui.com/elements/button.html" class="item" target="_blank">Button manual</a>
</div>
</div>
<div class="three wide column">
<h4 class="ui inverted header">GitLab</h4>
<div class="ui inverted link list">
<a href="https://gitlab.com/UnicodeLabs/OpenRPA" class="item" target="_blank">OpenRPA repository</a>
<a href="https://gitlab.com/UnicodeLabs" class="item" target="_blank">UnicodeLabs</a>
<a href="#" class="item">Link -</a>
<a href="#" class="item">Link -</a>
</div>
</div>
<div class="seven wide column">
<h4 class="ui inverted header">OpenRPA</h4>
<p>Open source Robotic Process Automation software by the Unicode Labs (Created by Ivan Maslov). Under the MIT license.</p>
</div>
</div>
<div class="ui inverted section divider"></div>
<div class="ui horizontal inverted small divided link list">
<a class="item" href="#">Site Map</a>
<a class="item" href="#">Contact Us</a>
<a class="item" href="#">Terms and Conditions</a>
<a class="item" href="#">Privacy Policy</a>
</div>
</div>
</div>
<div class="ui basic modal">
<div class="ui icon header">
</div>
<div class="content">
<p>Here is the message text!</p>
</div>
<div class="actions">
<div class="ui red basic cancel inverted button">
<i class="remove icon"></i>
No
</div>
<div class="ui green ok inverted button">
<i class="checkmark icon"></i>
Yes
</div>
</div>
</div>
<div class="ui modal openrpa-code-list-gui-import-modal">
<i class="close icon"></i>
<div class="header">
Code list import
</div>
<div class="content">
<div class="description">
<div class="ui header">Insert your JSON specification here.</div>
<p><textarea style="width:100%" rows="6" cols="60"></textarea></p>
</div>
</div>
<div class="actions">
<div class="ui black deny button">
Cancel
</div>
<div class="ui positive right labeled icon button" onclick="mGlobal.CodeList.fActionSpecificationImportFromJSON();">
Parse
<i class="checkmark icon"></i>
</div>
</div>
</div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Loading…
Cancel
Save