From afe13e94178d3cfc7730373e3f350f5f82596270 Mon Sep 17 00:00:00 2001 From: Ivan Maslov Date: Wed, 11 Mar 2020 17:38:00 +0300 Subject: [PATCH] # OpenRPA - hot fixes after the first run --- Sources/pyOpenRPA/Tools/RobotRDPActive/CMDStr.py | 8 +++++--- Sources/pyOpenRPA/Tools/RobotRDPActive/Connector.py | 1 + .../RobotRDPActive/GlobalDictSessionIndex_Defs.py | 11 ++++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Sources/pyOpenRPA/Tools/RobotRDPActive/CMDStr.py b/Sources/pyOpenRPA/Tools/RobotRDPActive/CMDStr.py index 77a6a098..02a2651a 100644 --- a/Sources/pyOpenRPA/Tools/RobotRDPActive/CMDStr.py +++ b/Sources/pyOpenRPA/Tools/RobotRDPActive/CMDStr.py @@ -1,11 +1,13 @@ import os # Get abs path of the file # Create CMD str to run file if process.exe is not running -def ProcessStartIfNotRunning(inProcessName, inFilePath): - lFileAbsPath = os.abspath(inFilePath) +def ProcessStartIfNotRunning(inProcessName, inFilePath, inFlagGetAbsPath=True): + lFileAbsPath = inFilePath + if inFlagGetAbsPath: + lFileAbsPath = os.path.abspath(inFilePath) lResult = f'tasklist /nh /fi "imagename eq {inProcessName}" | find /i "{inProcessName}" > nul || (start {lFileAbsPath})' return lResult # Create CMD str to stop process -def ProcessStop(inProcessName, inFlagForceClose) +def ProcessStop(inProcessName, inFlagForceClose): lResult = f'taskkill /im "{inProcessName}" /fi "username eq %USERNAME%"' if inFlagForceClose: lResult+= " /F" diff --git a/Sources/pyOpenRPA/Tools/RobotRDPActive/Connector.py b/Sources/pyOpenRPA/Tools/RobotRDPActive/Connector.py index ad407504..45abf837 100644 --- a/Sources/pyOpenRPA/Tools/RobotRDPActive/Connector.py +++ b/Sources/pyOpenRPA/Tools/RobotRDPActive/Connector.py @@ -133,6 +133,7 @@ def SessionScreenFull(inSessionHex): #Prepare little window lRDPWindow = UIDesktop.UIOSelector_Get_UIO([{"title_re": f"{inSessionHex}.*", "backend": "win32"}]) lRDPWindow.set_focus() + lRDPWindow.maximize() if not SessionIsFullScreen(inSessionHex): lRDPWindow.type_keys("^%{BREAK}") time.sleep(0.5) diff --git a/Sources/pyOpenRPA/Tools/RobotRDPActive/GlobalDictSessionIndex_Defs.py b/Sources/pyOpenRPA/Tools/RobotRDPActive/GlobalDictSessionIndex_Defs.py index a8297715..9ddcc3ee 100644 --- a/Sources/pyOpenRPA/Tools/RobotRDPActive/GlobalDictSessionIndex_Defs.py +++ b/Sources/pyOpenRPA/Tools/RobotRDPActive/GlobalDictSessionIndex_Defs.py @@ -1,13 +1,14 @@ -from . import CMDStr # Create CMD Strings -from . import Connector # RDP API -def ProcessStartIfNotRunning(inGlobalDict, inSessionIndex, inProcessName, inFilePath): - lCMDStr = CMDStr.ProcessStartIfNotRunning(inProcessName,inFilePath) +# ATTENTION! HERE IS NO Relative import because it will be imported dynamically +from pyOpenRPA.Tools.RobotRDPActive import CMDStr # Create CMD Strings +from pyOpenRPA.Tools.RobotRDPActive import Connector # RDP API +def ProcessStartIfNotRunning(inGlobalDict, inSessionIndex, inProcessName, inFilePath, inFlagGetAbsPath=True): + lCMDStr = CMDStr.ProcessStartIfNotRunning(inProcessName,inFilePath, inFlagGetAbsPath= inFlagGetAbsPath) # Calculate the session Hex lSessionHex = inGlobalDict["RDPList"][inSessionIndex]["SessionHex"] # Run CMD Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="RUN") # Create CMD str to stop process -def ProcessStop(inGlobalDict, inSessionIndex, inProcessName, inFlagForceClose) +def ProcessStop(inGlobalDict, inSessionIndex, inProcessName, inFlagForceClose): lCMDStr = f'taskkill /im "{inProcessName}" /fi "username eq %USERNAME%"' if inFlagForceClose: lCMDStr+= " /F"