Jump to content

Variables turned into functions


 Share

Recommended Posts

Ok this is what i was thinking about is it possible to use the value of a variable as a autoit script???

for ex: $i='msgbox(0 , "" , "lol")'

and i want autoit to run it???

(maybee it's a noob question, maybee not but.... i gotta know)

pls help

Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Link to comment
Share on other sites

I think it is actually possible. I don't know how to do it, but I use something similar in almost all my scripts.

Here's an example:

#include <Misc.au3>
#include <GUIConstants.au3>

HotKeySet("{F1}", "On")
HotKeySet("{F2}", "Off")
HotKeySet("{F3}", "Play")
HotKeySet("{F4}", "Stop")

Global $trigger = 0
Global $score = 0
Global $click = 1
Global $click2 = -1
Dim $Position, $i = 0, $Record[1]

Opt("GUIOnEventMode", 1)
$mainwindow = GUICreate("BA-AUTO *BETA*", 200, 160)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
$on = GUICtrlCreateButton("On (F1)", 40, 10, 120)
GUICtrlSetOnEvent($on, "On")
$off = GUICtrlCreateButton("Off (F2)", 40, 40, 120)
GUICtrlSetOnEvent($off, "Off")
$play = GUICtrlCreateButton("Play (F3)", 40, 90, 120)
GUICtrlSetOnEvent($play, "Play")
$stop = GUICtrlCreateButton("Stop (F4)", 40, 120, 120)
GUICtrlSetOnEvent($stop, "Stop")
GUISetState(@SW_SHOW)

Func CLOSEClicked()
  Exit
EndFunc

Func On()
    $score = 1
EndFunc

Func Off()
    $score = 0
EndFunc

Func Play()
    $trigger = 1
EndFunc

Func Stop()
    $trigger = 0
EndFunc

While 1
    While 1
        If $score = 1 Then
            If _IsPressed("01") Then
                $click = $click + 1
                $Position = MouseGetPos() ; <------setting variable
                $x = $Position[0] ; <--------using it/ setting variable
                $y = $position[1] ; <--------using it/ setting variable
                ReDim $Record[$i + 2]
                $Record[$i] = $x ; <--------using it/ setting variable
                $Record[$i + 1] = $y ; <-----using it/ setting variable
                $i += 2
            EndIf
            sleep(10)
        EndIf
        If $score = 0 Then
            ExitLoop
        EndIf
    WEnd

    While 1
        If $trigger = 1 Then
            For $n = 0 to $click
                $a = $click2 + 1 
                $b = $click2 + 2
                MouseClick("left", $Record[$a], $Record[$b], 1) ; <----Using it
                $click2 = $click2 + 2
                If $n = $click - 2 Then
                    $click2 = -1
                    $n = 0
                EndIf
                If $trigger = 0 Then
                    ExitLoop
                EndIf
            Next
        EndIf
        If $trigger = 0 Then
            ExitLoop
        EndIf
    WEnd
WEnd
Edited by BALA
[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Link to comment
Share on other sites

  • Developers

... I don't know how to do it, but I use something similar in almost all my scripts.....

I think its kinda late for me to understand this one .,........ :P

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

tnx and for pc that don't have autoit installed just put the exe there and use it's path instead of the @AutoItExe macro right?

Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Link to comment
Share on other sites

I think its kinda late for me to understand this one .,........ :P

Hey I come up with great things without understanding them!

Hence where I got the idea for an electric tooth pick :D

Edited by BALA
[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Link to comment
Share on other sites

tnx and for pc that don't have autoit installed just put the exe there and use it's path instead of the @AutoItExe macro right?

It's not neccessary. It will work also in compiled state without AutoIt instaled. See this:

@AutoItExe - The full path and filename of the AutoIt executable currently running. For compiled scripts it is the path of the compiled script.

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...