Sign in to follow this  
Followers 0
Sobiech

How To...

21 posts in this topic

Hi :)

Simple question

How to remember (by program) text what i was wrote in Inputbox?

Example

I was wrote some text in some program to input box (long text) and i close the program

I dont want write this text again when i open this program again ;)

Is there any way to remember what user set in inputs, before he close the program?


This world is crazy

Share this post


Link to post
Share on other sites



You could use an INI-file to save the data. (IniWrite on Exit, IniRead on Startup)


*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi :)

Simple question

How to remember (by program) text what i was wrote in Inputbox?

Example

I was wrote some text in some program to input box (long text) and i close the program

I dont want write this text again when i open this program again ;)

Is there any way to remember what user set in inputs, before he close the program?

See the INI functions in the Help file under Function Reference >> File, Directory and Disk functions Reference

The two you are looking for are IniWrite and IniRead

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

I have ~~ 30 inputs xd

But ok i will try :)


This world is crazy

Share this post


Link to post
Share on other sites

I have ~~ 30 inputs xd

But ok i will try :)

use Arrays and For-Loops ;)

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Small snipit for ideas...

Dim $Input[11], $Ini_File = False, $File_Location = @ScriptDir & "Input.ini"

If FileExists($File_Location) Then $Ini_File = True

For $x = 1 To 10
    If $Ini_File Then $Input[$x] = IniRead($File_Location, "Input", $x, "")
    $Input[$x] = InputBox("Input", "Please type in your input", $Input[$x])
    IniWrite($File_Location, "Input", $x, $Input[$x])
Next

8)

Fixed IniRead() error, still not tested

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

$sIni = @AppDataDir & "\Myapp\Myapp.ini"
$Input1 = GUICtrlCreateInput()
$Input2 = GUICtrlCreateInput()
more
more
more
etc.
$input30 = GUICtrlCreateInput()

For $i = $Input1 To $Input30
    GUICtrlSetData($i, IniRead($sIni, "Settings", $i, ""))
Next

GUISetState()

