Jump to content

Possible to save a variable Local?


Recommended Posts

Hello all today i want to ask you

 

if it possible when i for example set in the first programm variable $test1 = hello

the programms close but the variable saved and can i then open a new autoit script who show me then the variable $test1?

 

example :

$hInput_username = GUICtrlCreateInput("", 70, 12, 137, 21) ; ($hInput_username is for example = Maik)

then close the script/programm

now open the next programm and load the variable from the cache / ram

GUICtrlCreateLabel("hello welcome back " & $$hInput_username , 12, 14, 84, 17) ;(the label have the text : hello welcome back Maik)

 

 

if this possible?

 

thanks in advance

 

 

Link to comment
Share on other sites

Data stored in the local memory of the AutoIt script will be gone when you start your next script. So, cache/ram: no. But if you want to do it without file interaction, you could write something like an environment variable or a registry entry.

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
Local $Form1 = GUICreate("Form1", 327, 95, 192, 124)
Local $hInput_username = GUICtrlCreateInput(magicRead("hInput_username"), 16, 16, 121, 21)
Local $hLabel_username = GUICtrlCreateLabel("hello welcome back " & magicRead("hInput_username"), 16, 56, 221, 21) ;(the label have the text : hello welcome back Maik)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            magicWrite("hInput_username")
            GUIDelete()
            ExitLoop

    EndSwitch
WEnd

Func magicWrite($sGuiName)
    IniWrite(StringTrimRight(@ScriptFullPath, 3) & "ini", "saved", $sGuiName, GUICtrlRead(Eval($sGuiName)))
EndFunc   ;==>magicWrite

Func magicRead($sGuiName)
    Return IniRead(StringTrimRight(@ScriptFullPath, 3) & "ini", "saved", $sGuiName, "no one ?")
EndFunc   ;==>magicRead

:)

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...