Jump to content

Recommended Posts

Posted
$gui1=GUICreate("google", 250, 150)
$input1 = GUICtrlCreateInput("", 75, 40, 100, 25)
$OK1 = GUICtrlCreateButton("Done", 100, 120, 55, 20,$BS_DEFPUSHBUTTON)
GUISetState(@SW_SHOW,$gui1)

$google="google,hi,ih"

While 1
 Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE
         Exit
      Case $OK1
         CHANGEVARIABLE($google,'hi,hi,hi')

   EndSwitch
WEnd

So, what i want to do is..

I want to change $google variable value after pressed "ok" button, so that next time i open script (to run or to edit), value of $google will be new value.

it should permanently change value of that variable in script, so that even after i close this script and reopen it next day, new (changed value 'hi,hi,hi') value is there, rather then old value "google,hi,ih".

 

i don't think there is any direct function for it cause it checked it, so is there any way to do it??

 

Posted

thank you very much..

Actually i am trying to write an AI (not high level just basic).

After i complete it, is there a way to share it among all autoit user so that you can check it for improvement or use it for their daily tasks?

Posted

for simple data: 

Global $hGUI = GUICreate("Google", 407, 55, -1, -1)
Global $Input1 = GUICtrlCreateInput("google,hi,ih", 115, 16, 188, 21)
Global $OK1 = GUICtrlCreateButton("SAVE", 316, 8, 87, 36)
GUICtrlCreateLabel("Input data to save:", 16, 18, 93, 17)

Global $sFileToSaveData = @ScriptDir & "\" & @ScriptName & "_DATA.ini" ; Change to path you want to save
Global $Google = FileRead($sFileToSaveData)
If Not @error And $Google <> "" Then GUICtrlSetData($Input1, $Google)
GUISetState(@SW_SHOW, $hGUI)

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $OK1
            $Google = GUICtrlRead($Input1)
            CHANGEVARIABLE($Google)
            MsgBox(32, "Done", $Google & " saved to" & $sFileToSaveData)
    EndSwitch
    Sleep(10)
WEnd

Func CHANGEVARIABLE($VARIABLE)
    Local $hOpen = FileOpen($sFileToSaveData, 2 + 8 + 128)
    FileWrite($hOpen, $VARIABLE)
    Return SetError(@error, FileClose($hOpen), 1)
EndFunc   ;==>CHANGEVARIABLE

 

Regards,
 

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
  • Recently Browsing   0 members

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