Jump to content

RDP Session In AutoIT Gui


goss34
 Share

Recommended Posts

Hi Guys,

I have been scouring the forums but cant find what i want so i am hoping someone can help me out by pointing me in the right direction or starting me off with how to build the script from scratch.

What i want to be able to achieve is:

  • Have the script hunt for a machine that is available from a group of say 4 (how it will know its available i dont know?)
  • When a free machine is found launch an RDP session within the autoit window (scaling the window to fit in the GUI)
First off is this possible?

Second, can someone help me get started?

Thanks

Dan

Link to comment
Share on other sites

  • 2 weeks later...

Try this uncomplete version:

#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
 
$host = "" ;<<<<<<< enter here the host name or ip address
;Remote Desktop ActiveX Control Interfaces -> http://msdn.microsoft.com/en-us/library/aa383022(v=VS.85).aspx
$hGUI = GUICreate("RDP Embedded Sessions", 952, 675, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
$oRDP = ObjCreate("MsTscAx.MsTscAx.2") ;http://msdn.microsoft.com/en-us/library/aa381344(v=VS.85).aspx
$oRDP_Ctrl = GUICtrlCreateObj($oRDP, 64, 44, 800, 600)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
GUICtrlSetStyle($oRDP_Ctrl , $WS_VISIBLE)
$oRDP.DesktopWidth = 800
$oRDP.DesktopHeight = 600
$oRDP.Fullscreen = False
$oRDP.ColorDepth = 16
$oRDP.AdvancedSettings3.SmartSizing = True
$oRDP.Server = $host
$oRDP.UserName = "" ;<<<<<<< enter here the user name
$oRDP.Domain = ""
$oRDP.AdvancedSettings2.ClearTextPassword = ""
$oRDP.ConnectingText = "Connecting to " & $host
$oRDP.DisconnectedText = "Disconnected from " & $host
$oRDP.StartConnected = True
$oRDP.Connect()
 
GUISetState(@SW_SHOW, $hGUI)
;~ ConsoleWrite($oRDP.GetErrorDescription() & @CRLF)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            $oRDP.Disconnect()
            Exit
    EndSwitch
WEnd

It will open a RDP session embedded in the GUI.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • 6 months later...

Thanks UEZ.

Exactly the one I'm searching for. The above script works as expected. But it only runs when I run this script from SciTE4AutoIt3 editor.

After I build this script as exe, that exe fails to connect that system. It just hangs and displays a message 'Connecting to 172.16.0.160'. I didn't modify this script expect the following lines.

$host = "172.16.0.160"

$oRDP.UserName = "administrator"

Exe should be perfectly same as the script. I'm just wondering how it works like a charm when I run from the editor but the exe hangs to connect.

Any Help is appreciated. If you need any more information to help me please let me know.

Thanks in advance for your help.

post-67499-0-51208500-1334415181_thumb.j

Edited by pilot
Link to comment
Share on other sites

  • 4 months later...

Thankd UEZ

I've added some change to the original.

you need to create an ini file RDP_QC.ini in the same location as the au3 or exe file.

[serveurs]

Server1 = Server1

Server2 = Server2

Server3 = Server3

enjoy !

#include <GUIConstants.au3>

#include <GUIConstantsEx.au3>

#include <WinAPI.au3>

#include <WindowsConstants.au3>

#include <EditConstants.au3>

Opt("GUIOnEventMode", 1)

#Region ### START Koda GUI section ### Form=

$hGUI = GUICreate("Form1", 1401, 801, 193, 115)

GUISetOnEvent($GUI_EVENT_CLOSE, "hGUIClose")

$Connect = GUICtrlCreateButton("Connect", 1272, 16, 115, 33, 0)

GUICtrlSetOnEvent(-1, "ConnectClick")

$Password = GUICtrlCreateInput("", 1272, 200, 115, 23, $ES_PASSWORD)

GUICtrlSetOnEvent(-1, "ConnectClick")

$oRDP = ObjCreate("MsTscAx.MsTscAx.2") ;http://msdn.microsoft.com/en-us/library/aa381344(v=VS.85).aspx

$oRDP_Ctrl = GUICtrlCreateObj($oRDP, 4, 4, 1232, 792)

GUICtrlSetResizing(-1, $GUI_DOCKALL)

GUICtrlSetStyle($oRDP_Ctrl , $WS_VISIBLE)

GUICtrlSetStyle($oRDP_Ctrl , $WS_EX_STATICEDGE)

$oRDP.DesktopWidth = 1240

$oRDP.DesktopHeight = 800

$oRDP.Fullscreen = False

$oRDP.ColorDepth = 16

$oRDP.AdvancedSettings3.SmartSizing = True

$serveur = GUICtrlCreateCombo("", 1272, 50, 120, 23)

GUICtrlSetData(-1, "", "")

GUICtrlSetFont(-1, 9, 800, 0, "Courier new")

GUICtrlSetOnEvent(-1, "ConnectClick")

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

Call("Load_srv")

While 1

Sleep(100)

WEnd

Func ConnectClick()

$host = GUICtrlRead($serveur,1) ;<<<<<<< enter here the host name or ip address

if $host <> "" Then

$oRDP.Server = $host

$oRDP.UserName = "" ;<<<<<<< enter here the user name

$oRDP.Domain = ""

$oRDP.AdvancedSettings2.ClearTextPassword = GUICtrlRead($Password)

$oRDP.ConnectingText = "Connecting to " & $host

$oRDP.DisconnectedText = "Disconnected from " & $host

$oRDP.StartConnected = True

$oRDP.connect()

endIf

EndFunc

func Load_srv()

$var = IniReadSection(@ScriptDir & "\RDP_QC.ini","Serveurs")

For $i = 1 To $var[0][0]

;~ MsgBox(4096, "", "Key: " & $var[$i][0] & @CRLF & "Value: " & $var[$i][1])

GUICtrlSetData($serveur,$var[$i][1])

Next

endFunc

Func hGUIClose()

exit

EndFunc

Link to comment
Share on other sites

  • 5 months later...

Please don't resurrect old threads, especially when you just want to learn something that can be found via the help file. My suggestion, read the help file as this will be a great source of help.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

I can give you guidance, what I can't do is speed up the process of you learning it. The help file is a great place to start, trust me. If you have little time, then perhaps an alternative source would be an option?

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

You're welcome. Good luck.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

  • 1 year later...

Hi everybody,

I need to resize the "Rdp embedded sessions" in order to resize $oRDP in the same size without borders

Anybody can help me ?

Thanks

I have the following code :

#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

$host = "" ;<<<<<<< enter here the host name or ip address

$hGUI = GUICreate("Terminal server", 900, 700, -1, -1, BitOR($GUI_SS_DEFAULT_GUI,$WS_SIZEBOX,$WS_THICKFRAME))

$oRDP = ObjCreate("MsTscAx.MsTscAx.2")
$oRDP_Ctrl = GUICtrlCreateObj($oRDP, 0, 0, 900, 700)

GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
GUICtrlSetStyle($oRDP_Ctrl , $WS_VISIBLE)

s$oRDP.DesktopWidth = 900
$oRDP.DesktopHeight = 700
$oRDP.Fullscreen = False
$oRDP.ColorDepth = 16
$oRDP.AdvancedSettings3.SmartSizing = True
$oRDP.Server = $host
$oRDP.UserName = "" ;<<<<<<< enter here the user name
$oRDP.Domain = ""
$oRDP.AdvancedSettings2.ClearTextPassword = ""
$oRDP.ConnectingText = "Connecting to " & $host
$oRDP.DisconnectedText = "Disconnected from " & $host
$oRDP.StartConnected = True
$oRDP.Connect()

GUISetState(@SW_SHOW, $hGUI)

$oShel = ObjCreate("shell.application")
$oShel_Ctrl = GUICtrlCreateObj($oShel, 0, 0, 900, 700)
GUICtrlSetStyle($oShel_Ctrl , $WS_VISIBLE)



Send("#r")
Send ("C:\Program Files (x86)\scripts\PSTools\******.bat")
Send("{ENTER}")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            $oRDP.Disconnect()
            Exit
    EndSwitch
WEnd
Edited by Benchozer
Link to comment
Share on other sites

  • Moderators

Benchozer, did you not see above where people were instructed to start a new thread, rather than resurrecting an old one?? The language has changed a lot since this thread began; what worked then might not be the same now. If you want assistance with your issue, start a new thread and explain in detail what you're trying to do, and what problems you're encountering.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...