Jump to content

INI file help


Recommended Posts

GUICtrlCreateLabel("Username", 10, 5, 75, 20)
    GUICtrlCreateLabel("Password", 10, 50, 75, 20)
    IniWrite("C:\WINDOWS\Temp\pw.ini", "Section1", "Key", $pass)

This is what i have so far.. i can get it to write an ini file

and this is what i get in return

[section1]

Key=4104

and the password was NOT 4104.. i typed "dog"... :whistle:

try guictrlread() ..

[edit]

it was more than likely returning the control id.. you want to use guictrlread instead of the variable.

IniWrite("C:\WINDOWS\Temp\pw.ini", "Section1", "Key", guictrlread($pass))

Edited by mrRevoked
Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Link to comment
Share on other sites

Func myspacelogin()
    Local $regis = 0

    If $regis = 0 Then
        GUIDelete($regis)
    EndIf
    
    
    ;Guicreated
    $child = GUICreate("logon", 200, 100,)
    GUISetOnEvent($GUI_EVENT_CLOSE, "childclose")
    GUISetState(@SW_SHOW, $child)
    

    ;Buttons
    $ok1 = GUICtrlCreateButton("OK", 140, 25, 50, 30)
    $confirm = GUICtrlSetOnEvent(-1, "confirmpass")

    ;Inputs
    $user = GUICtrlCreateInput("", 10, 28, 75, 20)
    $pass = GUICtrlCreateInput("", 10, 73, 75, 20, $ES_PASSWORD)
    ;Labels
    GUICtrlCreateLabel("Username", 10, 5, 75, 20)
    GUICtrlCreateLabel("Password", 10, 50, 75, 20)
    Do
        $msg = GUIGetMsg()
        If $msg = $ok1 Then
            IniWrite("C:\WINDOWS\Temp\pw.ini", "Section1", "Key", GUICtrlRead($user))
            IniWrite("C:\WINDOWS\Temp\pw.ini", "Section2", "Key", GUICtrlRead($pass))
        EndIf

    Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>myspacelogin

--------------------

yeah, so i still can't get it to work.... i have the added code, modified for my IDs, but when i click "ok" it opens the confirm window, like it is supposed to, but it doesn't make the INI...

ContactAim- bluehydrolic

Link to comment
Share on other sites

This code works on my computer:

#include<guiconstants.au3>

;Guicreated
$child = GUICreate("logon", 200, 100)
GUISetState(@SW_SHOW, $child)


;Buttons
$ok1 = GUICtrlCreateButton("OK", 140, 25, 50, 30)

;Inputs
$user = GUICtrlCreateInput("", 10, 28, 75, 20)
$pass = GUICtrlCreateInput("", 10, 73, 75, 20, $ES_PASSWORD)
;Labels
GUICtrlCreateLabel("Username", 10, 5, 75, 20)
GUICtrlCreateLabel("Password", 10, 50, 75, 20)
Do
    $msg = GUIGetMsg()
    If $msg = $ok1 Then
        IniWrite("pw.ini", "Section1", "Key", GUICtrlRead($user))
        IniWrite("pw.ini", "Section2", "Key", GUICtrlRead($pass))
        Run("notepad.exe pw.ini")
        Exit
    EndIf

Until $msg = $GUI_EVENT_CLOSE

I think that one thing that might have caused some trouble in your code is that you combined msg and on event modes.

Basically, you set an onevent as well as used guigetmsg().

Try running the above code on your computer. I changed a lot, but the concept still should be the same. :whistle:

Edited by veldrinn
Link to comment
Share on other sites

so, i'm going to try and do away with my UDFs can use all script stuff, so that way i dont have any issues...

but now im stuck... The advice i got for the INI, doesnt work well within a func/endfunc.. so, ive decided to do away with the func/endfunc

#include <GUIConstants.au3>

Global $regis = 1, $child = 1, $confirm = 1, $load = 0

$parent1 = GUICreate("Myspace", 197, 205, 193, 115)
$Myspace = GUICtrlCreateButton("Myspace", 112, 152, 75, 25, $BS_DEFPUSHBUTTON)

