Sign in to follow this  
Followers 0
blessthefall

Saving variables to a file to recall with another script

3 posts in this topic

I write a lot of bots for different games and distribute them around to a few friends for use.

I am, by no means, an AutoIt veteran and the scripts are all very simple.

I generally just combine a lot of (in my opinion =] ) clever loops and pixel checks (PixelCheckSum, PixelSearch, and PixelGetColor) to achieve what I want.

I've grown increasingly interested in the versatility of AutoIt, and am also interested in learning more about it. I have almost no prior programming experience. I also have zero experience with AutoIt GUI (something that i'm going to be delving into very soon).

So my first issue:

-I want to make a script that will open a window with one or more inputs. I want the user to be able to enter a value and then the script will save the input as a variable into a file so that the variable can be recalled by other scripts.

--------script 1--------

#include <GUIConstants.au3>

GUICreate("Inputs")

GUISetState (@SW_SHOW)

;here is the point where I get am unfamiliar completely. I suspect I should use GUICtrlCreateInput but I don't quite understand the example in the help file

;this is the example script:

;--------------------------------------------

;file = GUICtrlCreateInput ( "", 10, 5, 300, 20)

;GUICtrlSetState(-1,$GUI_DROPACCEPTED)

;GUICtrlCreateInput ("", 10, 35, 300, 20) ; will not accept drag&drop files

;$btn = GUICtrlCreateButton ("Ok", 40, 75, 60, 20)

;GUISetState ()

;--------------------------------------------

--------script 2--------

;this will be the recall script, not sure how this should be done so will put this off until later.

Any help would be appreciated, an explanation in simple terms would be grand too =]

Share this post


Link to post
Share on other sites



I write a lot of bots for different games and distribute them around to a few friends for use.

I am, by no means, an AutoIt veteran and the scripts are all very simple.

I generally just combine a lot of (in my opinion =] ) clever loops and pixel checks (PixelCheckSum, PixelSearch, and PixelGetColor) to achieve what I want.

I've grown increasingly interested in the versatility of AutoIt, and am also interested in learning more about it. I have almost no prior programming experience. I also have zero experience with AutoIt GUI (something that i'm going to be delving into very soon).

So my first issue:

-I want to make a script that will open a window with one or more inputs. I want the user to be able to enter a value and then the script will save the input as a variable into a file so that the variable can be recalled by other scripts.

--------script 1--------

#include <GUIConstants.au3>

GUICreate("Inputs")

GUISetState (@SW_SHOW)

;here is the point where I get am unfamiliar completely. I suspect I should use GUICtrlCreateInput but I don't quite understand the example in the help file

;this is the example script:

;--------------------------------------------

;file = GUICtrlCreateInput ( "", 10, 5, 300, 20)

;GUICtrlSetState(-1,$GUI_DROPACCEPTED)

;GUICtrlCreateInput ("", 10, 35, 300, 20) ; will not accept drag&drop files

;$btn = GUICtrlCreateButton ("Ok", 40, 75, 60, 20)

;GUISetState ()

;--------------------------------------------

--------script 2--------

;this will be the recall script, not sure how this should be done so will put this off until later.

Any help would be appreciated, an explanation in simple terms would be grand too =]

Use Koda. Makes everything really easy and gives you a GUI designer.

(If you don't have it download the full Scite editor here: Scite Full)

Example(Obviously needs tweaking. But it only took me 1:30 seconds to get this far with Koda):

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 324, 332, 193, 125)
$Input1 = GUICtrlCreateInput("Input1", 45, 39, 221, 21)
$Input2 = GUICtrlCreateInput("Input2", 45, 81, 221, 21)
$Button1 = GUICtrlCreateButton("Button1", 92, 213, 137, 71, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            FileWrite(@ScriptDir & '\Variables.txt', GUICtrlRead($Input1) & @CRLF & GUICtrlRead($Input2))

    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

Use Koda. Makes everything really easy and gives you a GUI designer.

(If you don't have it download the full Scite editor here: Scite Full)

Example(Obviously needs tweaking. But it only took me 1:30 seconds to get this far with Koda):

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 324, 332, 193, 125)
$Input1 = GUICtrlCreateInput("Input1", 45, 39, 221, 21)
$Input2 = GUICtrlCreateInput("Input2", 45, 81, 221, 21)
$Button1 = GUICtrlCreateButton("Button1", 92, 213, 137, 71, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            FileWrite(@ScriptDir & '\Variables.txt', GUICtrlRead($Input1) & @CRLF & GUICtrlRead($Input2))

    EndSwitch
WEnd

Ah, many thanks. This is helpful except for the fact that when looking at the code I'm lost >_>. I like to know exactly what's going on, thus far all of my scripts have been written with notepad.

I'll check it out tho and come back with any new questions I may have.

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