# Beta - dont use as release Tool RobotRDPActive

dev-linux
Ivan Maslov 5 years ago
parent b3f8da1821
commit b02acc1a14

@ -0,0 +1,39 @@
import win32clipboard
import keyboard # keyboard functions
import time # Some operations need wait
import random # random number for test
# set clipboard data
def TextSet(inTextStr):
win32clipboard.OpenClipboard()
win32clipboard.EmptyClipboard()
win32clipboard.SetClipboardText(inTextStr)
win32clipboard.CloseClipboard()
# get clipboard data
def TextGet():
win32clipboard.OpenClipboard()
data = win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()
return data
# Test in has text cursor and ready to apply
def InputIsFocused():
keyboard.press_and_release("ctrl+a")
keyboard.press_and_release("backspace") # remove old text
lTextForTest = str(random.randrange(100,99999))
keyboard.write(lTextForTest)
keyboard.press_and_release("ctrl+a")
keyboard.press_and_release("ctrl+c")
time.sleep(2)
keyboard.press_and_release("backspace") # remove old text
lClipboardText = TextGet()
lResult = lClipboardText == lTextForTest
return lResult
# Check if cmd is opened
def CMDIsOpen():
lTextForTest = str(random.randrange(100,99999))
keyboard.write(lTextForTest+" |clip")
keyboard.press_and_release("enter")
time.sleep(2)
lClipboardText = TextGet()
lResult = lClipboardText == lTextForTest
return lResult

