Sign in to follow this  
Followers 0
EndersGame

Pixel Search + random questions

17 posts in this topic

#1 ·  Posted (edited)

Skip to the paragraph(ish) before my code if you don't want a story.

Basically doing this for practice so I can get a hang of things. I've only started programming(as in never before) like 3 weeks ago, etc.

So... noob questions ahead.

Not sure if talking about making scripts for games is against forum policy (some forums are weird like that :/ and I couldn't find a forum rules thread) if it is ill edit.

Here's the game http://www.digyourowngrave.com/pel/

Basically the background of the game is black and I want it to move when something which isn't black passes over. So I do a pixel search for black then if the computer doesn't find black it returns @error = 1 which is my if statement, all this in a while loop so it does it continuously (confirm please).

And that's the gist of my script, the middle one has an extra pixel search to see on which side my paddle is.

So my problems are

1. It doesn't work (of course :P ), all it does is send left left and right right really fast and I don't understand why since the background IS black. (the screen is in the same position as when i froze the window thing for the coordinates)

2. Also how do I know how much shade difference I want to put if i want it to search between grey and white.

3. How do I set it up if i want the script to only start when I press a hotkey I tried to make a hotkeyset with the whole script as hotkeyed but it would just start and exit the script instantly.

HotkeySet("p", "pause")
AutoItSetOption("TrayIconDebug", 1)


While (True)

;left side
PixelSearch(240,760,255,750,0x000000)
if (@error=1)Then   
Send("{left}{left}")
EndIf

;middle
PixelSearch(435, 735, 455, 725, 0x000000)
if (@error=1) Then
    PixelSearch(257,790,257,790, 0x888888)
    if(@error=0) Then
        Send("{right}")
    Else
        Send("{left}")
    EndIf
EndIf

;right side
PixelSearch(635,770,650,760, 0x000000)
if (@error = 1) Then
    Send("{right}{right}")
    EndIf
Wend


Func pause()
    Send("{esc}")
EndFunc
Edited by EndersGame

Share this post


Link to post
Share on other sites



3. How do I set it up if i want the script to only start when I press a hotkey I tried to make a hotkeyset with the whole script as hotkeyed but it would just start and stop the scrip instantly.

HotkeySet("p", "pause")
HotKeySet("g", "Go")
AutoItSetOption("TrayIconDebug", 1)

While 1
Sleep(100)
WEnd

Func Go()
While (True)

;left side
PixelSearch(240,760,255,750,0x000000)
if (@error=1)Then   
Send("{left}{left}")
EndIf

;middle
PixelSearch(435, 735, 455, 725, 0x000000)
if (@error=1) Then
    PixelSearch(257,790,257,790, 0x888888)
    if(@error=0) Then
        Send("{right}")
    Else
        Send("{left}")
    EndIf
EndIf

;right side
PixelSearch(635,770,650,760, 0x000000)
if (@error = 1) Then
    Send("{right}{right}")
    EndIf
Wend
EndFunc


Func pause()
    Send("{esc}")
EndFunc

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Share this post


Link to post
Share on other sites

...

Not sure if talking about making scripts for games is against forum policy ...

It is not against any forum policy per se. Some members will help you with games other members consider scripting a game cheating. As for the game that you linked to. As a general rule - if the "AutoIt Window Info" tool cannot "see" the colored objects - then your script won't either.

Open that tool, select the tab named mouse, then click on the windows of interest. Move the mouse to the place where the colored objects will be - nothing changes :-(

I don't know why some flash objects can be "seen" and others can't... but then I don't know a lot of things :-)


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi guys,

this is going to be my first script. So it is a try to make a very small bot which will help me get the jumping rope contest on Facebook's Pet Society contest.

Sooo the idea is the following:

There is my "animal" ;$me that is jumping on that rope. So when the rope from black turns red (0x990000) the bot is suppoed to click the left mouse button somewhere on my animal's colour (0x6c5EA7). Here is my script based on the previous script and of course I am doing it tottaly wrong so it is not working.

PLS also note that I have narrowed it down to specific coordinates, so the PixelSearch would work faster. PLS give some advice. Thanks in advance. Following is the code:

HotkeySet("q", "quit")
HotKeySet("g", "Go")
AutoItSetOption("TrayIconDebug", 1)

While 1
Sleep(100)
WEnd

Func Go()
ToolTip("BOT Active", 0, 0)
Sleep(2000); Sleep to give tooltip time to display

While (True)

PixelSearch(280 360 440 550,0x990000);red rope
if (@error=1)Then
    Sleep(10)
    Else
$me = PixelSearch(280 360 440 550,0x6c5EA7);me 
    MouseClick("left", $me)
EndIf
    Wend
EndFunc

Func quit ()
ToolTip("Quitting BOT", 0, 0)
Sleep(2000); Sleep to give tooltip time to display
EndFunc

$me = PixelSearch(280 360 440 550,0x6c5EA7) ;me

MouseClick("left", $me)

This part sucks... PLS advice ;-)

Edited by Diko

Share this post


Link to post
Share on other sites

I would really appreciate some help here :)

