Sign in to follow this  
Followers 0
BALA

Help debugging code

4 posts in this topic

#1 ·  Posted (edited)

I have a program here that will record mouse click then play it back for you. Here's the code that works:

#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("12") Then
            MouseClick("left", $x, $y, 1)
        EndIf
    EndIf
    
    If _IsPressed("0D") Then
        $score = 0
    EndIf
    sleep(10)
WEndoÝ÷ ØÛhºÇ¡¢ÙÊȧ²×vÊr^vØb±«­¢+Ø¥¹±Õ±Ðí5¥Í¹ÔÌÐì()!½Ñ-åMÐ ÅÕ½ÐííÅôÅÕ½Ðì°ÅÕ½Ðí=¸ÅÕ½Ðì¤)!½Ñ-åMÐ ÅÕ½ÐííÉôÅÕ½Ðì°ÅÕ½Ðí=ÅÕ½Ðì¤)!½Ñ-åMÐ ÅÕ½ÐííÍôÅÕ½Ðì°ÅÕ½ÐíA±äÅÕ½Ðì¤()¥´ÀÌØíA½Í¥Ñ¥½¸°ÀÌØí¤ôÀ°ÀÌØíI½ÉlÅt(ÀÌØíͽÉôÀ)]¡¥±Ä(Õ¹=¸ ¤($$ÀÌØíͽÉôÄ(%¹Õ¹((%ÀÌØíͽÉôÄQ¡¸(%}%ÍAÉÍÍ ÅÕ½ÐìÀÄÅÕ½Ðì¤Q¡¸(ÀÌØíA½Í¥Ñ¥½¸ô5½ÕÍÑA½Ì ¤(ÀÌØíàôÀÌØíA½Í¥Ñ¥½¹lÁt(ÀÌØíäôÀÌØíÁ½Í¥Ñ¥½¹lÅt(I¥´ÀÌØíI½ÉlÀÌØí¤¬Ét(ÀÌØíI½ÉlÀÌØí¥tôÀÌØíà(ÀÌØíI½ÉlÀÌØí¤¬ÅtôÀÌØíä(ÀÌØí¤¬ôÈ(¹%(¹%((Õ¹A±ä ¤($%5½ÕÍ
±¥¬ ÅÕ½Ðí±ÐÅÕ½Ðì°ÀÌØíà°ÀÌØíä°Ä¤(%¹Õ¹($(%Õ¹= ¤($$ÀÌØíͽÉôÀ(%¹Õ¹(ͱÀ ÄÀ¤)]¹

There's seems to be a problem with that one and I can't figure it out. Any ideas?

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

Share this post


Link to post
Share on other sites



Don't put your functions inside a While...WEnd loop. Just do something like...

While 1
    Sleep(100)
WEnd

...and put your functions elsewhere.

Share this post


Link to post
Share on other sites

I tried it like this:

#include <Misc.au3>

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

Dim $Position, $i = 0, $Record[1]
$score = 0
While 1
    sleep(10)
WEnd
Func On()
    $score = 1
EndFunc
   
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

Func Play()
    MouseClick("left", $x, $y, 1)
EndFunc

Func Off()
    $score = 0
EndFunc

It comes up with a new error though:

"Line 29

MouseClick("left", $x, $y, 1)

MouseClick("left", ^ERROR

Error: Variable used without being declared."


[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

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