Sign in to follow this  
Followers 0
XZ3R0

Center Clicking

18 posts in this topic

So i am using Pixlesearch to search for a color and then once the color is found the mouse clicks on it. For the most part this works quite well but the "color" is a moving target and the mouse often misses by the time it clicks.

Is there a way to define a square area that the mouse will click in the middle of, so its not aiming for the edge of the color where its most likely to miss?

Share this post


Link to post
Share on other sites



You can only click one point on the screen, that being the "center of the square". So.... is the target always moving in the same direction

at the same speed when the pixel is found you are searching for? If this is the case you can just add (or subtract) to the X and Y

coordinates from where the pixel is found. If the "color" is moving at the same rate of speed across the screen you could find it (the color)

twice and predict where the "click" should occur.

Maybe you could supply a screen shot and some more information on what is actually happening.....


Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

hmm that's a good idea. but there is only one small little problem.

Ok since i'm new to coding i'm practicing on little flash games. the game is to shoot balloons as they float across the screen. They are always moving at a constant velocity up, so i could use your idea for the y-axis. but they tent to drift back and forth on the x-axis so there's no real way to condensate for that movement since it tents to switch. Because if you add +10 to the x coord sometimes that would work but sometimes that may just make it go ever further off course.

If you want to know the exact game its on http://www.gamevance.com/ and its "Shooting Stars"

But to rephrase my original question, is there a way to find the boarders off the object, in this case the balloon, and then tell the mouse to click in the middle. The pixlesearch seems to find the edge of the balloon first and then tells the mouse to click it, by the time it gets to that point the balloon has moved enough to miss. but if it aimed for the middle of the target, the velocity is not fast enough for the mouse to miss then. So i guess I'm asking, is there a away to tell it to aim for the center of the object?

Also, how would i add to the y-coord to compensate with your idea? I'm using

MouseClick ( "Left", $Coor[0], $Coor[1], 1, 0 )

Do i just put

MouseClick ( "Left", $Coor[0], $Coor[1]+5, 1, 0 )
? Edited by XZ3R0

Share this post


Link to post
Share on other sites

Lets say you have a square 10 by 10 using

MouseClick("Left", $Coor[0] + Random(Min[0], Max[0]), $Coor[1] + Random(Min[1], Max[1]), 1, 0)

This will evade the possible catching you cheating using a script with a negative min value to a max value


Contact via MSN: [email=terarink_msn@hotmail.com]terarink_msn@hotmail.com[/email], yahoo: terarink_yah

Share this post


Link to post
Share on other sites

I would think that this would work

MouseClick ( "Left", $Coor[0], $Coor[1]+5, 1, 0 )oÝ÷ Øç¢ÛkÊØb±«­¢+ØÀÌØíY0ôÀÌØí
½½ÉlÅt¬Ô)5½ÕÍ
±¥¬ ÅÕ½Ðí1ÐÅÕ½Ðì°ÀÌØí
½½ÉlÁt°ÀÌØíY0°Ä°À¤

You may not be having so much a problem with the X coordinate as PixelSearch executes from left to right and

top to bottom and I assume the balloons are going up.

If you do not have a limited amount of clicks or "shots" I would just click a few points across the Y axis in the

relative area of the X axis.


Share this post


Link to post
Share on other sites

You may not be having so much a problem with the X coordinate as PixelSearch executes from left to right and

top to bottom and I assume the balloons are going up.

If you do not have a limited amount of clicks or "shots" I would just click a few points across the Y axis in the

relative area of the X axis.

I don't understand what your trying to say.

Im using the code

$val1 = ($Coor[0] + Random ( min [-5], max [5], 1 ))
$val2 = ($coor[1] + Random ( min [-5], max [5], 1 ) + 20)
MouseClick ( "Left", $val1, $val2, 1, 3 )

And i get an error: Error phrasing function cell. right after the first random.

But without that random code it seems to work pretty well, with some tuning to the mouse click code. But i only have one more thing to do and that's make it target all the colors (it only targets red right now)

TerarinKerowyn mentioned something about arrays in another post. Can anyone explain how to make pixlesearch search for more colors?

Share this post


Link to post
Share on other sites

Can you post the code entirely on here


Contact via MSN: [email=terarink_msn@hotmail.com]terarink_msn@hotmail.com[/email], yahoo: terarink_yah

Share this post


Link to post
Share on other sites

Can you post the code entirely on here

