Jump to content

Saving variables and opening variables - (Moved)


Recommended Posts

Good afternoon everyone, I am from San Jose de Mayo, Uruguay. I started two weeks ago with Autoit but I have already programmed some functional things. Now my question is me in one of the Scrpts I use MouseGetPos () to get the mouse coordinates and I save them in Variables something like this:

       func posmovimiento()  ; seleccionar la posicion del boton teletransportar
        MsgBox(0, "Selecion de posicion", "Selecciona la posicion inicial del boton Teletrasportar en tu pc y presiona espacio para continuar")
        $mouse = MouseGetPos()
        $lockx1 = $mouse[0]
        $locky1 = $mouse[1]
        MsgBox(0, "Selecion de posicion", "Selecciona la posicion final del boton Teletrasportar en tu pc y presiona espacio para continuar")
        $mouse = MouseGetPos()
        $lockx2 = $mouse[0]
        $locky2 = $mouse[1]
        EndFunc

 

Those variables are already declared as global at the beginning of the Script and the moment I do that they change, but when I close the program and reopen it I have to do it again because they return to the initial value of the declaration I gave them. My question is how can I save them in a .txt or .ini file that they are saved and that the next time I open the program, read them from that file? I would like if they were so kind they could guide me a little.

Link to post
Share on other sites
1 minute ago, Nine said:

Look at documentation and examples in help file under IniRead / IniWrite

im looking your work in the forum you are great im glad why you are the first to aswer me. 
Maybe i see this IniWrite (@ScriptDir & "\ MyVars.ini", "Variables", "variable_a", $ variable_a) but I don't know how to implement it well

Link to post
Share on other sites

Quite simple.  Every time you change the value of a variable that you want to keep in the ini file, you use IniWrite.  Do that for every variables that you want to keep.

Link to post
Share on other sites

i can solved but not for the guide. 

so declare the variables:


Global $lockx1 = IniRead(@ScriptDir & "\ variables.ini", "teletransportar", "lockx1", "")
Global $locky1 = IniRead(@ScriptDir & "\ variables.ini", "teletransportar", "locky1", "")
Global $lockx2 = IniRead(@ScriptDir & "\ variables.ini", "teletransportar", "lockx2", "")
Global $locky2 = IniRead(@ScriptDir & "\ variables.ini", "teletransportar", "locky2", "")

 

func posmovimiento()
        ; seleccionar la posicion del boton teletransportar
        MsgBox(0, "Selecion de posicion", "Selecciona la posicion inicial del boton Teletrasportar en tu pc y presiona espacio para continuar")
        $mouse = MouseGetPos()
        $lockx1 = $mouse[0]
        $locky1 = $mouse[1]
        IniWrite (@ScriptDir & "\ variables.ini", "teletransportar", "lockx1", $lockx1)
        IniWrite (@ScriptDir & "\ variables.ini", "teletransportar", "locky1", $locky1)
        MsgBox(0, "Selecion de posicion", "Selecciona la posicion final del boton Teletrasportar en tu pc y presiona espacio para continuar")
        $mouse = MouseGetPos()
        $lockx2 = $mouse[0]
        $locky2 = $mouse[1]
        IniWrite (@ScriptDir & "\ variables.ini", "teletransportar", "lockx2", $lockx2)
        IniWrite (@ScriptDir & "\ variables.ini", "teletransportar", "locky2", $locky2)
    EndFunc

 

 

Thank soo much ! 

Link to post
Share on other sites
  • Moderators

Moved to the appropriate forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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

    No registered users viewing this page.

×
×
  • Create New...