|
|
@ -19,40 +19,22 @@ import subprocess
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
def SessionConnect(inRDPSessionConfiguration):
|
|
|
|
def Session(inRDPSessionConfiguration):
|
|
|
|
#Run mstsc
|
|
|
|
#RDPConnector.SessionConnect(mConfiguration)
|
|
|
|
from pywinauto.application import Application
|
|
|
|
#RDPConnector.LoginPassSet("111.222.222.111","ww","dd")
|
|
|
|
lRDPApplication = Application(backend="uia").start("mstsc.exe")
|
|
|
|
(lRDPFile, lSessionHex) = SessionConfigurationCreate(inRDPSessionConfiguration)
|
|
|
|
lProcessId = lRDPApplication.process
|
|
|
|
#Set session hex in globalDict
|
|
|
|
#Expand the parameter section
|
|
|
|
inRDPSessionConfiguration["SessionHex"] = lSessionHex
|
|
|
|
UIDesktop.UIOSelector_Get_UIO(
|
|
|
|
#Set login/password
|
|
|
|
[
|
|
|
|
SessionLoginPasswordSet(inRDPSessionConfiguration["Host"],inRDPSessionConfiguration["Login"],inRDPSessionConfiguration["Password"])
|
|
|
|
{"process": lProcessId, "backend": "uia"},
|
|
|
|
#Start session
|
|
|
|
{"class_name": "ToolbarWindow32"},
|
|
|
|
SessionRDPStart(lRDPFile)
|
|
|
|
{"title": "Показать параметры ", "control_type": "Button"}]
|
|
|
|
#Remove temp file
|
|
|
|
).click()
|
|
|
|
time.sleep(4) #Delete file after some delay - one way to delete and run the RDP before because RDP is not read file in one moment
|
|
|
|
#Select flag ask login/pass
|
|
|
|
os.remove(lRDPFile) # delete the temp rdp
|
|
|
|
UIDesktop.UIOSelector_Get_UIO(
|
|
|
|
return inRDPSessionConfiguration
|
|
|
|
[
|
|
|
|
|
|
|
|
{"process": lProcessId, "backend": "win32"},
|
|
|
|
|
|
|
|
{"title":"Общие"},
|
|
|
|
|
|
|
|
{"title":"Учетные данные"},
|
|
|
|
|
|
|
|
{"title":"&Всегда запрашивать учетные данные", "class_name":"Button"}]
|
|
|
|
|
|
|
|
).check()
|
|
|
|
|
|
|
|
#Set host:port
|
|
|
|
|
|
|
|
lHostPort=inRDPSessionConfiguration['Host']
|
|
|
|
|
|
|
|
if 'Port' in inRDPSessionConfiguration:
|
|
|
|
|
|
|
|
lHostPort=f"{lHostPort}:{inRDPSessionConfiguration['Port']}"
|
|
|
|
|
|
|
|
UIDesktop.UIOSelector_Get_UIO(
|
|
|
|
|
|
|
|
[
|
|
|
|
|
|
|
|
{"process": lProcessId, "backend": "uia"},
|
|
|
|
|
|
|
|
{"title": "Компьютер:"},
|
|
|
|
|
|
|
|
{"title": "Компьютер:", "control_type": "Edit"}]
|
|
|
|
|
|
|
|
).set_text(f"{lHostPort}")
|
|
|
|
|
|
|
|
#Set user
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
#Add login/ password to the windows credentials to run RDP
|
|
|
|
#Add login/ password to the windows credentials to run RDP
|
|
|
|
def LoginPassSet(inHost,inLogin,inPassword):
|
|
|
|
def SessionLoginPasswordSet(inHost, inLogin, inPassword):
|
|
|
|
#Clear old login/password if it exists
|
|
|
|
#Clear old login/password if it exists
|
|
|
|
#os.system(f"cmdkey /delete:TERMSRV/{inHost}") #Dont need to delete because new user password will clear the previous creds
|
|
|
|
#os.system(f"cmdkey /delete:TERMSRV/{inHost}") #Dont need to delete because new user password will clear the previous creds
|
|
|
|
#Set login password for host
|
|
|
|
#Set login password for host
|
|
|
@ -60,7 +42,7 @@ def LoginPassSet(inHost,inLogin,inPassword):
|
|
|
|
return None
|
|
|
|
return None
|
|
|
|
#Create current .rdp file with settings
|
|
|
|
#Create current .rdp file with settings
|
|
|
|
#Return (full path to file, session hex)
|
|
|
|
#Return (full path to file, session hex)
|
|
|
|
def RDPConfigurationCreate(inConfiguration):
|
|
|
|
def SessionConfigurationCreate(inConfiguration):
|
|
|
|
#RobotRDPActive folder path
|
|
|
|
#RobotRDPActive folder path
|
|
|
|
lFileFullPath=__file__
|
|
|
|
lFileFullPath=__file__
|
|
|
|
lFileFullPath = lFileFullPath.replace("/","\\")
|
|
|
|
lFileFullPath = lFileFullPath.replace("/","\\")
|
|
|
@ -72,10 +54,11 @@ def RDPConfigurationCreate(inConfiguration):
|
|
|
|
#Prepare host:port
|
|
|
|
#Prepare host:port
|
|
|
|
lHostPort=inConfiguration['Host']
|
|
|
|
lHostPort=inConfiguration['Host']
|
|
|
|
if 'Port' in inConfiguration:
|
|
|
|
if 'Port' in inConfiguration:
|
|
|
|
|
|
|
|
if inConfiguration['Port']:
|
|
|
|
lHostPort=f"{lHostPort}:{inConfiguration['Port']}"
|
|
|
|
lHostPort=f"{lHostPort}:{inConfiguration['Port']}"
|
|
|
|
#Replace {Width}, {Height}, {BitDepth}, {HostPort}, {Login}
|
|
|
|
#Replace {Width}, {Height}, {BitDepth}, {HostPort}, {Login}
|
|
|
|
lRDPTemplateFileContent = lRDPTemplateFileContent.replace("{Width}", str(1680))
|
|
|
|
lRDPTemplateFileContent = lRDPTemplateFileContent.replace("{Width}", inConfiguration.get('Screen',{}).get("Width",1680))
|
|
|
|
lRDPTemplateFileContent = lRDPTemplateFileContent.replace("{Height}", str(1050))
|
|
|
|
lRDPTemplateFileContent = lRDPTemplateFileContent.replace("{Height}", inConfiguration.get('Screen',{}).get("Height",1050))
|
|
|
|
lRDPTemplateFileContent = lRDPTemplateFileContent.replace("{BitDepth}", inConfiguration.get('Screen',{}).get("DepthBit","32"))
|
|
|
|
lRDPTemplateFileContent = lRDPTemplateFileContent.replace("{BitDepth}", inConfiguration.get('Screen',{}).get("DepthBit","32"))
|
|
|
|
lRDPTemplateFileContent = lRDPTemplateFileContent.replace("{HostPort}", lHostPort)
|
|
|
|
lRDPTemplateFileContent = lRDPTemplateFileContent.replace("{HostPort}", lHostPort)
|
|
|
|
lRDPTemplateFileContent = lRDPTemplateFileContent.replace("{Login}", inConfiguration['Login'])
|
|
|
|
lRDPTemplateFileContent = lRDPTemplateFileContent.replace("{Login}", inConfiguration['Login'])
|
|
|
@ -85,7 +68,7 @@ def RDPConfigurationCreate(inConfiguration):
|
|
|
|
#Return .rdp full path
|
|
|
|
#Return .rdp full path
|
|
|
|
return (lRDPCurrentFileFullPath, (lRDPCurrentFileFullPath.split("\\")[-1])[0:-4])
|
|
|
|
return (lRDPCurrentFileFullPath, (lRDPCurrentFileFullPath.split("\\")[-1])[0:-4])
|
|
|
|
#RDPSessionStart
|
|
|
|
#RDPSessionStart
|
|
|
|
def RDPSessionStart(inRDPFilePath):
|
|
|
|
def SessionRDPStart(inRDPFilePath):
|
|
|
|
#run rdp session
|
|
|
|
#run rdp session
|
|
|
|
lItemArgs = [inRDPFilePath]
|
|
|
|
lItemArgs = [inRDPFilePath]
|
|
|
|
subprocess.Popen(lItemArgs, shell=True)
|
|
|
|
subprocess.Popen(lItemArgs, shell=True)
|
|
|
@ -116,18 +99,18 @@ def RDPSessionStart(inRDPFilePath):
|
|
|
|
60
|
|
|
|
60
|
|
|
|
)
|
|
|
|
)
|
|
|
|
#Prepare little window
|
|
|
|
#Prepare little window
|
|
|
|
SessionLittleScreen(lRDPFileName)
|
|
|
|
SessionScreen100x550(lRDPFileName)
|
|
|
|
return None
|
|
|
|
return None
|
|
|
|
#Set fullscreen for app
|
|
|
|
#Set fullscreen for app
|
|
|
|
def SessionFullScreen(inSessionHex):
|
|
|
|
def SessionScreenFull(inSessionHex):
|
|
|
|
#Prepare little window
|
|
|
|
#Prepare little window
|
|
|
|
lRDPWindow = UIDesktop.UIOSelector_Get_UIO([{"title_re": f"{lRDPFileName} — .*", "backend": "win32"}])
|
|
|
|
lRDPWindow = UIDesktop.UIOSelector_Get_UIO([{"title_re": f"{inSessionHex} — .*", "backend": "win32"}])
|
|
|
|
lRDPWindow.maximize()
|
|
|
|
lRDPWindow.maximize()
|
|
|
|
return None
|
|
|
|
return None
|
|
|
|
#Set Little window of the session
|
|
|
|
#Set Little window of the session
|
|
|
|
def SessionLittleScreen(inSessionHex):
|
|
|
|
def SessionScreen100x550(inSessionHex):
|
|
|
|
#Prepare little window
|
|
|
|
#Prepare little window
|
|
|
|
lRDPWindow = UIDesktop.UIOSelector_Get_UIO([{"title_re": f"{lRDPFileName} — .*", "backend": "win32"}])
|
|
|
|
lRDPWindow = UIDesktop.UIOSelector_Get_UIO([{"title_re": f"{inSessionHex} — .*", "backend": "win32"}])
|
|
|
|
lRDPWindow.restore()
|
|
|
|
lRDPWindow.restore()
|
|
|
|
lRDPWindow.move_window(10,10,550,100)
|
|
|
|
lRDPWindow.move_window(10,10,550,100)
|
|
|
|
return None
|
|
|
|
return None
|