Thanks in advance.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Just wanted to thanks for the tip. This additionally to the small change where

MouseClick("primary", $me[0],$me[1],1,0)

is now.

That way I managed to solve it and... I did it ;-)

HotkeySet("{F10}", "quit")
HotKeySet("{F9}", "Go")
AutoItSetOption("TrayIconDebug", 1)


While 1
Sleep(100)
WEnd


Func Go()
ToolTip("BOT Active", 0, 0)
Sleep(2000); Sleep to give tooltip time to display

While (True)

PixelSearch(700,370,1100,520,0x990000);red rope
if (@error=1)Then
    Sleep(10)
    Else
$me = PixelSearch(700,370,1100,520,0xC12727);me 
    MouseClick("primary", $me[0],$me[1],1,0)

EndIf
    Wend
EndFunc

Func quit ()
ToolTip("Quitting BOT", 0, 0)
Sleep(2000); Sleep to give tooltip time to display
EndFunc

Now I am trying something else:

I have a rectangular (absolute position) where I am waiting for an object with specific color (absolute number) to appear so I can click on it.

This is much easier but I get stuck on the folloing part:

HotkeySet("{F10}", "quit")
HotKeySet("{F9}", "Go")
AutoItSetOption("TrayIconDebug", 1)


While 1
Sleep(100)
WEnd


Func Go()
ToolTip("BOT Active", 0, 0)
Sleep(2000); Sleep to give tooltip time to display

While (True)

$subject = PixelSearch(800,240,900,520,0x990000);subject
 if (@error=1)Then
    Sleep(10)
    Else
 $subject = PixelSearch(800,240,900,520,0x990000);subject
    MouseClick("primary", $subject[0],$subject[1],1,0)


EndIf
    Wend
EndFunc

Func quit ()
ToolTip("Quitting BOT", 0, 0)
Sleep(2000); Sleep to give tooltip time to display
EndFunc

It says that I am in mistake on the second Sleep(10)

PLS Help :-) I assume that I did it much more complicated than it actuallu is :-)

Edited by Diko

Share this post


Link to post
Share on other sites
HotkeySet("p", "pause")
AutoItSetOption("TrayIconDebug", 1)

While (True)

;left side
PixelSearch(240,760,255,750,0x000000)
if (@error=1)Then    
Send("{left}{left}")
EndIf

;middle
PixelSearch(435, 735, 455, 725, 0x000000)
if (@error=1) Then
    PixelSearch(257,790,257,790, 0x888888)
    if(@error=0) Then
        Send("{right}")
    Else
        Send("{left}")
    EndIf
EndIf

;right side
PixelSearch(635,770,650,760, 0x000000)
if (@error = 1) Then
    Send("{right}{right}")
    EndIf
Wend

Func pause()
    Send("{esc}")
EndFuncoÝ÷ Ûú®¢×+,µ«^éíjëh×6PixelSearch( 257 , 790 , 257 , 790 , 0x888888 )oÝ÷ Ø'ßÛm«më欱æ«r§Þ¦,^ì¢Ø^ÈZ¢¶ÚºÚ"µÍ^[Ù]ÛÛÜMÈ
ÎL

Share this post


Link to post
Share on other sites

PixelSearch differs in purpose from PixelGetColor, because in the first one you know the color and search for absolute location in some area. Check out here and do something where this color is. The Second one is to get a color value from exact location.

