Jump to content

Embed RDP in GUI


lod3n
 Share

Recommended Posts

#include <GUIConstants.au3>

$oRDP = ObjCreate("MsTscAx.MsTscAx") 
GUICreate("Embedded RDP control Test", 640, 480, -1 , -1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj($oRDP, 10, 10, 620, 460)
GUISetState()

$oRDP.Server = "SERVERNAME"
$oRDP.Domain = "DOMAIN"
$oRDP.UserName = "USERNAME"

$oRDP.Connect()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

GUIDelete()

Exit

Check out the TypeInfo of IDispatch for Microsoft RDP Client Control in OLEView for additional methods.

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

This is great! I would like to make a GUI that has several TABs each having an RDP connection to a different server.

However, as soon as I put the "GUICtrlCreateObj" within a TabItem, my GUI Locks up, and I can't type in the RDP window, nor can I close the GUI without cancelling the process.

Any clues?

Link to comment
Share on other sites

@lod3n

This will solve the resizing problem.

#include <GUIConstants.au3>

$oRDP = ObjCreate("MsTscAx.MsTscAx") 
GUICreate("Embedded RDP control Test", 640, 480, -1 , -1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj($oRDP, 10, 10, 620, 460)
GUICtrlSetStyle ( $GUIActiveX,  $WS_VISIBLE )   
GUICtrlSetResizing ($GUIActiveX,$GUI_DOCKAUTO)

GUISetState()

$oRDP.Server = "server"
$oRDP.Domain = "domain"
$oRDP.UserName = "administrator"

$oRDP.Connect()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

GUIDelete()

Exit

Enjoy !!

ptrex

Edited by ptrex
Link to comment
Share on other sites

  • 2 weeks later...

I try:

$oRDP.Server = "server"

$oRDP.Domain = "domain"

$oRDP.UserName = "administrator"

$oRDP.PortablePassword ="BLAHBLAH"

$oRDP.Connect()

but error: The requested action with this object has failed.

I have found only these parameters of the password, but I can not use not one :)

propterty PortablePassword

propterty PortableSalt

propterty BinaryPassword

property BinarySalt

Method ResetPassword

How? Can you help, please?

Link to comment
Share on other sites

  • 4 months later...

Redraw problem fixed!

#include <GUIConstants.au3>

$oRDP = ObjCreate("MsTscAx.MsTscAx")
$GUI = GUICreate("Embedded RDP control Test", 640, 480, 0, -1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj($oRDP, 10, 10, 620, 460)
GUICtrlSetResizing ($GUIActiveX,$GUI_DOCKAUTO)

GUISetState()

;START - fixing the styles of the controls and the GUI to prevent clipping
$hUIContainerClass = ControlGetHandle($GUI, "", "UIContainerClass1")
$hUIMainClass = ControlGetHandle($GUI, "", "UIMainClass1")
$hATL = ControlGetHandle($GUI, "", "ATL:46F016981")
Const $WS_EX_NOPARENTNOTIFY = 0x4
Const $WS_EX_NOINHERITLAYOUT = 0x100000
$hUIContainerClassStyle = BitOR($WS_CHILD, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS, $WS_VISIBLE) ; 0x56000000
$hUIContainerClassStyleEx = BitOR($WS_EX_NOINHERITLAYOUT, $WS_EX_NOPARENTNOTIFY) ; 0x00100004
$hUIMainClassStyle = BitOR($WS_CHILD, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS, $WS_SYSMENU, $WS_VISIBLE) ; 0x56080000
$hUIMainClassStyleEx = 0x0
$hATLStyle = BitOR($WS_CHILD, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS, $WS_VISIBLE) ; 0x56000000
$hATLStyleEx = 0x0
$guiStyle = BitOR($WS_BORDER, $WS_CAPTION, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS, $WS_DLGFRAME, $WS_GROUP, $WS_MAXIMIZE, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SYSMENU, $WS_TABSTOP, $WS_THICKFRAME, $WS_VISIBLE) ; 0x17CF0100
$guiStyleEx = $WS_EX_WINDOWEDGE ; 0x00000100
_SetStyle($hUIContainerClass,$hUIContainerClassStyle,$hUIContainerClassStyleEx)
_SetStyle($hUIMainClass,$hUIMainClassStyle,$hUIMainClassStyleEx)
_SetStyle($hATL,$hATLStyle,$hATLStyleEx)
_SetStyle($gui,$guiStyle,$guiStyleEx)
Func _SetStyle($hwnd,$style,$exstyle)
    DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hwnd, "int", -16, "long", $style)
    DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hwnd, "int", -20, "long", $exstyle)
EndFunc
;END - fixing the styles of the controls and the GUI to prevent clipping

;[EDIT] I went ahead and found out what hex values of the styles I originally posted here represented.
; $WS_EX_NOPARENTNOTIFY and $WS_EX_NOINHERITLAYOUT seem to be fairly important
; This may still be important for other projects with similar problems.

$oRDP.Server = "server"
$oRDP.Domain = "domain"
$oRDP.UserName = "administrator"

$oRDP.Connect()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

GUIDelete()

Exit
Edited by lod3n

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

