Jump to content

Recommended Posts

Posted

I am trying to have a gui with a few buttons and some precoded values, but when the options button is pressed, I'd like to be able to have a gui resize and have the hard coded options become input boxes at that point, and then the options button be able to be pressed again, and have it return to the standard gui box size

Here is my code. I've noticed that the form values are anchored to the height of the box, and they move in reference to the bottom margin, and of course don't work after they've moved. I'd like to have them stay stationary, and also have the newer input boxes load into the new/larger area. Do I have to have a secondary form load for this?

Thanks!

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <WinAPI.au3>


#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Remote Desktop Connection", 413, 144, 1617, 309)
$Label1 = GUICtrlCreateLabel("Computer:", 8, 80, 52, 21, $WS_TABSTOP)
$Combo1 = GUICtrlCreateCombo("", 88, 80, 249, 25)
    GUICtrlSetData(-1, "")
$connect = GUICtrlCreateButton("Connect", 88, 112, 75, 25, 0)
$cancel = GUICtrlCreateButton("Cancel", 168, 112, 75, 25, 0)
$help = GUICtrlCreateButton("Help", 248, 112, 75, 25, 0)
$options = GUICtrlCreateButton("Options", 328, 112, 75, 25, 0)
$Graphic1 = GUICtrlCreateGraphic(0, 0, 408, 70)
GUISetState(@SW_SHOW)
Dim $Form1_AccelTable[2][2] = [["^n", $connect],["^h", $help]]
GUISetAccelerators($Form1_AccelTable)
#EndRegion ### END Koda GUI section ###


Global $default = default










While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
case $cancel
Exit
case $connect
    _connect()
case $options   
    _options()
EndSwitch
WEnd



func _connect()
$combo2=GUICtrlRead($Combo1)
;~ MsgBox(0, 'combo1', $Combo2)
;~ MsgBox(0, "test", @ComSpec & " " & @WindowsDir & "\mstsc.exe /v:" & $Combo2 & " /f")
run( "cmd /c mstsc.exe /v:" & $Combo2 & " /f", @SystemDir, @SW_HIDE)
    sleep(1000)
While 1
    If WinExists($combo2 & " - Remote Desktop") Then
;~      msgbox(0, "Success is", "Yes")
        
            WinActive($combo2 & " - Remote Desktop")
    
            Sleep(500)
            Send("{ENTER}")
            Send("!U")  
            Send("login name")
            Send("{TAB}")
            Send("")
            Send("{TAB}")
            Send("b")
            Send("{ENTER}")
            
        ExitLoop
    EndIf   
        

        

        
Sleep(500)
WEnd
EndFunc




func _options()
    