Sleep (3000)
MouseClick( "left", 360, 545, 1, 0)
Sleep(500)
While 1=1
    $i=1
    While $i<60
        $coor = PixelSearch( 75, 245, 655, 500, 0xF50002, 0, 10 )
        While @error = 0
            $val1 = ($Coor[0])
            $val2 = ($coor[1] + 25)
            MouseClick ( "Left", $val1, $val2, 1, 3 )
            Sleep(50)
            $coor = PixelSearch( 75, 245, 655, 500, 0xF50002, 0, 10 )
        WEnd
    $i=$i+.05
    WEnd
WEnd

I know its kind of crappy, there's things i want to change, but i don't really know how. im just going 1 step at a time.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Dim $iColor[MAX_COLORS]

; Modification to each color goes here on a value of $iColor[n]

While 1
    $i=1
    While $i<60
        For $iColor In $iColors
            $coor = PixelSearch( 75, 245, 655, 500, $iColor, 0, 10 )
            While Not @error
                MouseClick ( "left", ($Coor[0] + Random(1, 25)), ($Coor[1] + Random(1, 25)), 1, 3 )
                Sleep(50)
                $coor = PixelSearch( 75, 245, 655, 500, $iColor, 0, 10 )
            WEnd
        Next
    $i=$i+.05
    WEnd
WEnd

Edited by TerarinKerowyn

Contact via MSN: [email=terarink_msn@hotmail.com]terarink_msn@hotmail.com[/email], yahoo: terarink_yah

Share this post


Link to post
Share on other sites

Sorry, the balloon thing has nothing to do with anything. I was thinking of another game muttley


Share this post


Link to post
Share on other sites

Dim $iColor[MAX_COLORS]

; Modification to each color goes here on a value of $iColor[n]

While 1
    $i=1
    While $i<60
        For $iColor In $iColors
            $coor = PixelSearch( 75, 245, 655, 500, $iColor, 0, 10 )
            While Not @error
                MouseClick ( "left", ($Coor[0] + Random(1, 25)), ($Coor[1] + Random(1, 25)), 1, 3 )
                Sleep(50)
                $coor = PixelSearch( 75, 245, 655, 500, $iColor, 0, 10 )
            WEnd
        Next
    $i=$i+.05
    WEnd
WEnd
Wow this script is really cool, but I get unified variable error for $iColors. is that a typo? how do i fix that?

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Ok nvm about the post above here is my official first beta

WinActivate("Shooting Stars - Tournament Game - Mozilla Firefox");browser title
MouseClick( "left", 360, 545, 1, 0);starts game
Sleep(500)
Dim $Color[4];balloon colors
$Color[0]="0xF50002"
$Color[1]="0x6ebb1f"
$Color[2]="0xffd600"
$Color[3]="0x50b0d1"

While 1
    $i=1
    While $i<60
           For $Colors In $Color
           $coor = PixelSearch( 75, 245, 655, 500, $Colors, 0, 10 )
                   While Not @error
                MouseClick ( "left", ($Coor[0]), ($Coor[1]), 1, 3 );seemed to work better without random
                Sleep(50)
                $coor = PixelSearch( 75, 245, 655, 500, $Colors, 0, 10 )
            WEnd
        Next
    $i=$i+.05;need to replace with a timer or something
    WEnd
WEnd

I tried a number of times fine tuning this to get it just right, but in the end it just seemed to work better without the random generators. This officially got me the top score for this game at 562 points with 2 misses left, so it seems believable.

Things to add:

stop/start hot keys

60s timer

higher accuracy (somehow)

can anyone help me out with those? i want it have a hotkey to start and stop it but after its been started for 60s it will turn back to the off position.

Edited by XZ3R0

Share this post


Link to post
Share on other sites

HotKeySet("a", "StartTick")
HotKeySet("z", "EndTick")
Dim $bTickTimer = False

WinActivate("Shooting Stars - Tournament Game - Mozilla Firefox");browser title
MouseClick( "left", 360, 545, 1, 0)
Sleep(500)
Dim $Color[4]
$Color[0]="0xF50002"
$Color[1]="0x6ebb1f"
$Color[2]="0xffd600"
$Color[3]="0x50b0d1"

While 1
    While $iTickTimer = True
       For $Colors In $Color
           $coor = PixelSearch( 75, 245, 655, 500, $Colors, 0, 10 )
            While Not @error
                MouseClick ( "left", ($Coor[0]), ($Coor[1]), 1, 3 );seemed to work better without random
                Sleep(50)
                $coor = PixelSearch( 75, 245, 655, 500, $Colors, 0, 10 )
            WEnd
        Next
    WEnd
    Sleep(1000)