I don't know what to tell you. Without the fix, I get the same clipping problems you've described. With the fix, the clipping problems go away. I can cover and uncover the window, minimize and restore it, and it doesn't miss a beat. It may be possible that the class names on my version of the RDP control are somehow different from yours. See what this version reports in the Scite console:

#include <GUIConstants.au3>

$oRDP = ObjCreate("MsTscAx.MsTscAx")
$GUI = GUICreate("Embedded RDP control Test", 640, 480, 0, -1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj($oRDP, 10, 10, 620, 460)
GUICtrlSetResizing ($GUIActiveX,$GUI_DOCKAUTO)

GUISetState()

;START - fixing the styles of the controls and the GUI to prevent clipping
$hUIContainerClass = ControlGetHandle($GUI, "", "UIContainerClass1")
$hUIMainClass = ControlGetHandle($GUI, "", "UIMainClass1")
$hATL = ControlGetHandle($GUI, "", "ATL:46F016981")
ConsoleWrite("$hUIContainerClass (should not be 0 or blank):" & $hUIContainerClass & @crlf)
ConsoleWrite("$hUIMainClass (should not be 0 or blank):" & $hUIMainClass & @crlf)
ConsoleWrite("$hATL (should not be 0 or blank):" & $hATL & @crlf)
Const $WS_EX_NOPARENTNOTIFY = 0x4
Const $WS_EX_NOINHERITLAYOUT = 0x100000
$hUIContainerClassStyle = BitOR($WS_CHILD, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS, $WS_VISIBLE) ; 0x56000000
$hUIContainerClassStyleEx = BitOR($WS_EX_NOINHERITLAYOUT, $WS_EX_NOPARENTNOTIFY) ; 0x00100004
$hUIMainClassStyle = BitOR($WS_CHILD, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS, $WS_SYSMENU, $WS_VISIBLE) ; 0x56080000
$hUIMainClassStyleEx = 0x0
$hATLStyle = BitOR($WS_CHILD, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS, $WS_VISIBLE) ; 0x56000000
$hATLStyleEx = 0x0
$guiStyle = BitOR($WS_BORDER, $WS_CAPTION, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS, $WS_DLGFRAME, $WS_GROUP, $WS_MAXIMIZE, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SYSMENU, $WS_TABSTOP, $WS_THICKFRAME, $WS_VISIBLE) ; 0x17CF0100
$guiStyleEx = $WS_EX_WINDOWEDGE ; 0x00000100
_SetStyle($hUIContainerClass,$hUIContainerClassStyle,$hUIContainerClassStyleEx)
_SetStyle($hUIMainClass,$hUIMainClassStyle,$hUIMainClassStyleEx)
_SetStyle($hATL,$hATLStyle,$hATLStyleEx)
_SetStyle($gui,$guiStyle,$guiStyleEx)
Func _SetStyle($hwnd,$style,$exstyle)
    DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hwnd, "int", -16, "long", $style)
    DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hwnd, "int", -20, "long", $exstyle)
EndFunc
;END - fixing the styles of the controls and the GUI to prevent clipping

;[EDIT] I went ahead and found out what hex values of the styles I originally posted here represented.
; $WS_EX_NOPARENTNOTIFY and $WS_EX_NOINHERITLAYOUT seem to be fairly important
; This may still be important for other projects with similar problems.

$oRDP.Server = "server"
$oRDP.Domain = "domain"
$oRDP.UserName = "administrator"

$oRDP.Connect()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

GUIDelete()

Exit

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

Scite Output shows this:

$hUIContainerClass (should not be 0 or blank):

$hUIMainClass (should not be 0 or blank):

$hATL (should not be 0 or blank):

My msrdp.ocx has the version 5.1.2600.2180.

My mstscax.dll has the version 5.1.2600.2180.

A short time i had the RDP 6.0 Client installed.

Could it be, that the install / uninstall of RDP 6 are importent ?

Link to comment
Share on other sites

My msrdp.ocx has the version 5.1.2600.2180

My mstscax.dll has the version 6.0.6000.16386

That must be the problem. The class names are different between the two different ActiveX control versions. Why did you downgrade?

In any case, there must be a way to solve this. Could you add this:

Opt("WinSearchChildren", 1)     ;0=no, 1=search children also
ConsoleWrite(WinGetClassList($GUI,"")

to the script just before the message loop, and report back what your controls are called? Hopefully that will pull all of the nested child controls that I originally discovered with Spy++ to build the fix.

Edited by lod3n

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

  • 3 weeks later...

hi lod3n,

sorry for the long time since i answer.

We downgrade, because, we had/have some problems with the rdp 6 client (saved rdp-files, server hangs up when be accesed with rdp 6 and so on ...).

Here's the output from Scite with the latest codelines:

$hUIContainerClass (should not be 0 or blank):

$hUIMainClass (should not be 0 or blank):

$hATL (should not be 0 or blank):

ATL:6A688220

UIMainClass

UIContainerClass

IHWindowClass

OPWindowClass

But im tested the latest code on a machine with rdp 6, but the same clipping problem.

Here's the scite output:

$hUIContainerClass (should not be 0 or blank):

$hUIMainClass (should not be 0 or blank):

$hATL (should not be 0 or blank):

ATL:46BF1698

UIMainClass

UIContainerClass

IHWindowClass

OPWindowClass

OPWindowClass

Hope, this could help to solve this.

Greets,

Andy

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...