#include <GUIConstants.au3>
#include <WindowsConstants.au3>
FileInstall("C:\Documents and Settings\Администратор\Рабочий стол\Elegant\ICO\48x48\LCD.ico", @WindowsDir & "\LCD.ico")
$width = 1024
$height = 768
$oRDP = ObjCreate("MsTscAx.MsTscAx")
$GUI = GUICreate("Клиент подключения к удаленному рабочему столу" , $width+20, $height+20, 0, -1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj($oRDP, 10, 10, $width, $height)
GUICtrlSetResizing ($GUIActiveX,$GUI_DOCKAUTO)
GUISetIcon(@WindowsDir & "\LCD.ico")
GUISetState()
GUICreate("Введите IP адрес", 250,50, @DesktopWidth/2-160, @DesktopHeight/2-45, -1, 0x00000018); WS_EX_ACCEPTFILES
$file = GUICtrlCreateInput ( "Введите IP адрес", 10, 5, 230, 20)
GUICtrlSetState(-1,$GUI_DROPACCEPTED)
$btn = GUICtrlCreateButton ("Ok", 90, 30, 60, 20)
GUISetState ()
$msg = 0
While $msg <> $GUI_EVENT_CLOSE
$msg = GUIGetMsg()
Select
Case $msg = $btn
ExitLoop
EndSelect
Wend
$input = GUICtrlRead($file)
$login = IniRead(@ScriptDir & "\Passwords.ini", $input, "login","Нет в базе")
$pass = IniRead(@ScriptDir & "\Passwords.ini", $input, "pass","Нет в базе")
;MsgBox (4096, "drag drop file", $login)
; connect to the server. if this is not done first, the child controls are not rendered.
; which is a problem, because we have to change their styles to prevent clipping
$oRDP.Server = $input
$oRDP.Domain = "domain"
$oRDP.UserName = $login
$oRdp.AdvancedSettings2.ClearTextPassword = $pass
$oRDP.Connect()
;$oRdp.Fullscreen = True
$oRdp.ConnectingText = "Подключение"
$oRdp.DisconnectedText = "Сбой соединения"
; Determine the class name of the ATL control - it seems to be random from system to system
Opt("WinTitleMatchMode", 4 ) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("WinSearchChildren", 1) ;0=no, 1=search children also
$sATLClass = ""
$aClasses = StringSplit(WinGetClassList($GUI,""),@LF)
For $i = 1 To $aClasses[0]
If StringLeft($aClasses[$i],4) = "ATL:" Then
$sATLClass = $aClasses[$i]
ExitLoop
EndIf
Next
; get the handles to the controls that must have their styles modified
$hUIContainerClass = ControlGetHandle($GUI, "", "[CLASS:UIContainerClass]")
$hUIMainClass = ControlGetHandle($GUI, "", "[CLASS:UIMainClass]")
$hATL = ControlGetHandle($GUI, "", "[CLASS:"&$sATLClass&"]")
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)
; modify the styles of the child controls to match those set by the offical client application
; this prevents clipping problems - though, I don't know why
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
; $WS_EX_NOPARENTNOTIFY and $WS_EX_NOINHERITLAYOUT seem to be fairly important
; This may still be important for other projects with similar problems.
AdlibEnable ( "checkconn", 1000)
Func checkconn()
If $oRDP.Connected = 0 Then
Exit
EndIf
EndFunc
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
WEnd
GUIDelete()
Exit