GUISetState(@SW_SHOW)

Do
    $msg = GUIGetMsg()
    
Until $msg = $Myspace

If $msg = $Myspace And Not FileExists("myspace.ini") Then
    $regis = GUICreate("Register", 200, 100)
    GUISetState(@SW_SHOW, $regis)
    GUICtrlCreateLabel("Register for Myspace Auto Logon?", 5, 20, 200, 20)
    $ok2 = GUICtrlCreateButton("OK", 55, 60, 50, 30)
    $can = GUICtrlCreateButton("Cancel", 115, 60, 50, 30)
    Do
        $auto = GUIGetMsg()
        If $auto = $ok2 Then
            MsgBox(4096, "", "OK!")
        EndIf
        If $auto = $can Then
            GUIDelete($regis)
        EndIf
        
    Until $auto = $ok2 Or $can
EndIf


If $msg = $Myspace And FileExists("myspace.ini") Then
    Run("C:\Program Files\Mozilla Firefox\firefox.exe")
EndIf

Any advice??? I cant make the window $regis close by itself, and the windows $parent1 closes when $regis closes. for some reason.... :whistle:

ContactAim- bluehydrolic

Link to comment
Share on other sites

so, i'm going to try and do away with my UDFs can use all script stuff, so that way i dont have any issues...

but now im stuck... The advice i got for the INI, doesnt work well within a func/endfunc.. so, ive decided to do away with the func/endfunc

#include <GUIConstants.au3>

Global $regis = 1, $child = 1, $confirm = 1, $load = 0

$parent1 = GUICreate("Myspace", 197, 205, 193, 115)
$Myspace = GUICtrlCreateButton("Myspace", 112, 152, 75, 25, $BS_DEFPUSHBUTTON)

GUISetState(@SW_SHOW)

Do
    $msg = GUIGetMsg()
    
Until $msg = $Myspace

If $msg = $Myspace And Not FileExists("myspace.ini") Then
    $regis = GUICreate("Register", 200, 100)
    GUISetState(@SW_SHOW, $regis)
    GUICtrlCreateLabel("Register for Myspace Auto Logon?", 5, 20, 200, 20)
    $ok2 = GUICtrlCreateButton("OK", 55, 60, 50, 30)
    $can = GUICtrlCreateButton("Cancel", 115, 60, 50, 30)
    Do
        $auto = GUIGetMsg()
        If $auto = $ok2 Then
            MsgBox(4096, "", "OK!")
        EndIf
        If $auto = $can Then
            GUIDelete($regis)
        EndIf
        
    Until $auto = $ok2 Or $can
EndIf
If $msg = $Myspace And FileExists("myspace.ini") Then
    Run("C:\Program Files\Mozilla Firefox\firefox.exe")
