Sign in to follow this  
Followers 0

RDP Session In AutoIT Gui


13 posts in this topic

Posted

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

Share this post


Link to post
Share on other sites



Posted

Can anyone help with this? :graduated:

Share this post


Link to post
Share on other sites

Posted (edited)

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
pilot, JLogan3o13 and Jfish like this

Share this post


Link to post
Share on other sites

Posted (edited)

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

Share this post


Link to post
Share on other sites

Posted

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

Share this post


Link to post
Share on other sites

Posted

Hi referring to the above scripts plss guide me how to execute tasks on the remote system for e.g. taking a basic task as running calc.exe...it would be of grrt help :rambo:

Share this post


Link to post
Share on other sites

Posted

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.

Share this post


Link to post
Share on other sites

Posted (edited)

sorry : but i have timing constraint...i just wanted to have minimum guidance o:)

Edited by ravi88

Share this post


Link to post
Share on other sites

Posted

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?

Share this post


Link to post
Share on other sites

Posted

thnx :pirate:

Share this post


Link to post
Share on other sites

Posted

You're welcome. Good luck.

Share this post


Link to post
Share on other sites

Posted (edited)

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

Share this post


Link to post
Share on other sites

Posted

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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0