Sign in to follow this  
Followers 0
BALA

MouseClick Help (again XD)

3 posts in this topic

Over the past 3 days, I've been working on a program that will automate tasks/actions you do on your computer for you. I'm relatively new at AutoIt, so bare with me. Right now I have a code that's suppose to record a mouse click you do when you press the Tab key and stop recording when you press it again, then repeat the click when you press the Enter key. For some reason it's not working. Could someone help me figure out what's wrong with the code?

#include <Array.au3>
#include <Misc.au3>

Dim $Position, $i = 0, $Record[1]
$score = 0
While 1
    If _IsPressed("09") Then
        $score = 1
    EndIf
    
    If $score = 1 Then
        If _IsPressed("01") Then
            $Position = MouseGetPos()
            $x = $Position[0]
            $y = $position[1]
            ReDim $Record[$i + 2]
            $Record[$i] = $x
            $Record[$i + 1] = $y
            $i += 2
        EndIf
    EndIf

    If $score = 0 Then
        If _IsPressed("0D") Then
            MouseClick("left", $x, $y, 1)
        EndIf
    EndIf
    sleep(10)
WEnd

[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

Share this post


Link to post
Share on other sites



To set your script to do things on a key press, use hotkeys. Straight out of the helpfile:

; Press Esc to terminate script, Pause/Break to "pause"

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage")  ;Shift-Alt-d

;;;; Body of program would go here ;;;;
While 1
    Sleep(100)
WEnd
;;;;;;;;

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func ShowMessage()
    MsgBox(4096,"","This is a message.")
EndFunc

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

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