WEnd

Func StartTick()
    $bTickTimer = True
    AdlibDisable()
    AdlibEnable(EndTick(), 60000)
EndFunc

Func EndTick()
    $bTickTimer = False
    AdlibDisable()
EndFunc


Contact via MSN: [email=terarink_msn@hotmail.com]terarink_msn@hotmail.com[/email], yahoo: terarink_yah

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Awesome, thank you so much for all your help. There's just one more small thing. Is there away to have it so that it starts with StartTick() enabled? I tried using Send("A") but i don't think i did it right or it doesn't recognizes hotkeys from itself.

Edited by XZ3R0

Share this post


Link to post
Share on other sites

By sending

Send("a")

Do note the small letters and not CAPS. But to show you a more correct way do this at Dim $bTickTimer = False overwrite it so it says

Dim $bTickTimer = True
AdlibEnable(EndTick(), 60000)

Contact via MSN: [email=terarink_msn@hotmail.com]terarink_msn@hotmail.com[/email], yahoo: terarink_yah

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

By sending

Send("a")

Do note the small letters and not CAPS. But to show you a more correct way do this at Dim $bTickTimer = False overwrite it so it says

Dim $bTickTimer = True
AdlibEnable(EndTick(), 60000)
Ah, i thought it would be something like that. The ONLY last thing i wanted to add is to make a toggle switch from stopped and started. like only have to press "s" once to start and "s" once again to stop, but i couldn't figure that out either. I assume it had to do with the If Then keyword refrence, but i didnt know how to combine it into one function with the timer but thats ok this is still just as good.

Well here it is, the official release of my first bot that won me top score for 22 hours and "won" me a prize (lets see if they send it)

Here's how to use it:

1. Open Shooting Stars game and wait till its at the title page with the button that says "*Start*" and maximize the window.

2. Let it run. It SHOULD hit most of the balloons with quite good accuracy, enough to go the full 60 seconds if not, then try again. I like that it doesn't have 100% accuracy cause it makes it more believable, but this is also the best i could get it, if you know of ways to improve the accuracy please let me know.

3. (optional). If you need to stop the script for any reason, pressing the "a" key starts it again, and pressing "s" stops it. And if the script gets out of control just hit "q" and it will Quit.

Thats all there is to it. Thank you everyone for all the help especially TerarinKerowyn.

Edited by XZ3R0

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

HotKeySet("a", "ToggleTick")
HotKeySet("q", "Quit")

Dim $TickTimer = True
Dim $Color[4]

$Color[0]="0xF50002"
$Color[1]="0x6ebb1f"
$Color[2]="0xffd600"
$Color[3]="0x50b0d1"

AdlibEnable("ToggleTick", 60000)

WinActivate("Shooting Stars");browser title
MouseClick( "left", 360, 550, 1, 0)
Sleep(500)

While 1
    While $TickTimer = "True"
       For $Colors In $Color
           $coor = PixelSearch( 75, 245, 655, 500, $Colors, 0, 10 )
            While Not @error
                MouseClick ( "left", ($Coor[0]), ($Coor[1]), 1, 3 );seemed to work better without random
                Sleep(Random(30,100, 1))
                $coor = PixelSearch( 75, 245, 655, 500, $Colors, 0, 10 )
            WEnd
        Next
    WEnd
    Sleep(1000)
WEnd


Func ToggleTick()
    If $TickTimer Then
        $TickTimer = "False"
        AdlibDisable()
   Else
        $TickTimer = "True"
        AdlibDisable()
        AdlibEnable( "ToggleTick", 60000)
   EndIf
EndFunc

Func Quit()
Exit
EndFunc

That will add it your toggle switch for you

Edited by TerarinKerowyn

Contact via MSN: [email=terarink_msn@hotmail.com]terarink_msn@hotmail.com[/email], yahoo: terarink_yah

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

OH, its else. Dam i was so close. Well now my script is complete (in my eyes at least, besides not having 100% accuracy but that's no necessary)

Thank you so much for all your help. I am not working on a new, more complex, and harder bot for the game GreenBot. Which ill also probably asking for a lot of help on since it doesn't deal with clicking but actual moving a character around.

All other replys, please be foreword to the new topic for the release at http://www.autoitscript.com/forum/index.php?showtopic=75355

Edited by XZ3R0

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