Sign in to follow this  
Followers 0
gte

What am I doing wrong here?

5 posts in this topic

With this while statement, I'm trying to have the script check the input boxes of my gui.

If they have text in them, to send the text from the boxes and if they are empty, to send the other assigned values of the "decrypt_*" variables.

No matter what I alter with this if statement, it wants to just send a "0" . Is there a guictrlread ($variable) = $guiboxblank or something that I haven't found?

While 1
    If WinExists($combo2 & " - Remote Desktop") Then
        
;~      msgbox(0, "Success is", "Yes")
        
            WinActive($combo2 & " - Remote Desktop")
;~          WinActive("Untitled - Notepad")
            
            Sleep(500)
            Send("{ENTER}")
            Sleep(500)
            Send("!U")
            Sleep(100)
            if GUICtrlRead($Input1) = 0 Then
                Guictrlread($decrypted_username)
                Send(GUICtrlRead($decrypted_username))
            ElseIf GUICtrlRead($Input1) <> 0 Then
                Send(Guictrlread($Input1))
            EndIf   
            Sleep(100)
            Send("{TAB}")
            Sleep(100)
            if GUICtrlRead($Input2) = 0 Then
                Guictrlread($decrypted_password)
                Send(GUICtrlRead($decrypted_password))
            ElseIf GUICtrlRead($Input2) <> 0 Then
                Send(Guictrlread($Input2))
            EndIf
            Sleep(100)
            Send("{TAB}")
            Sleep(100)
            if GUICtrlRead($Input3) = 0 Then
                Guictrlread($decrypted_domain)
                Send(GUICtrlRead($decrypted_domain))
            ElseIf GUICtrlRead($Input3) <> 0 Then
                Send(Guictrlread($Input3))
            EndIf
            Sleep(100)
            Send("{ENTER}")
            Sleep(100)
    

            
        ExitLoop
    EndIf

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

This is better but your basic concept is flawed I think.

While 1
    If WinExists($combo2 & " - Remote Desktop") Then
        
;~      msgbox(0, "Success is", "Yes")
        
            WinActive($combo2 & " - Remote Desktop")
;~          WinActive("Untitled - Notepad")
            
            Sleep(500)
            Send("{ENTER}")
            Sleep(500)
            Send("!U")
            Sleep(100)
            if GUICtrlRead($Input1) = "" Then
                ;Guictrlread($decrypted_username);; does nothing
                Send(GUICtrlRead($decrypted_username))
            Else
                Send(Guictrlread($Input1))
            EndIf   
            Sleep(100)
            Send("{TAB}")
            Sleep(100)
            if GUICtrlRead($Input2) = "" Then
                ;Guictrlread($decrypted_password);; does nothing
                Send(GUICtrlRead($decrypted_password))
            Else
                Send(Guictrlread($Input2))
            EndIf
            Sleep(100)
            Send("{TAB}")
            Sleep(100)
            if GUICtrlRead($Input3) = "" Then
                ;Guictrlread($decrypted_domain);; does nothing
                Send(GUICtrlRead($decrypted_domain))
            Else
                Send(Guictrlread($Input3))
            EndIf
            ;; I think that all of this is in the wrong place but without more of the code I can't be sure
            Sleep(100)
            Send("{ENTER}")
            Sleep(100)
         ExitLoop
         ;; down to here  
    EndIf
Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks for the reply Geo. Here is the entire code, I made the changes you suggested, and I still get it trying to enter 0's in when the boxes are blank.

You may have to manually input the data the first time, when launching, so that it has an encrypted file to reference and parse from.

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

Opt('GUIResizeMode', $GUI_DOCKALL)


Global $default = default
Global $hGUI, $Btn_Options
Global $Checkbox, $Edit
Global $fShow = False
Global $clipboardget = ClipGet( )
Global $clipboard = StringLeft($clipboardget, 15)



#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Remote Desktop Connection", 413, 144, 617, 309)
$Label1 = GUICtrlCreateLabel("Computer:", 8, 80, 52, 21, $WS_TABSTOP)
$Combo1 = GUICtrlCreateCombo($clipboard, 88, 80, 249, 25)   
$connect = GUICtrlCreateButton("Connect", 88, 112, 75, 25, 0)
GUICtrlSetState($connect, $GUI_FOCUS)
$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)
GUICtrlSetState($Input1, "blank")
$Input2 = GUICtrlCreateInput("", 96, 272, 241, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
GUICtrlSetState($Input2, "blank")
$Input3 = GUICtrlCreateInput("", 96, 304, 241, 21)
GUICtrlSetState($Input3, "blank")
$User = GUICtrlCreateLabel("User Name", 8, 240, 60, 21)
$Password = GUICtrlCreateLabel("Password", 8, 272, 60, 21)
$Domain = GUICtrlCreateLabel("Domain", 8, 304, 60, 21)
$Checkbox1 = GUICtrlCreateCheckbox("", 192, 192, 25, 25)
GUICtrlSetState($Checkbox1, $GUI_Enable)
$Save = GUICtrlCreateLabel("Save these credentials for later use?", 8, 200, 175, 21)
$Checkbox2 = GUICtrlCreateCheckbox("", 8, 360, 17, 17)
$Checkbox3 = GUICtrlCreateCheckbox("", 8, 384, 17, 17)
$fullscreen = GUICtrlCreateLabel("Select here if you do NOT want full screen mode", 32, 360, 225, 17)
$consolemode = GUICtrlCreateLabel("Select here if you want to log in with console mode (win2k3 server only)", 32, 384, 343, 17)
$Checkbox4 = GUICtrlCreateCheckbox("", 8, 408, 17, 17)
$programclose = GUICtrlCreateLabel("Select here if you do NOT want this program to close after connecting", 32, 408, 333, 17)
GUISetState(@SW_SHOW)
Dim $Form1_AccelTable[2][2] = [["^n", $connect],["^h", $help]]
GUISetAccelerators($Form1_AccelTable)
#EndRegion ### END Koda GUI section ###





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, 500)
        
    Else
        GUICtrlSetData($Btn_Options, '&Show')
        WinMove($Form1, '', Default, Default, 413, 175)
    EndIf

    