While 1
   $nMsg = GUIGetMsg()
   Switch $Msg
      Case -3
         For $i = $Input1 To $Input30
             If IniRead(IniRead($sIni, "Settings", $i, "") <> GUICtrlRead($i) Then
                 IniWrite($sIni, "Settings", $i, GUICtrlRead($i)
             EndIf
         Next
         Exit
   EndSwitch
Wend

Edit: Corrected closing code tag

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

Ok byt if my inputs have other names than "$InputX" ? Example

$sIni = @AppDataDir & "\Myapp\Myapp.ini"
$StartKey = GUICtrlCreateInput()
$RunKey = GUICtrlCreateInput()
$ExitKey = GUICtrlCreateInput()

Can I use

Dim $startkey[0], $runkey[1] ???

How can i use "for loop" if my inputs have the captions above


This world is crazy

Share this post


Link to post
Share on other sites

Can I use

Dim $startkey[0], $runkey[1] ???

No, this will not work.

How can i use "for loop" if my inputs have the captions above

You will not be able to use a "for loop" with different names

(unless they are in an array, but that is another story and more complicated)

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

$sIni = @AppDataDir & "\Myapp\Myapp.ini"
$Input1 = GUICtrlCreateInput()
$Input2 = GUICtrlCreateInput()
more
more
more
etc.
$input30 = GUICtrlCreateInput()

For $i = $Input1 To $Input30
    GUICtrlSetData($i, IniRead($sIni, "Settings", $i, ""))
Next

GUISetState()

While 1
   $nMsg = GUIGetMsg()
   Switch $Msg
      Case -3
         For $i = $Input1 To $Input30
             If IniRead(IniRead($sIni, "Settings", $i, "") <> GUICtrlRead($i) Then
                 IniWrite($sIni, "Settings", $i, GUICtrlRead($i)
             EndIf
         Next
         Exit
   EndSwitch
Wend

Edit: Corrected closing code tag

I have Syntax error :\

C:\Project\123.au3(278,78) : ERROR: syntax error
             If IniRead(IniRead($Ini, "Settings", $i, "") <> GUICtrlRead($i) Then
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Project\123.au3(279,64) : ERROR: syntax error
                 IniWrite($Ini, "Settings", $i, GUICtrlRead($i)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

and more more more more in rest od code (but only if i use your code :|)


This world is crazy

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

If IniRead(IniRead($sIni, "Settings", $i, "")) <> GUICtrlRead($i) Then
                 IniWrite($sIni, "Settings", $i, GUICtrlRead($i))

You're missing the closing parentheses.

C:\Project\123.au3(283,46) : ERROR: IniRead() [built-in] called with wrong number of args.
    If IniRead(IniRead($Ini, "Settings", $i, ""))
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Project\D2NT1.5v3.6M2ConfigEditorByInFlames.au3 - 1 error(s), 0 warning(s)
>Exit code: 2    Time: 0.217

O_o

Ahh and i change names of $inputs :)

I have now 61 input fields ;)

Edited by Sobiech

This world is crazy

Share this post


Link to post
Share on other sites

Sorry, moi mistake:

If IniRead($sIni, "Settings", $i, "") <> GUICtrlRead($i) Then
                 IniWrite($sIni, "Settings", $i, GUICtrlRead($i))

This is syntactically correct, it might not be correct though.

Share this post


Link to post
Share on other sites

I think it was me that left off the closing parenthesis. Sorry about that.


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

Ok thx now its work :)

So I have

For $i = $Input1 To $Input61
    GUICtrlSetData($i, IniRead($Ini, "Settings", $i, ""))
Next


While 1
   $nMsg = GUIGetMsg()
   Switch $nMsg
      Case -3
         For $i = $Input1 To $Input61
If IniRead($Ini, "Settings", $i, "") <> GUICtrlRead($i) Then
                 IniWrite($Ini, "Settings", $i, GUICtrlRead($i))

             EndIf
         Next
         Exit
   EndSwitch
Wend

I think this can help me to load last $inputs from .ini?

And one more thing, actually i dont have .ini from i can load informations. First i must create it :\

I used one time this thing

IniWrite($Ini, "Keys", "StartKey", $input43)

And this is ok, but i have 61 inputs O_o.

Is there faster way to create that ini?


This world is crazy

Share this post


Link to post
Share on other sites

For $i = 1 To 61
    IniWrite($Ini, "Keys", $i, Eval("Input" & $i))
Next

It's not recommended to use control's ID as the key, value, or iterator (such as in a For...Next loop). It's not consistent and is bugs prone. You can build an array of input, using loops where the iterator is an index. Just my thought.

Share this post


Link to post
Share on other sites

Extremly bad-written and over-exaggerated code FTW!

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$INI = "MyINI.ini"

$Form1 = GUICreate("Massive over-exaggeration FTW", 800, 600)
Dim $Input[85]
Dim $InputText[85]

For $n = 0 To UBound($InputText)-1 Step 1
    $InputText[$n] = IniRead($INI,"Inputs","Input"&$n,"")
Next

$n = 0
For $x= 8 To 600 Step 130
    For $y = 8 To 400 Step 24
    $Input[$n] = GUICtrlCreateInput($InputText[$n], $x, $y, 121, 21)
    $n+=1
Next
Next
$Save = GUICtrlCreateButton("Save values",8,450,100,100)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $save
            For $n = 0 To UBound ($Input)-1 Step 1
                ToolTip("saving value " & $n)
                IniWrite($INI,"Inputs","Input"&$n,GUICtrlRead($Input[$n]))
            Next

        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

[font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size]

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

You chaged my life O_o

And Thx for all who help me :)

Now i must understand your code in 100% ;)

Edited by Sobiech

This world is crazy

Share this post


Link to post
Share on other sites

me too! lol

We have many choices.... :)

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Ok i did what i want :)

Big thanks for all ;)


This world is crazy

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