# Keyboar - hotkey fix with rdp - need UAT

dev-linux
Ivan Maslov 5 years ago
parent 7ca1c2b6b3
commit be364e5e42

@ -21,6 +21,8 @@ gRecoveryWindowRUNRetryIntervalSecInt = 3 # Retry interval for retry
gRecoveryCMDResponsibleRetryCountInt = 3 # Retry iteration count is CMD is not responsible gRecoveryCMDResponsibleRetryCountInt = 3 # Retry iteration count is CMD is not responsible
gRecoveryCMDResponsibleRetryIntervalSecInt = 3 # Retry interval for retry gRecoveryCMDResponsibleRetryIntervalSecInt = 3 # Retry interval for retry
gKeyboardHotkeyDelaySecFloat = 0.6 # Const for delay - important for work with RDP!!!!
#Connect to RDP session #Connect to RDP session
""" """
{ {
@ -312,16 +314,15 @@ def SystemCMDRun(inSessionHexStr, inCMDCommandStr = "echo 1", inModeStr="CROSSCH
lCMDPostFixStr = f"& (echo {lCrosscheckKeyStr} | clip)" lCMDPostFixStr = f"& (echo {lCrosscheckKeyStr} | clip)"
elif inModeStr == "LISTEN": elif inModeStr == "LISTEN":
lCMDPostFixStr = f"| clip" lCMDPostFixStr = f"| clip"
keyboard.press_and_release('win+r') KeyboardHotkey("win","r") # win+r
time.sleep(1) # Wait for RUN window will appear KeyboardHotkey("ctrl","a") # Select all
lRDPWindow.type_keys("^(a)") # Select all keyboard.send("backspace") # Delete selected all
keyboard.press_and_release("backspace") # Delete selected all time.sleep(gKeyboardHotkeyDelaySecFloat) # Wait for RUN window will appear ctrl+a+backspace is async - so we need some timeout...
time.sleep(0.5) # 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 lInputStr = f"cmd /c ({inCMDCommandStr}) {lCMDPostFixStr}" # Generate the output string for RUN window
keyboard.write(lInputStr) # Write new text keyboard.write(lInputStr) # Write new text
time.sleep(0.5) time.sleep(gKeyboardHotkeyDelaySecFloat)
lRDPWindow.type_keys("^(a)") # Select all KeyboardHotkey("ctrl","a") # Select all
lRDPWindow.type_keys("^(c)") # Copy data KeyboardHotkey("ctrl","c") # Copy data
# Check the clipboard # Check the clipboard
lClipboardWaitTimeStartSec = time.time() lClipboardWaitTimeStartSec = time.time()
lClipboardStr = Clipboard.TextGet() # Get text from clipboard 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"}, UIDesktop.UIOSelector_Get_UIO([{"title": "Remote Desktop Connection", "class_name": "#32770", "backend": "win32"},
{"title": "OK", "class_name": "Button"}]).click() {"title": "OK", "class_name": "Button"}]).click()
except Exception as e: except Exception as e:
pass 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)
Loading…
Cancel
Save