Sign in to follow this  
Followers 0
Shat4Brains

GUI Problem

3 posts in this topic

Well im a beginner at auto it scripting and cant figure out this problem im having

The Script - The idea is to add username and password and for it to save in the registry

Problem - The password saves correctly in the registy but the username doesnt, it saves the username as the number 8(i geuss thats the input box's id)

any ideas on what I can do to have the username save correctly?

;Include constants
#include <GUIConstants.au3>
#include <file.au3>


;Initialize variables
Global $GUIWidth
Global $GUIHeight

$GUIWidth = 300
$GUIHeight = 250

;Create window
GUICreate("Auto Login v 0.01", $GUIWidth, $GUIHeight)

; INPUT username
$Username = GUICtrlCreateInput ("Username", 10,10,150,20)

; INPUT username
$Password = GUICtrlCreateInput ("Password", 10,35,150,20)

$radio1 = GUICtrlCreateRadio ("Character 1", 10, 55, 120, 20)
GUICtrlSetState ($radio1,$GUI_CHECKED)
$radio2 = GUICtrlCreateRadio ("Character 2", 10, 75, 120, 20)
$radio3 = GUICtrlCreateRadio ("Character 3", 10, 95, 120, 20)

;Create an "ADD Username" button
$ADD_Username = GUICtrlCreateButton("ADD ID", 170, 10, 70, 20)
GUICtrlSetState(-1,$GUI_FOCUS)

;Create an "ADD Password" button
$ADD_Password = GUICtrlCreateButton("ADD Pass", 170, 35, 70, 20)
GUICtrlSetState(-1,$GUI_FOCUS)

;Create an "OK" button
$OK_Btn = GUICtrlCreateButton("OK", 75, 210, 70, 25)

;Create a "CANCEL" button
$Exit_Btn = GUICtrlCreateButton("Exit", 165, 210, 70, 25)

;Show window/Make the window visible
GUISetState(@SW_SHOW)

;Loop until:
;- user presses Esc
;- user presses Alt+F4
;- user clicks the close button
While 1
 ;After every loop check if the user clicked something in the GUI window
   $msg = GUIGetMsg()

   Select
   
    ;Check if user clicked on the close button
      Case $msg = $GUI_EVENT_CLOSE
       ;Destroy the GUI including the controls
         GUIDelete()
       ;Exit the script
         Exit







      Case $msg = $ADD_Username
                  $DATA_Username = GUICtrlRead($Username)

; Write a single REG_SZ value
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Launcher\tab1", "username1", "REG_SZ", $ADD_Username)


      Case $msg = $ADD_Password
                  $DATA_Password = GUICtrlRead($Password)

; Write a single REG_SZ value
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Launcher\tab1", "password1", "REG_SZ", $DATA_Password)








    
    ;Check if user clicked on the "OK" button
      Case $msg = $OK_Btn
         MsgBox(64, "New GUI", "You clicked on the OK button!")
      
    ;Check if user clicked on the "Exit" button
      Case $msg = $Exit_Btn
        ExitLoop
         
   EndSelect

WEnd

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You read the password to a variable and write it succesfully. You read the username

to a variable but you don't use that variable when attempting to write it to the registry,

instead you use the control-id for the button.

Case $msg = $ADD_Username
    $DATA_Username = GUICtrlRead($Username)
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Launcher\tab1", "username1", "REG_SZ", $DATA_Username)


Case $msg = $ADD_Password
    $DATA_Password = GUICtrlRead($Password)
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Launcher\tab1", "password1", "REG_SZ", $DATA_Password)

Edit : correction

Edited by Helge

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

ahh i now see the mistake, man i was wondering were i had the wrong piece of code, thanks alot i appreciate it

Edited by Shat4Brains

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