From be364e5e4205a6fb0d78b92914aedc39209f3276 Mon Sep 17 00:00:00 2001 From: Ivan Maslov Date: Mon, 1 Jun 2020 23:10:04 +0300 Subject: [PATCH] # Keyboar - hotkey fix with rdp - need UAT --- .../Orchestrator/RobotRDPActive/Connector.py | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/Sources/pyOpenRPA/Orchestrator/RobotRDPActive/Connector.py b/Sources/pyOpenRPA/Orchestrator/RobotRDPActive/Connector.py index 0d969130..ff93abd7 100644 --- a/Sources/pyOpenRPA/Orchestrator/RobotRDPActive/Connector.py +++ b/Sources/pyOpenRPA/Orchestrator/RobotRDPActive/Connector.py @@ -21,6 +21,8 @@ gRecoveryWindowRUNRetryIntervalSecInt = 3 # Retry interval for retry gRecoveryCMDResponsibleRetryCountInt = 3 # Retry iteration count is CMD is not responsible gRecoveryCMDResponsibleRetryIntervalSecInt = 3 # Retry interval for retry +gKeyboardHotkeyDelaySecFloat = 0.6 # Const for delay - important for work with RDP!!!! + #Connect to RDP session """ { @@ -312,16 +314,15 @@ def SystemCMDRun(inSessionHexStr, inCMDCommandStr = "echo 1", inModeStr="CROSSCH lCMDPostFixStr = f"& (echo {lCrosscheckKeyStr} | clip)" elif inModeStr == "LISTEN": lCMDPostFixStr = f"| clip" - keyboard.press_and_release('win+r') - time.sleep(1) # Wait for RUN window will appear - lRDPWindow.type_keys("^(a)") # Select all - keyboard.press_and_release("backspace") # Delete selected all - time.sleep(0.5) # Wait for RUN window will appear ctrl+a+backspace is async - so we need some timeout... + KeyboardHotkey("win","r") # win+r + KeyboardHotkey("ctrl","a") # Select all + keyboard.send("backspace") # Delete selected all + time.sleep(gKeyboardHotkeyDelaySecFloat) # Wait for RUN window will appear ctrl+a+backspace is async - so we need some timeout... lInputStr = f"cmd /c ({inCMDCommandStr}) {lCMDPostFixStr}" # Generate the output string for RUN window keyboard.write(lInputStr) # Write new text - time.sleep(0.5) - lRDPWindow.type_keys("^(a)") # Select all - lRDPWindow.type_keys("^(c)") # Copy data + time.sleep(gKeyboardHotkeyDelaySecFloat) + KeyboardHotkey("ctrl","a") # Select all + KeyboardHotkey("ctrl","c") # Copy data # Check the clipboard lClipboardWaitTimeStartSec = time.time() lClipboardStr = Clipboard.TextGet() # Get text from clipboard @@ -392,4 +393,12 @@ def SystemRDPWarningClickOk(): UIDesktop.UIOSelector_Get_UIO([{"title": "Remote Desktop Connection", "class_name": "#32770", "backend": "win32"}, {"title": "OK", "class_name": "Button"}]).click() except Exception as e: - pass \ No newline at end of file + pass +# Bugfix with RDP work +def KeyboardHotkey(inModifierKeyStr,inKeyStr, inDelaySecFloat=gKeyboardHotkeyDelaySecFloat): + keyboard.press(inModifierKeyStr) + time.sleep(inDelaySecFloat) + keyboard.send(inKeyStr) + time.sleep(inDelaySecFloat) + keyboard.release(inModifierKeyStr) + time.sleep(inDelaySecFloat) \ No newline at end of file