@ -5,6 +5,7 @@ import uuid #temp id for Template.rdp
import tempfile #Temporary location import tempfile #Temporary location
import time import time
import subprocess import subprocess
from . import Clipboard # Clipboard functions get/set
#Connect to RDP session #Connect to RDP session
""" """
{ {
@ -123,7 +124,7 @@ def SessionRDPStart(inRDPFilePath):
#Set fullscreen for app #Set fullscreen for app
def SessionScreenFull(inSessionHex): def SessionScreenFull(inSessionHex):
#Prepare little window #Prepare little window
lRDPWindow = UIDesktop.UIOSelector_Get_UIO([{"title_re": f"{inSessionHex}.*", "backend": "win32"}]) lRDPWindow = UIDesktop.UIOSelector_Get_UIO([{"title_re": f"{inSessionHex}.*", "backend": "uia"}]) #Hotfix uia is needed to set focus in RDP
lRDPWindow.maximize() lRDPWindow.maximize()
lRDPWindow.set_focus() lRDPWindow.set_focus()
return None return None
@ -131,7 +132,10 @@ def SessionScreenFull(inSessionHex):
def SessionScreen100x550(inSessionHex): def SessionScreen100x550(inSessionHex):
#Prepare little window #Prepare little window
lRDPWindow = UIDesktop.UIOSelector_Get_UIO([{"title_re": f"{inSessionHex}.*", "backend": "win32"}]) lRDPWindow = UIDesktop.UIOSelector_Get_UIO([{"title_re": f"{inSessionHex}.*", "backend": "win32"}])
lRDPWindow.restore() #lRDPWindow.minimize()
#lRDPWindow.restore()
lRDPWindow.maximize()
lRDPWindow.type_keys("^%{BREAK}") # Ctrl + alt + creak to return window from full screen correctly
lRDPWindow.move_window(10,10,550,100) lRDPWindow.move_window(10,10,550,100)
return None return None
import keyboard import keyboard
@ -139,8 +143,15 @@ import time
#Type command in CMD #Type command in CMD
def SessionCMDRun(inSessionHex,inCMDCommandStr): def SessionCMDRun(inSessionHex,inCMDCommandStr):
SessionScreenFull(inSessionHex) SessionScreenFull(inSessionHex)
time.sleep(2) # High priority
keyboard.press_and_release('win+r') keyboard.press_and_release('win+r')
time.sleep(2) time.sleep(2)
keyboard.write(f"cmd {inCMDCommandStr}") print(Clipboard.InputIsFocused())
keyboard.write(f"cmd")
keyboard.press_and_release('enter') keyboard.press_and_release('enter')
time.sleep(2) # Only time wait we can set here :(
print(Clipboard.CMDIsOpen())
keyboard.write(f"{inCMDCommandStr} && exit") # Run CMD command and close CMD console
keyboard.press_and_release('enter')
time.sleep(2)
SessionScreen100x550(inSessionHex) SessionScreen100x550(inSessionHex)

@ -1,6 +1,7 @@
from pyOpenRPA.Robot import UIDesktop from pyOpenRPA.Robot import UIDesktop
from . import Connector from . import Connector
import os import os
import time # Time wait operations
import pdb import pdb
#Check for session is closed. Reopen if detected. Always keep session is active #Check for session is closed. Reopen if detected. Always keep session is active
def Monitor(inGlobalDict, inListUpdateTimeout): def Monitor(inGlobalDict, inListUpdateTimeout):
@ -51,5 +52,15 @@ def Monitor(inGlobalDict, inListUpdateTimeout):
Connector.SessionScreenFull(inGlobalDict["RDPList"][inGlobalDict["OrchestratorToRobotStorage"]["FullScreenSessionIndex"]]["SessionHex"]) Connector.SessionScreenFull(inGlobalDict["RDPList"][inGlobalDict["OrchestratorToRobotStorage"]["FullScreenSessionIndex"]]["SessionHex"])
#Set one to other equal #Set one to other equal
inGlobalDict["FullScreenSessionIndex"] = inGlobalDict["OrchestratorToRobotStorage"]["FullScreenSessionIndex"] inGlobalDict["FullScreenSessionIndex"] = inGlobalDict["OrchestratorToRobotStorage"]["FullScreenSessionIndex"]
###########################################
# Check ActivityList from orchestrator
for lActivityItem in inGlobalDict["OrchestratorToRobotResetStorage"]["ActivityList"]:
# Check case CMDCommand
if lActivityItem["Type"] == "CMDCommand":
pass
# CMD command passed
#Connector.SessionCMDRun(inSessionHex=lActivityItem["SessionHex"], inCMDCommandStr= lActivityItem["CMDValue"])
# loop interval
time.sleep(2)
return None return None
#TODO Def garbage window cleaner (if connection was lost) #TODO Def garbage window cleaner (if connection was lost)

@ -41,6 +41,7 @@ for lConfigurationItem in mGlobalDict["RDPList"]:
except Exception: except Exception:
pass pass
#Run monitor #Run monitor
print(mGlobalDict)
Monitor.Monitor(mGlobalDict, 1) Monitor.Monitor(mGlobalDict, 1)
#Enable certificate warning #Enable certificate warning
lCMDString = 'reg add "HKEY_CURRENT_USER\\Software\\Microsoft\\Terminal Server Client" /v "AuthenticationLevelOverride" /t "REG_DWORD" /d 2 /f' lCMDString = 'reg add "HKEY_CURRENT_USER\\Software\\Microsoft\\Terminal Server Client" /v "AuthenticationLevelOverride" /t "REG_DWORD" /d 2 /f'

@ -36,6 +36,10 @@ def Settings():
}, },
"OrchestratorToRobotResetStorage": { "OrchestratorToRobotResetStorage": {
"SafeTurnOff":False #Control from orchestrator to safety turn off robot "SafeTurnOff":False #Control from orchestrator to safety turn off robot
"ActivityList":[
{"Type":"CMDCommand", "CMDValue"},
{"Type":"CreateFile","FileFullPath": "" ,"FileBytes": None}
]
}, },
"OrchestratorConnector": { "OrchestratorConnector": {
#Fill below #Fill below
@ -73,7 +77,7 @@ def Settings():
"Interval": 3.3, "Interval": 3.3,
"RobotStorage": mDict, "RobotStorage": mDict,
"RobotStorageKey": "OrchestratorToRobotResetStorage", "RobotStorageKey": "OrchestratorToRobotResetStorage",
"RobotResetValue": {"SafeTurnOff":False}, "RobotResetValue": mDict["OrchestratorToRobotResetStorage"],
"OrchestratorKeyList": ["Storage", "RobotRDPActive","OrchestratorToRobotResetStorage"], "OrchestratorKeyList": ["Storage", "RobotRDPActive","OrchestratorToRobotResetStorage"],
"OrchestratorProtocol": lOrchestratorProtocol, "OrchestratorProtocol": lOrchestratorProtocol,
"OrchestratorHost": lOrchestratorHost, "OrchestratorHost": lOrchestratorHost,

Loading…
Cancel
Save