Jump to content
Sign in to follow this  

Starting a function at start, list/conditional question

Recommended Posts

Hey everyone.

This is a script for clicking through some bookmarks. I could just, you know, use my mouse, but where's the fun in that? It does work, I'm just wondering how to... streamline it.

First, the script presses the 'g' key at the beginning to start the "Go" function. Can I get it to start the "Go" function when I start the script without making it press 'g'?

Second, I'm willing to bet that there's a much more efficient way to go through each of the mouse clicks than the huge list of 'ElseIf' commands.

I'm just asking because I want to see how I can write scripts more efficiently; this script by itself isn't exactly a challenge.

Global $spot = 1
HotKeySet ("{g}", "Go")
Send ( "{g}")

Func Go()
    If $spot = 1 Then
        MouseClick ( "left", 80, 880, 1, 2)
        WinWait ("Google")
        MouseClick ( "left", 315, 90, 1, 2)
        $spot = 2
    ElseIf $spot = 2 Then
        MouseClick ("left", 10, 65)
        WinWait ("The Escapist")
        $spot = 3
    ElseIf $spot = 3 Then
        MouseClick ("left", 30, 65)
        WinWait ("MLG")
        $spot = 4
    ElseIf $spot = 4 Then
        MouseClick ("left", 75, 65)
        WinWait ("Scottsdale")
        $spot = 5
    ElseIf $spot = 5 Then
        MouseClick ("left", 95, 65)
        WinWait ("Arizona")
        $spot = 6
    ElseIf $spot = 6 Then
        MouseClick ("left", 125, 65)
        $spot = 7

While $spot <> 7
    Sleep (100)

If $spot = 7 Then

I may or may not have to explain this, I don't know: the $spot variable and having everything in a... uh, "Func" function are so that the script waits for me to press 'g' while I look at a page, then continues. After the last page, it ends the script.

Edited by ponchato

Share this post

Link to post
Share on other sites


Global $spot = 1


Func Go()
    local $aspot[6][3] = [[1,"Google",80,40],[2,"The Escapist",10,65],[3,"MLG",30,65], _
    For $i = 0 To UBound($aspot)-1
        If $spot = $aspot[$i][0] Then
            MouseClick ("left", $aspot[$i][2], $aspot[$i][3])
            WinWait ($aspot[$i][1])
            $spot = $i +1

While $spot <> 7
    Sleep (100)

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...