While 1
    
        
        WinMove("Remote Desktop Connection", "", $default, $default, 413, 450, 1)
    
                #include <ButtonConstants.au3>
                #include <ComboConstants.au3>
                #include <EditConstants.au3>
                #include <GUIConstantsEx.au3>
                #include <StaticConstants.au3>
                #include <WindowsConstants.au3>

                #Region ### START Koda GUI section ### Form=
                $Form1_1_1 = GUICreate("Remote Desktop Connection", 407, 401, 1849, 413)
                $Label1 = GUICtrlCreateLabel("Computer:", 8, 80, 52, 17, $WS_TABSTOP)
                $Combo1 = GUICtrlCreateCombo("", 88, 80, 249, 25)
                $cancel = GUICtrlCreateButton("Cancel", 168, 112, 75, 25, 0)
                $help = GUICtrlCreateButton("Help", 248, 112, 75, 25, 0)
                $options = GUICtrlCreateButton("Options", 328, 112, 75, 25, 0)
                $connect = GUICtrlCreateButton("Connect", 88, 112, 75, 25, 0)
                $Graphic1 = GUICtrlCreateGraphic(0, 0, 408, 70)
                $Input1 = GUICtrlCreateInput("", 96, 240, 241, 21)
                $Input2 = GUICtrlCreateInput("", 96, 272, 241, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
                $Input3 = GUICtrlCreateInput("", 96, 304, 241, 21)
                $User = GUICtrlCreateLabel("User Name", 8, 240, 60, 21)
                $Password = GUICtrlCreateLabel("Password", 8, 272, 36, 21)
                $Domain = GUICtrlCreateLabel("Domain", 8, 304, 60, 21)
                #EndRegion ### END Koda GUI section ###

                While 1
                    $nMsg = GUIGetMsg()
                    Switch $nMsg
                        Case $GUI_EVENT_CLOSE
                            Exit

                    EndSwitch
                WEnd

                    
    




Sleep(500)
WEnd
EndFunc
Posted

Re-including header files inside a function or anything other than at the header is not a good idea. If you're going to use that header file, just include it at the file header. Another thing you can consider is to create the dialog window at start and just show it when necessary instead of destroying and creating it over and over. If you're insisting to use this technique you can move part of the dialog's controls off it's client edges and resizing it when needed.

Posted

Using your suggestions, it still pushes everything down to the bottom, even when the other buttons are off screen until I hit the options button

Can you provide a code modification to show me what you are talking about?

Re-including header files inside a function or anything other than at the header is not a good idea. If you're going to use that header file, just include it at the file header. Another thing you can consider is to create the dialog window at start and just show it when necessary instead of destroying and creating it over and over. If you're insisting to use this technique you can move part of the dialog's controls off it's client edges and resizing it when needed.

Posted

#include <GUIConstantsEx.au3>
Opt('GUIResizeMode', $GUI_DOCKALL)

Global $hGUI, $Btn_Options
Global $Checkbox, $Edit
Global $fShow = False

$hGUI = GUICreate('Title', 500, 100)
$Btn_Options = GUICtrlCreateButton('&Show', 215, 40, 70, 25)
$Checkbox = GUICtrlCreateCheckbox('&Check', 10, 130)
$Edit = GUICtrlCreateEdit('Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed' & @CRLF & 'diam nonummy nibh euismod tincidunt ut laoreet dolore magna' & @CRLF & 'aliquam erat volutpat. Ut wisi enim ad minim veniam, quis' & @CRLF & 'nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip' & @CRLF & 'ex ea commodo consequat. Duis autem vel eum iriure dolor in' & @CRLF & 'hendrerit in vulputate velit esse molestie consequat, vel illum' & @CRLF & 'dolore eu feugiat nulla facilisis at vero eros et accumsan et' & @CRLF & 'iusto odio dignissim qui blandit praesent luptatum zzril delenit' & @CRLF & 'augue duis dolore te feugait nulla facilisi. Nam liber tempor cum' & @CRLF & 'soluta nobis eleifend option congue nihil imperdiet doming id' &@CRLF & 'quod mazim placerat facer possim assum. Typi non habent' & @CRLF & 'claritatem insitam; est usus legentis in iis qui facit eorum' & @CRLF & 'claritatem. Investigationes demonstraverunt lectores legere me' & @CRLF & 'lius quod ii legunt saepius. Claritas est etiam processus' & @CRLF & 'dynamicus, qui sequitur mutationem consuetudium lectorum.' & @CRLF & 'Mirum est notare quam littera gothica, quam nunc putamus' & @CRLF & 'parum claram, anteposuerit litterarum formas humanitatis per' & @CRLF & 'seacula quarta decima et quinta decima. Eodem modo typi, qui' & @CRLF & 'nunc nobis videntur parum clari, fiant sollemnes in futurum.', _
    10, 170, 480, 300)
    
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            ExitLoop
            
        Case $Btn_Options
            $fShow = Not $fShow
            
            If $fShow Then
                GUICtrlSetData($Btn_Options, '&Hide')
                WinMove($hGUI, '', Default, Default, 500, 500)
            Else
                GUICtrlSetData($Btn_Options, '&Show')
                WinMove($hGUI, '', Default, Default, 500, 100)
            EndIf
            
        Case $Checkbox
            If BitAND(GUICtrlRead($Checkbox), $GUI_CHECKED) Then
                GUICtrlSetData($Checkbox, '&Check')
            Else
                GUICtrlSetData($Checkbox, '&Uncheck')
            EndIf
    EndSwitch
WEnd

Posted

Thanks Authenticity! You're the man!

Here is my code, it's working great.

Any idea on where to learn about saving the typed in credentials into an encrypted file somewhere?

And also how to make the press of the enter key, when typing in the server name value, have it be the same as mouse clicking on the connect button?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <WinAPI.au3>
Opt('GUIResizeMode', $GUI_DOCKALL)

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Remote Desktop Connection", 413, 144, 1617, 309)
$Label1 = GUICtrlCreateLabel("Computer:", 8, 80, 52, 21, $WS_TABSTOP)
$Combo1 = GUICtrlCreateCombo("", 88, 80, 249, 25)
    GUICtrlSetData(-1, "")
$connect = GUICtrlCreateButton("Connect", 88, 112, 75, 25, 0)
$cancel = GUICtrlCreateButton("Cancel", 168, 112, 75, 25, 0)
$help = GUICtrlCreateButton("Help", 248, 112, 75, 25, 0)
$options = GUICtrlCreateButton("Options", 328, 112, 75, 25, 0)
$Graphic1 = GUICtrlCreateGraphic(0, 0, 408, 70)
$Input1 = GUICtrlCreateInput("", 96, 240, 241, 21)
$Input2 = GUICtrlCreateInput("", 96, 272, 241, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
$Input3 = GUICtrlCreateInput("", 96, 304, 241, 21)
$User = GUICtrlCreateLabel("User Name", 8, 240, 60, 21)
$Password = GUICtrlCreateLabel("Password", 8, 272, 60, 21)
$Domain = GUICtrlCreateLabel("Domain", 8, 304, 60, 21)
GUISetState(@SW_SHOW)
Dim $Form1_AccelTable[2][2] = [["^n", $connect],["^h", $help]]
GUISetAccelerators($Form1_AccelTable)
#EndRegion ### END Koda GUI section ###





Global $default = default
Global $hGUI, $Btn_Options
Global $Checkbox, $Edit
Global $fShow = False


$hGUI = GUICreate('Title', 500, 100)
$Btn_Options = GUICtrlCreateButton('&Show', 215, 40, 70, 25)
$Checkbox = GUICtrlCreateCheckbox('&Check', 10, 130)
$Edit = GUICtrlCreateEdit('asdfasdfadsfasdfasdfasdfasdfasdfasdfasdfafdadf' & @CRLF & '231354564564131231534564561231344865341' & @CRLF & 'asdfasdfadsfasdfasdfasdfasdfasdfasdfasdfafdadf' & @CRLF & '231354564564131231534564561231344865341' & @CRLF & 'asdfasdfadsfasdfasdfasdfasdfasdfasdfasdfafdadf' & @CRLF & '231354564564131231534564561231344865341', 10, 170, 480, 300)






While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
case $cancel
Exit
case $connect
    _connect()
Case $options
$fShow = Not $fShow
            
    If $fshow Then
        GUICtrlSetData($Btn_Options, '&Hide')
        WinMove($Form1, '', Default, Default, 413, 450)
        
    Else
        GUICtrlSetData($Btn_Options, '&Show')
        WinMove($Form1, '', Default, Default, 413, 175)
    EndIf   
;~ case $options    
;~  _options()
EndSwitch
WEnd



func _connect()
$combo2=GUICtrlRead($Combo1)
;~ MsgBox(0, 'combo1', $Combo2)
;~ MsgBox(0, "test", @ComSpec & " " & @WindowsDir & "\mstsc.exe /v:" & $Combo2 & " /f")
run( "cmd /c mstsc.exe /v:" & $Combo2 & " /f", @SystemDir, @SW_HIDE)
    sleep(1000)
While 1
    If WinExists($combo2 & " - Remote Desktop") Then
;~      msgbox(0, "Success is", "Yes")
        
            WinActive($combo2 & " - Remote Desktop")
    
            Sleep(500)
            Send("{ENTER}")
            Send("!U")  
            Send(GUICtrlRead($Input1))
            Send("{TAB}")
            Send(GUICtrlRead($Input2))
            Send("{TAB}")
            Send(guictrlread($Input3))
            Send("{ENTER}")
            
        ExitLoop
    EndIf   
        

        

        
Sleep(500)
WEnd
EndFunc

#include <GUIConstantsEx.au3>
Opt('GUIResizeMode', $GUI_DOCKALL)

Global $hGUI, $Btn_Options
Global $Checkbox, $Edit
Global $fShow = False

$hGUI = GUICreate('Title', 500, 100)
$Btn_Options = GUICtrlCreateButton('&Show', 215, 40, 70, 25)
$Checkbox = GUICtrlCreateCheckbox('&Check', 10, 130)
$Edit = GUICtrlCreateEdit('Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed' & @CRLF & 'diam nonummy nibh euismod tincidunt ut laoreet dolore magna' & @CRLF & 'aliquam erat volutpat. Ut wisi enim ad minim veniam, quis' & @CRLF & 'nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip' & @CRLF & 'ex ea commodo consequat. Duis autem vel eum iriure dolor in' & @CRLF & 'hendrerit in vulputate velit esse molestie consequat, vel illum' & @CRLF & 'dolore eu feugiat nulla facilisis at vero eros et accumsan et' & @CRLF & 'iusto odio dignissim qui blandit praesent luptatum zzril delenit' & @CRLF & 'augue duis dolore te feugait nulla facilisi. Nam liber tempor cum' & @CRLF & 'soluta nobis eleifend option congue nihil imperdiet doming id' &@CRLF & 'quod mazim placerat facer possim assum. Typi non habent' & @CRLF & 'claritatem insitam; est usus legentis in iis qui facit eorum' & @CRLF & 'claritatem. Investigationes demonstraverunt lectores legere me' & @CRLF & 'lius quod ii legunt saepius. Claritas est etiam processus' & @CRLF & 'dynamicus, qui sequitur mutationem consuetudium lectorum.' & @CRLF & 'Mirum est notare quam littera gothica, quam nunc putamus' & @CRLF & 'parum claram, anteposuerit litterarum formas humanitatis per' & @CRLF & 'seacula quarta decima et quinta decima. Eodem modo typi, qui' & @CRLF & 'nunc nobis videntur parum clari, fiant sollemnes in futurum.', _
    10, 170, 480, 300)
    
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            ExitLoop
            
        Case $Btn_Options
            $fShow = Not $fShow
            
            If $fShow Then
                GUICtrlSetData($Btn_Options, '&Hide')
                WinMove($hGUI, '', Default, Default, 500, 500)
            Else
                GUICtrlSetData($Btn_Options, '&Show')
                WinMove($hGUI, '', Default, Default, 500, 100)
            EndIf
            
        Case $Checkbox
            If BitAND(GUICtrlRead($Checkbox), $GUI_CHECKED) Then
                GUICtrlSetData($Checkbox, '&Check')
            Else
                GUICtrlSetData($Checkbox, '&Uncheck')
            EndIf
    EndSwitch
WEnd

Posted

Hi, you explain the first question?

About the second question, try this one. Put the constant declaration at the header (if it's not already declared), and the second line at least after the default button you're interested in is defined. In your example, a better place to put it is just after you show the main window, or right after the $connect is assigned a button control identifier:

If Not IsDeclared('DM_SETDEFID') Then Global Const $DM_SETDEFID = 0x0401
_SendMessage($Form1, $DM_SETDEFID, $connect)
Posted (edited)

I haven't cleaned up the code yet, but you'll notice that when you run the code, it looks like the below when expanded.

I'd like to have the values entered in those 3 input boxes, to be stored somewhere, and saved, so they are auto populated next time the program is launched. That way it saves time/redundancy, and it allows you to keep it minimized for next time

Posted Image

Hi, you explain the first question?

About the second question, try this one. Put the constant declaration at the header (if it's not already declared), and the second line at least after the default button you're interested in is defined. In your example, a better place to put it is just after you show the main window, or right after the $connect is assigned a button control identifier:

If Not IsDeclared('DM_SETDEFID') Then Global Const $DM_SETDEFID = 0x0401
_SendMessage($Form1, $DM_SETDEFID, $connect)

Edited by gte
Posted

Well, encryption is not that good and solid. All you can do is to try to protect it but it's definitely not 100% secure. As I always tell users here, add as much crap as possible to drive the beginner reverser crazy. Run the user name and password through a series of encryption algorithm using a controlled randomization techniques. Other than that you can add a little bit more crap. :D

.. or search the internet for nice encryption techniques. :D

Posted

So set it up to save to a text file and then read from the text file upon start up? Then worry about encrypting it?

Also, have you ever tried to use the insert pic option for a gui in koda? I can't seem to make the image smaller than 100 pixels (the blue arrow) rather than the location that I want it (the red arrow) . Even if I resize it, koda auto corrects it to the blue line and makes it 100 pixels in height? I can't seem to change it anywhere?

Posted Image

Well, encryption is not that good and solid. All you can do is to try to protect it but it's definitely not 100% secure. As I always tell users here, add as much crap as possible to drive the beginner reverser crazy. Run the user name and password through a series of encryption algorithm using a controlled randomization techniques. Other than that you can add a little bit more crap. :D

.. or search the internet for nice encryption techniques. :D

Posted

I really don't know what to tell you heh. At some point the passwords and usernames has to be compared whether you encrypt them just once or thousands times, at some point something has to be evaluated and compared... You can store the passwords on some SQL server or other computer and... again the password for that has to be on user's dark mind, otherwise it won't be secure...

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
  • Recently Browsing   0 members

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