EndIf
oÝ÷ Ø    òiÛâqâj{fjG­ì"Ú0Ó~«z¬rZ,y¼¢¶Ç¥}©Ý¶°whÂÍ7ê«z{urZ,zÌ!z}7ê· Ç%¢Ç¬~ì¢g«y«([e·ú®¢×zYhDz¢ç±Ú.¶íéh¢"'¶)hØ^r¥vØ^­è¬h¢²Æ zÚ$yêmêZ­éí訥éÞt­ìÊ)âÂä²
Þj×è®g¢[§rبÀ'˲¶¼­+Úr^¶¬².Ø^¨¸Ú²'«{
èµè­jwb¶Çɨ­ç}ç-÷¢~Ø^r¥w¬iû§rب­Ü(®K¢¹jëh×6#include <GUIConstants.au3>

;Global $regis = 1, $child = 1, $confirm = 1, $load = 0

$parent1 = GUICreate("Myspace", 197, 205, -1, -1)
$Myspace = GUICtrlCreateButton("Myspace", 112, 152, 75, 25, $BS_DEFPUSHBUTTON)

GUISetState()

While 1 
 $nMsg = GUIGetMsg()
Switch $nMsg
    Case $GUI_EVENT_CLOSE
        Exit
    Case $Myspace
        If Not FileExists("myspace.ini") Then
        ChildGui()
        ElseIf FileExists("myspace.ini") Then
        Run("C:\Program Files\Mozilla Firefox\firefox.exe")
        EndIf
EndSwitch
WEnd

Func ChildGui()
    $regis = GUICreate("Register", 200, 100)
    GUICtrlCreateLabel("Register for Myspace Auto Logon?", 5, 20, 200, 20)
    $ok2 = GUICtrlCreateButton("OK", 55, 60, 50, 30)
    $can = GUICtrlCreateButton("Cancel", 115, 60, 50, 30)
    GUISetState(@SW_SHOW, $regis)
    While 1
        $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
        GUIDelete($regis)
        ExitLoop
        Case $ok2
        MsgBox(4096, "", "OK!")
        Case $can            
        GUIDelete($regis)
        ExitLoop
    EndSwitch
WEnd    
EndFunc

Edit

By the way I don't know why you declared those values upfront but it wasn't needed for this so far.

Edited by EndFunc
EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

i suggestion, Encrypt your data.

Actually, I'd like to. I want to encrypt the password, when it goes to the INI, and then I want to have a confirm password function as well, that will have an encrypted password, and compare the two.

Oh, and right now everything is working like it should in my code... which is awesome!!! THanks everyone!!

ContactAim- bluehydrolic

Link to comment
Share on other sites

#include <GUIConstants.au3>

$parent1 = GUICreate("Myspace", 197, 205, -1, -1)
$Myspace = GUICtrlCreateButton("Myspace", 112, 152, 75, 25, $BS_DEFPUSHBUTTON)

GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Myspace
            If Not FileExists("myspace.ini") Then
                ChildGui()
            ElseIf FileExists("myspace.ini") Then
                Run("C:\Program Files\Mozilla Firefox\firefox.exe")
            EndIf
    EndSwitch
WEnd

Func ChildGui()
    $regis = GUICreate("Register", 200, 100)
    GUICtrlCreateLabel("Register for Myspace Auto Logon?", 5, 20, 200, 20)
    $ok2 = GUICtrlCreateButton("OK", 55, 60, 50, 30)
    $can = GUICtrlCreateButton("Cancel", 115, 60, 50, 30)
    GUISetState(@SW_SHOW, $regis)
    While 1
        $msg = GUIGetMsg()
        Switch $msg
            Case $GUI_EVENT_CLOSE
                GUIDelete($regis)
                ExitLoop
            Case $ok2
                Password()
                
            Case $can
                GUIDelete($regis)
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>ChildGui


Func Password()
    Local $regis
    GUIDelete($regis)
    $child = GUICreate("logon", 200, 100)
    GUISetState(@SW_SHOW, $child)
    $ok1 = GUICtrlCreateButton("OK", 140, 25, 50, 30)
    $user = GUICtrlCreateInput("", 10, 28, 75, 20)
    $pass = GUICtrlCreateInput("", 10, 73, 75, 20, $ES_PASSWORD)
    GUICtrlCreateLabel("Username", 10, 5, 75, 20)
    GUICtrlCreateLabel("Password", 10, 50, 75, 20)
    While 1
        $mmsg = GUIGetMsg()
        Switch $mmsg

            Case $GUI_EVENT_CLOSE
                GUIDelete($child)
                ExitLoop
            Case $ok1
                IniWrite("pw.ini", "Section1", "Key", GUICtrlRead($user))
                IniWrite("pw.ini", "Section2", "Key", GUICtrlRead($pass))
                Confirm()
        EndSwitch
    WEnd
EndFunc   ;==>Password
Func Confirm()
    $confirm = GUICreate("Confirm", 200, 100)
    GUISetState(@SW_SHOW, $confirm)
    GUICtrlCreateLabel("Please confirm your password.", 10, 5, 200, 20)
    GUICtrlCreateLabel("Password", 10, 50, 65, 20, $ES_PASSWORD)
    $passconf = GUICtrlCreateInput("", 10, 65, 75, 20)
    $ok3 = GUICtrlCreateButton("OK", 140, 25, 50, 30)
    
    While 1
        $lmsg = GUIGetMsg()
        Switch $lmsg
            Case $GUI_EVENT_CLOSE
                GUIDelete($confirm)
                ExitLoop
            Case $ok3
                IniWrite("confirm.ini", "section1", "Key", GUICtrlRead($passconf))
                $one = IniReadSection("pw.ini", "Section2")
                $two = IniReadSection("confrim.ini", "section1")
If $one = $two Then
Msgbox (4096, "", "Password Matched!!")
Endif


        EndSwitch
    WEnd
    
    
EndFunc   ;==>Confirm

If $one = $two Then the password is matched...

Unfortunately, that doesn't work.. any suggesttions?

ContactAim- bluehydrolic

Link to comment
Share on other sites

#include <GUIConstants.au3>

$parent1 = GUICreate("Myspace", 197, 205, -1, -1)
$Myspace = GUICtrlCreateButton("Myspace", 112, 152, 75, 25, $BS_DEFPUSHBUTTON)

GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Myspace
            If Not FileExists("myspace.ini") Then
                ChildGui()
            ElseIf FileExists("myspace.ini") Then
                Run("C:\Program Files\Mozilla Firefox\firefox.exe")
            EndIf
    EndSwitch
WEnd

Func ChildGui()
    $regis = GUICreate("Register", 200, 100)
    GUICtrlCreateLabel("Register for Myspace Auto Logon?", 5, 20, 200, 20)
    $ok2 = GUICtrlCreateButton("OK", 55, 60, 50, 30)
    $can = GUICtrlCreateButton("Cancel", 115, 60, 50, 30)
    GUISetState(@SW_SHOW, $regis)
    While 1
        $msg = GUIGetMsg()
        Switch $msg
            Case $GUI_EVENT_CLOSE
                GUIDelete($regis)
                ExitLoop
            Case $ok2
                Password()
                
            Case $can
                GUIDelete($regis)
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>ChildGui


Func Password()
    Local $regis
    GUIDelete($regis)
    $child = GUICreate("logon", 200, 100)
    GUISetState(@SW_SHOW, $child)
    $ok1 = GUICtrlCreateButton("OK", 140, 25, 50, 30)
    $user = GUICtrlCreateInput("", 10, 28, 75, 20)
    $pass = GUICtrlCreateInput("", 10, 73, 75, 20, $ES_PASSWORD)
    GUICtrlCreateLabel("Username", 10, 5, 75, 20)
    GUICtrlCreateLabel("Password", 10, 50, 75, 20)
    While 1
        $mmsg = GUIGetMsg()
        Switch $mmsg

            Case $GUI_EVENT_CLOSE
                GUIDelete($child)
                ExitLoop
            Case $ok1
                IniWrite("pw.ini", "Section1", "Key", GUICtrlRead($user))
                IniWrite("pw.ini", "Section2", "Key", GUICtrlRead($pass))
                Confirm()
        EndSwitch
    WEnd
EndFunc   ;==>Password
Func Confirm()
    $confirm = GUICreate("Confirm", 200, 100)
    GUISetState(@SW_SHOW, $confirm)
    GUICtrlCreateLabel("Please confirm your password.", 10, 5, 200, 20)
    GUICtrlCreateLabel("Password", 10, 50, 65, 20, $ES_PASSWORD)
    $passconf = GUICtrlCreateInput("", 10, 65, 75, 20)
    $ok3 = GUICtrlCreateButton("OK", 140, 25, 50, 30)
    
    While 1
        $lmsg = GUIGetMsg()
        Switch $lmsg
            Case $GUI_EVENT_CLOSE
                GUIDelete($confirm)
                ExitLoop
            Case $ok3
                IniWrite("confirm.ini", "section1", "Key", GUICtrlRead($passconf))
                $one = IniReadSection("pw.ini", "Section2")
                $two = IniReadSection("confrim.ini", "section1")
If $one = $two Then
Msgbox (4096, "", "Password Matched!!")
Endif


        EndSwitch
    WEnd
    
    
EndFunc   ;==>Confirm

If $one = $two Then the password is matched...

Unfortunately, that doesn't work.. any suggesttions?

IniReadSection() returns an array.

iniread() maybe??

Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Link to comment
Share on other sites

If $one = $two Then the password is matched...

Unfortunately, that doesn't work.. any suggesttions?

Why do you need 2 different guis just to confirm a password? Why not create another Input for confirmation and compare them like you do when you register many logins. Much easier less code. Also it is a waste of using 2 ini files for a password and then a confirmation password. Another problem I noticed is because of the $ES_PASSWORD style used on the input to mask the password it seems to convert the $var to a number. That is why you are getting 4105 instead of what you typed. It still knows that the values are equal when you compare them though. If you check the ini file afterwords it will show you your username and password that you entered.

Anyhow, see if this code would help make it much shorter and help some.

#include <GUIConstants.au3>

$parent1 = GUICreate("Myspace", 197, 205, -1, -1)
$Myspace = GUICtrlCreateButton("Myspace", 112, 152, 75, 25, $BS_DEFPUSHBUTTON)

GUISetState()

While 1 
 $nMsg = GUIGetMsg()
Switch $nMsg
    Case $GUI_EVENT_CLOSE
        Exit
    Case $Myspace
        If Not FileExists("myspace.ini") Then
            Dim $iMsgBoxAnswer
            $iMsgBoxAnswer = MsgBox(33,"Register","Register for Myspace Auto Logon?")
            Select
               Case $iMsgBoxAnswer = 1 ;OK
                Password()  
               Case $iMsgBoxAnswer = 2 ;Cancel
                ContinueLoop
            EndSelect
        Else
        Run("C:\Program Files\Mozilla Firefox\firefox.exe")
        EndIf
EndSwitch
WEnd
Func Password()
    $child = GUICreate("logon", 200, 150)    
    $ok1 = GUICtrlCreateButton("OK", 140, 65, 50, 30)
    $user = GUICtrlCreateInput("", 10, 28, 75, 20)
    $pass = GUICtrlCreateInput("", 10, 73, 75, 20, $ES_PASSWORD)
    $Confpass = GUICtrlCreateInput("", 10, 128, 75, 20, $ES_PASSWORD)
    GUICtrlCreateLabel("Username", 10, 5, 75, 20)
    GUICtrlCreateLabel("Password", 10, 50, 75, 20)
    GUICtrlCreateLabel("Confirm Password", 10, 105, 95, 20)
    GUISetState(@SW_SHOW, $child)
    While 1
        $mmsg = GUIGetMsg()
        Switch $mmsg

            Case $GUI_EVENT_CLOSE
                GUIDelete($child)
                ExitLoop
            Case $ok1
                If GUICtrlRead($user) = "" Then
                MsgBox(16, "User", "You must enter a username!")
                ElseIf GUICtrlRead($pass) = "" Then
                MsgBox(16, "Confirm Password", "You must enter a password.")
                ElseIf GUICtrlRead($Confpass) = "" Then
                MsgBox(16,"Confirm Password", "You must enter a confirmation Password!")
                ElseIf GUICtrlRead($pass) <> GUICtrlRead($Confpass) Then
                MsgBox(16,"Confirm Password", "Passwords do not match, please re-enter!")
                Else
                IniWrite("pw.ini", "Section1", "Key", GUICtrlRead($user))
                IniWrite("pw.ini", "Section2", "Key", GUICtrlRead($pass))
                MsgBox(64,"Confirm Password", "Passwords Match!")
                GUIDelete($child)
                ExitLoop
                EndIf
        EndSwitch
    WEnd
EndFunc   ;==>Password
Edited by EndFunc
EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

  • 1 month later...

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...