EndSwitch
WEnd



func _connect()

$Decrypt_File = FileRead(@TempDir & "\logon.ini")

$Decrypt_String = _StringEncrypt(0, $Decrypt_File, "ssadmadsusf", 7)

MsgBox(0, 'Decrypt String', $Decrypt_String)

$Decrypt_Array = StringSplit($Decrypt_String, ',')


$decrypted_username = $Decrypt_Array[1]
MsgBox(0, "Username", $decrypted_username)
$decrypted_password = $Decrypt_Array[2]
MsgBox(0, "Username", $decrypted_password)
$decrypted_domain = $Decrypt_Array[3] 


if GUICtrlread($Checkbox1) = $GUI_CHECKED Then
    FileDelete( @TempDir & "\logon.ini")
    FileWrite( @TempDir & "\logon.ini", _StringEncrypt(1,guictrlread($Input1) & ',' & guictrlread($Input2) & ',' & guictrlread($Input3),"ssadmadsusf", 7))
EndIf

if GUICtrlRead($Checkbox2) = $GUI_UNCHECKED then    
    $screenresolution1 = " /f"
EndIf   
    
if GUICtrlRead($Checkbox2) = $GUI_CHECKED then
    $screenresolution1 = " /w:1200 /h:1000"
EndIf   

if GUICtrlRead($Checkbox3) = $GUI_UNCHECKED then    
    $consolemode1 = ""
EndIf   
    
if GUICtrlRead($Checkbox3) = $GUI_CHECKED then
    $consolemode1 = " /console"
EndIf   



$combo2=GUICtrlRead($Combo1)



run( "cmd /c mstsc.exe /v:" & $Combo2 &$consolemode1 & $screenresolution1, @SystemDir, @SW_HIDE)
    sleep(5500)

$Input1 = "none"
$Input2 = "none"
$Input3 = "none"

MsgBox(0, "Input Box", guictrlread($Input1))
MsgBox(0, "Decrypted Input", $decrypted_username)
MsgBox(0, "Password Box", guictrlread($Input2))
MsgBox(0, "Decrypted Password", $decrypted_password)
MsgBox(0, "Domain Box", guictrlread($Input3))
MsgBox(0, "Decrtyped Domain", $decrypted_domain)

MsgBox(0, "Last Chance", "To kill the program")

    
While 1
    If WinExists($combo2 & " - Remote Desktop") Then
    
        
            WinActive($combo2 & " - Remote Desktop")
    
            
            Sleep(500)
            Send("{ENTER}")
            Sleep(500)
            Send("!U")
            Sleep(100)
            if GUICtrlRead($Input1) = 0 Then
                
                Send(GUICtrlRead($decrypted_username))
            Else 
                Send(Guictrlread($Input1))
            EndIf   
            Sleep(100)
            Send("{TAB}")
            Sleep(100)
            if GUICtrlRead($Input2) = 0 Then
                
                Send(GUICtrlRead($decrypted_password))
            Else
                Send(Guictrlread($Input2))
            EndIf
            Sleep(100)
            Send("{TAB}")
            Sleep(100)
            if GUICtrlRead($Input3) = 0 Then
                
                Send(GUICtrlRead($decrypted_domain))
            Else
                Send(Guictrlread($Input3))
            EndIf
            Sleep(100)
            Send("{ENTER}")
            Sleep(100)
    

            
        ExitLoop
    EndIf   
        

        

        
Sleep(500)
WEnd

sleep(7500)

if GUICtrlRead($Checkbox4) = $GUI_UNCHECKED then    
    exit
EndIf   
    
if GUICtrlRead($Checkbox4) = $GUI_CHECKED then
    
EndIf   


EndFunc




func _options()
    
While 1
    
    

    


                #Region ### START Koda GUI section ### Form=
                $Form1_1_1 = GUICreate("Remote Desktop Connection", 413, 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
Edited by gte

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