Jump to content
Sign in to follow this  
kjpolker

IniWrite/Read won't work.

Recommended Posts

kjpolker

Okay so I am wondering if you can't write an input when your input reads your write. lol if that makes sense, take a look at the script:

Global $Name, $Pass, $Input1, $Input2
$Form1 = GUICreate("Auto Login!", 326, 151, 193, 125)
GUISetIcon(@ScriptDir & "\Icons\snow-flake.ico")
GUISetBkColor(0x000000)
$Pic1 = GUICtrlCreatePic(@ScriptDir & "\Icons\AIPM.jpg", 3, 0, 320, 50, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Input1 = GUICtrlCreateInput($Name, 102, 48, 137, 21)
GUICtrlSetCursor (-1, 5)
$Username = IniWrite("M:\Kevin\Autoit\AIPM\Config.ini", "USERNAME", "Key", $Input1)
$Input2 = GUICtrlCreateInput($Pass, 102, 74, 137, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
GUICtrlSetCursor (-1, 5)
$Password = IniWrite("M:\Kevin\Autoit\AIPM\Config.ini", "PASSWORD", "Key", $Input2)
$Button1 = GUICtrlCreateButton("Login!", 118, 104, 105, 25, 0)
GUICtrlSetCursor (-1, 0)
$Button2 = GUICtrlCreateButton("Click!", 16, 48, 65, 81, 0)
GUICtrlSetFont(-1, 10, 800, 0, "Magneto")
GUICtrlSetCursor (-1, 0)
$Label1 = GUICtrlCreateLabel("Click! to locate", 3, 131, 125, 17)
GUICtrlSetColor(-1, 0x00FFFF)
$Label2 = GUICtrlCreateLabel(" Dazzled", 248, 122, 71, 28)
GUICtrlSetFont(-1, 14, 400, 2, "Harlow Solid Italic")
GUICtrlSetColor(-1, 0x00FFFF)
$Name = IniRead("M:\USER\Autoit\AIPM\Config.ini", "USERNAME", "Key", "Not Found")
$Pass = IniRead("M:\USER\Autoit\AIPM\Config.ini", "PASSWORD", "Key", "Not Found")
GUISetState(@SW_SHOW)

As you should notice I have 2 Iniwrites writing the the input of 2 inpute boxes, and I have 2 Inireads reading the config.sys and putting them in the input boxes, I know it sounds confusing but just look at the script. Basically my goal was that if there is nothing in the input boxes ($User, $Pass) than it obviously leaves the config.sys key value blank, and as soon as I type in anyhting to the boxes it write it in config.sys. This was to achieve saving the information of login and pass until using a different username and password. If you kind of catch my drift please help me out, otherwise say so and I will rephrase. Thank you.

Share this post


Link to post
Share on other sites
Vanberk

Okay so I am wondering if you can't write an input when your input reads your write. lol if that makes sense, take a look at the script:

Global $Name, $Pass, $Input1, $Input2
$Form1 = GUICreate("Auto Login!", 326, 151, 193, 125)
GUISetIcon(@ScriptDir & "\Icons\snow-flake.ico")
GUISetBkColor(0x000000)
$Pic1 = GUICtrlCreatePic(@ScriptDir & "\Icons\AIPM.jpg", 3, 0, 320, 50, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Input1 = GUICtrlCreateInput($Name, 102, 48, 137, 21)
GUICtrlSetCursor (-1, 5)
$Username = IniWrite("M:\Kevin\Autoit\AIPM\Config.ini", "USERNAME", "Key", $Input1)
$Input2 = GUICtrlCreateInput($Pass, 102, 74, 137, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
GUICtrlSetCursor (-1, 5)
$Password = IniWrite("M:\Kevin\Autoit\AIPM\Config.ini", "PASSWORD", "Key", $Input2)
$Button1 = GUICtrlCreateButton("Login!", 118, 104, 105, 25, 0)
GUICtrlSetCursor (-1, 0)
$Button2 = GUICtrlCreateButton("Click!", 16, 48, 65, 81, 0)
GUICtrlSetFont(-1, 10, 800, 0, "Magneto")
GUICtrlSetCursor (-1, 0)
$Label1 = GUICtrlCreateLabel("Click! to locate", 3, 131, 125, 17)
GUICtrlSetColor(-1, 0x00FFFF)
$Label2 = GUICtrlCreateLabel(" Dazzled", 248, 122, 71, 28)
GUICtrlSetFont(-1, 14, 400, 2, "Harlow Solid Italic")
GUICtrlSetColor(-1, 0x00FFFF)
$Name = IniRead("M:\USER\Autoit\AIPM\Config.ini", "USERNAME", "Key", "Not Found")
$Pass = IniRead("M:\USER\Autoit\AIPM\Config.ini", "PASSWORD", "Key", "Not Found")
GUISetState(@SW_SHOW)

As you should notice I have 2 Iniwrites writing the the input of 2 inpute boxes, and I have 2 Inireads reading the config.sys and putting them in the input boxes, I know it sounds confusing but just look at the script. Basically my goal was that if there is nothing in the input boxes ($User, $Pass) than it obviously leaves the config.sys key value blank, and as soon as I type in anyhting to the boxes it write it in config.sys. This was to achieve saving the information of login and pass until using a different username and password. If you kind of catch my drift please help me out, otherwise say so and I will rephrase. Thank you.

It create Input1 and Input2 but the $Name and $Pass in them wont receive anything.

If you move

$Name = IniRead("M:\USER\Autoit\AIPM\Config.ini", "USERNAME", "Key", "Not Found")
$Pass = IniRead("M:\USER\Autoit\AIPM\Config.ini", "PASSWORD", "Key", "Not Found")
And place it under
GUISetBkColor(0x000000)

So it first read the INI file and put the username and password inside the $Name and $Pass. Now the Input1 and Input2 will get the name and pass from the ini file.

I hope this is what you where looking for :)

- Vanberk

Share this post


Link to post
Share on other sites
kjpolker

Unfortunatly it still doesn't seem to work, I believe the problem is that it is trying to write the input, but the input is trying to read the config. so they are trying to read each other, I am looking for a way to read the input box IF there is a username and password inserted, and save it, and IF there is no username/password than I want it to wait for a text to be inserted than write it in the config. Here is the code of my config.sys and for some very odd reason it is putting in the key=value for both username/password as 4 and 5, idk why.

[AIPM]
Key=D:\World of Warcraft\Launcher.exe
[USERNAME]
Key=4
[PASSWORD]
Key=5

Share this post


Link to post
Share on other sites
Vanberk

Change

$Input2 = GUICtrlCreateInput($Pass, 102, 74, 137, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
To

$Input2 = GUICtrlCreateInput($Pass, 102, 74, 137, 21, 0xA0)

Change

$Pic1 = GUICtrlCreatePic(@ScriptDir & "\Icons\AIPM.jpg", 3, 0, 320, 50, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
To

$Pic1 = GUICtrlCreatePic(@ScriptDir & "\Icons\AIPM.jpg", 3, 0, 320, 50, 0x4020100)

Share this post


Link to post
Share on other sites
kjpolker

Not exactly sure what that coding did, but I know it still didn't fix my problem =( Thank you for helping though, I still get a 4 and a 5 in the config.sys username/password value.

Share this post


Link to post
Share on other sites
Vanberk

Not exactly sure what that coding did, but I know it still didn't fix my problem =( Thank you for helping though, I still get a 4 and a 5 in the config.sys username/password value.

Wait, I think I misunderstood you. You can start the program but the things you put inside the Inputs will not be saved?

Put these 2 lines at the bottom of your script.

IniWrite("M:\Kevin\Autoit\AIPM\Config.ini", "USERNAME", "Key", $Input1)
IniWrite("M:\Kevin\Autoit\AIPM\Config.ini", "PASSWORD", "Key", $Input2)

Now when you exit the program it will save your $input1 and 2 inside the ini file.

If that is still not the problem at all then yea, try explain a bit more >.<

Edited by Vanberk

Share this post


Link to post
Share on other sites
kjpolker

Still no luck =(

Ok here is my rephrase, I have 2 input boxes, a config.sys. Here is the layout of the config.sys:

[AIPM]
Key=
[USERNAME]
Key=
[PASSWORD]
Key=

When I start my program I want my input box to say what is in the text file, so in my Username input it says the username, and in my password input, it says my password. HOWEVER, as you can see the username and password in the config.sys are not determined yet, so as being the first time I launch my application the username/password are blank, I than type in the suername/password and it saves both of them to the config.sys. Now everytime I launch my program the username and password are auto inserted into my input boxes UNTIL they are changed, where I have to insert the new username/password for the first time, until changed again. So here is my entire script un modified:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ImageListConstants.au3>

#Region ### START Koda GUI section ### Form=c:\users\kevin\desktop\jewel crafter\form1.kxf
Global $Name, $Pass, $Input1, $Input2
$Form1 = GUICreate("Auto Icy Prism Maker!", 326, 151, 193, 125)
GUISetIcon(@ScriptDir & "\Icons\snow-flake.ico")
GUISetBkColor(0x000000)
$Name = IniRead("M:\USER\Autoit\AIPM\Config.ini", "USERNAME", "Key", "Not Found")
$Pass = IniRead("M:\USER\Autoit\AIPM\Config.ini", "PASSWORD", "Key", "Not Found")
$Pic1 = GUICtrlCreatePic(@ScriptDir & "\Icons\AIPM.jpg", 3, 0, 320, 50, 0x4020100)
$Input1 = GUICtrlCreateInput($Name, 102, 48, 137, 21)
GUICtrlSetCursor (-1, 5)
$Input2 = GUICtrlCreateInput($Pass, 102, 74, 137, 21, 0xA0)
GUICtrlSetCursor (-1, 5)
$Button1 = GUICtrlCreateButton("Login!", 118, 104, 105, 25, 0)
GUICtrlSetCursor (-1, 0)
$Button2 = GUICtrlCreateButton("Click!", 16, 48, 65, 81, 0)
GUICtrlSetFont(-1, 10, 800, 0, "Magneto")
GUICtrlSetCursor (-1, 0)
$Label1 = GUICtrlCreateLabel("Click! to locate WoW.exe", 3, 131, 125, 17)
GUICtrlSetColor(-1, 0x00FFFF)
$Label2 = GUICtrlCreateLabel(" Dazzled", 248, 122, 71, 28)
GUICtrlSetFont(-1, 14, 400, 2, "Harlow Solid Italic")
GUICtrlSetColor(-1, 0x00FFFF)
$Username = IniWrite("M:\Kevin\Autoit\AIPM\Config.ini", "USERNAME", "Key", $Input1)
$Password = IniWrite("M:\Kevin\Autoit\AIPM\Config.ini", "PASSWORD", "Key", $Input2)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $Paused
HotKeySet( "{PAUSE}", "TogglePause")
HotKeySet( "{ESC}", "Terminate")    
Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc
Func Terminate()
    Exit 0
EndFunc

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button2
            $Dir1 = FileOpenDialog("Locate WoW.exe on your hard drive", @ProgramFilesDir, "Exe (*.exe)" )
            IniWrite("M:\Kevin\Autoit\AIPM\Config.ini", "AIPM", "Key", $Dir1)
        Case $Button1
            $Dir2 = IniRead("M:\Kevin\Autoit\AIPM\Config.ini", "AIPM", "Key", "NotFound")
            ShellExecute($Dir2)
            WinWaitActive("[TITLE:World of Warcraft v3.2.2.10505]")
            Sleep(1000)
            ControlClick("[TITLE:World of Warcraft v3.2.2.10505]", "", "[CLASSNN:Button9; TEXT:Play; INSTANCE:1]")
            WinWaitActive("[TITLE:World of Warcraft]")
    EndSwitch
WEnd

Take a look at that and see if we can figure something out, it is very hard to explain what I want but if you take a close look at the lines of:

$Input1, $Input2, $Username, and $Password, you should see what I plan on doing. Hope for luck =/

Share this post


Link to post
Share on other sites
Vanberk

Tested and should work.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ImageListConstants.au3>

#Region ### START Koda GUI section ### Form=c:\users\kevin\desktop\jewel crafter\form1.kxf
Global $Name, $Pass, $Input1, $Input2
$Form1 = GUICreate("Auto Icy Prism Maker!", 326, 151, 193, 125)
GUISetIcon(@ScriptDir & "\Icons\snow-flake.ico")
GUISetBkColor(0x000000)
$Name = IniRead("M:\Kevin\Autoit\AIPM\Config.ini", "USERNAME", "Key", "")
$Pass = IniRead("M:\Kevin\Autoit\AIPM\Config.ini", "PASSWORD", "Key", "")
$Pic1 = GUICtrlCreatePic(@ScriptDir & "\Icons\AIPM.jpg", 3, 0, 320, 50, 0x4020100)
$Input1 = GUICtrlCreateInput($Name, 102, 48, 137, 21)
GUICtrlSetCursor (-1, 5)
$Input2 = GUICtrlCreateInput($Pass, 102, 74, 137, 21, 0xA0)
GUICtrlSetCursor (-1, 5)
$Button1 = GUICtrlCreateButton("Login!", 118, 104, 105, 25, 0)
GUICtrlSetCursor (-1, 0)
$Button2 = GUICtrlCreateButton("Click!", 16, 48, 65, 81, 0)
GUICtrlSetFont(-1, 10, 800, 0, "Magneto")
GUICtrlSetCursor (-1, 0)
$Label1 = GUICtrlCreateLabel("Click! to locate WoW.exe", 3, 131, 125, 17)
GUICtrlSetColor(-1, 0x00FFFF)
$Label2 = GUICtrlCreateLabel(" Dazzled", 248, 122, 71, 28)
GUICtrlSetFont(-1, 14, 400, 2, "Harlow Solid Italic")
GUICtrlSetColor(-1, 0x00FFFF)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $Paused
HotKeySet( "{PAUSE}", "TogglePause")
HotKeySet( "{ESC}", "Terminate")    
Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc
Func Terminate()
    Exit 0
EndFunc

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
            IniWrite("M:\Kevin\Autoit\AIPM\Config.ini", "USERNAME", "Key", GUICtrlRead($Input1))
            IniWrite("M:\Kevin\Autoit\AIPM\Config.ini", "PASSWORD", "Key", GUICtrlRead($Input2))
            Exit
        Case $Button2
            $Dir1 = FileOpenDialog("Locate WoW.exe on your hard drive", @ProgramFilesDir, "Exe (*.exe)" )
            IniWrite("M:\Kevin\Autoit\AIPM\Config.ini", "AIPM", "Key", $Dir1)
        Case $Button1
            $Dir2 = IniRead("M:\Kevin\Autoit\AIPM\Config.ini", "AIPM", "Key", "NotFound")
            ShellExecute($Dir2)
            WinWaitActive("[TITLE:World of Warcraft v3.2.2.10505]")
            Sleep(1000)
            ControlClick("[TITLE:World of Warcraft v3.2.2.10505]", "", "[CLASSNN:Button9; TEXT:Play; INSTANCE:1]")
            WinWaitActive("[TITLE:World of Warcraft]")
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
kjpolker

Thank you so much! It is perfect, so I just needed to throw the 2 lines at the end I can see...Well at least we got it! Thank you again.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.