Still can anyone help for my other problem. :-) :)

Share this post


Link to post
Share on other sites

PixelSearch differs in purpose from PixelGetColor, because in the first one you know the color and search for absolute location in some area. Check out here and do something where this color is. The Second one is to get a color value from exact location.

Still can anyone help for my other problem. :-) :)

$color = PixelGetColor( 257, 790 )

If Hex( $color ) = 0x888888 Then
     Send("{right}")
Else
     Send("{left}")
EndIf

Share this post


Link to post
Share on other sites

Thank you for your reply :-)

Well the problem is that this colour can appear not in one point (1 dimension) but in 2D x1y1x2y2. As I said it is rectangular and the colour (the object) may come anywhere within that figure, so I need that the scripts whenever it pick it up to appear on that are to left click on that sampe place +2 pixels.

257 , 790 , 257 , 790

Share this post


Link to post
Share on other sites

@Diko

Can you explain your problrm with more examples ?

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

@Diko

Can you explain your problrm with more examples ?

Cheers, FireFox.

Thank you guys but I also manage with the second assifgnment as well. Now I am trying something much more complex. :-) I erally enjoy the AUTOIT. With one can build very nice cheaters for any flash game. Just FYI: On a very popular game I had to pass the ball with the computer for many times. So I wanted an auto script whenever "sees" the ball on predifined area to click on it so it will be returned. Another way to understand this is to imagine ping pong with the computer ;-)

Really this program is great :-)

@Aceguy - interesting technique there :-) I might use it on my current cheating script :-).

Additionally I think that at part of the comments here should stay because they are very informative now ;-)

Edited by Diko

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Thank you for your reply :-)

Well the problem is that this colour can appear not in one point (1 dimension) but in 2D x1y1x2y2. As I said it is rectangular and the colour (the object) may come anywhere within that figure, so I need that the scripts whenever it pick it up to appear on that are to left click on that sampe place +2 pixels.

257 , 790 , 257 , 790

This is a representation of the PixelSearch square... ( the dots are only there for formatting , ignore them )

(257,790)

...........---------------

...........|..................|

...........|..................|

...........|..................|

...........|..................|

...........|..................|

...........|..................|

...........---------------

...............................(257,790)

This doesn't make sense.

Edited by jaberwocky6669

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Hi guys,

here is what I almost did but got messed up with the cycles this time.

1/ This is a runner who [00] actually is stayong on the same pixel spot. [00]

2/ He is jumping over different hindrances (read colors)

3/ We have pixel location X where I have my PixelSearch function SCANNING, and which unfortunatly can return only coordinates or FALSE (@error=1)

4/ Ther emust taken different type of action to correspond to each different hindrances/color (seen in X area)

|oo|...........--------

|oo|...........|\..../|

|oo|...........|.\../.|

|oo|...........|..\/..|

|oo|...........|../\..|

|oo|...........|./..\.|

|oo|...........|/....\|

|oo|...........--------

================\\

=================\\

==================\\

===================\\

=====================>

===================//

==================//

=================//

================//

a) When color "1" is detected where X click on 00

B ) When color "2" is detected where X click on X

c) When color "3" is detected where X click on 00 when X on it.

(Perhaps a simple sleep will do the job here)

While (True)

PixelSearch(1030, 485, 1033, 488,0x674731) ;Runner have finished? 
;===================================== This is needed so the game would go in cycle without me restarting it every time.
    If (@error=1) Then              
        PixelSearch(750,575,755,595,0xFFFDE6) ;Jump on bar! !!!Case A)!!!
            If (@error=1) Then
                Sleep(10)

;=================
;================= IMPLEMENTATION of the other 2 cases -> b ) and c)
;=================
            Else
                MouseClick("",680,555,1,1) 
            EndIf
    Else
;===================================== This is needed so the game would go in cycle without me restarting it every time.
        MouseClick("",980, 510,3,2) ;Confirming OK
        Sleep(1000)
    EndIf

QUESTION: How can I IMPLEMENT the other two cases? Should I use SWITCH or is there any other way.

PLS advice. Thanks in advance.

Edited by Diko

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