Jump to content
Sign in to follow this  
pwnt

Saving a value multiple times, and using it in a different function

Recommended Posts

pwnt

Ok, I am having a problem here, I have a script that I'm working on that is gonna record mousepos with the click of a button. When I click the button, Autoit will save the value with mousegetpos, If i click the button multiple times I want the mouse positions to be saved in a "bin" where I can access them later in a different function.

Something like this I was thinking...

HotKeySet( "{f8}","record")
HotKeySet("{F5}","Start")


while 1 
    sleep(10)
WEnd

func record()
;trying to make the record values go up in value every time i click so I can use it multiple times in a row. 
;trying to use a mathematical function that adds +1 to the function every time, like: first time record1, second record2, record 3
    
    $record1+1= MouseGetPos()
;will that +1 work?
; and now I want to save the value it just got in a "bin" so I can use it later in other functions
    SAVING SCRIPT HERE -.-..-.-.-.-.-.-..-..-
EndFunc


func start()
    while 1
        mousemove($record1+1[0],$record1+1[1],50)
    ;does this check if there is a function called
        if $record2+1 = False
            then;gonna go to another value no need to have it here
        EndIf
    WEnd
EndFunc

so, most importantly, will that +1 work after functions to make the func be called record2 and next time record3 ETC.

and how do you save the values to a bin so you can access them later in a different function.

Share this post


Link to post
Share on other sites
exodius

You'll most likely want to use an Array. Example:

#include <Array.au3> ; Only necessary for easy display using _ArrayDisplay below

Dim $array[10]

For $x = 0 To UBound ($array)-1
    $array[$x] = $x
Next

_ArrayDisplay($array) ; Only necessary for easily displaying the results, you can use a For...Next Loop identical to the one above to read back through them.

*Edit - You can also dynamically increase your array size using ReDim

Edited by exodius

Share this post


Link to post
Share on other sites
pwnt

You'll most likely want to use an Array. Example:

#include <Array.au3> ; Only necessary for easy display using _ArrayDisplay below

Dim $array[10]

For $x = 0 To UBound ($array)-1
    $array[$x] = $x
Next

_ArrayDisplay($array) ; Only necessary for easily displaying the results, you can use a For...Next Loop identical to the one above to read back through them.

*Edit - You can also dynamically increase your array size using ReDim

Ok, I've been trying to learn arrays for a while now, I understand it atleast decently, but when it comes to mousepos, I can't use the [0], and [1], after the $array[2] for example.

Atleast it solved one of my problems, the global functions, thanks for that.

So got any ideas? been searching around for about an hour now, just cant find it.

Thanks in advance ^_^

Share this post


Link to post
Share on other sites
Aceguy

there ya go

#include<misc.au3>
#include<array.au3>
dim $array[1]

Do
    
    if _ispressed("01") Then
        while _IsPressed("01") 
            sleep(50)
        WEnd
        
        $ms=MouseGetPos()
        _ArrayAdd($array,$ms[0]&","&$ms[1])
    
    EndIf
until _ispressed("1b");press escape to quit

_ArrayDisplay($array)

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.