Jump to content
Sign in to follow this  

Pixelsearch technical restrictions and image crop problem

Recommended Posts


When I use PixelSearch many times with sleep delays between each time then it seems eventually to need to rest and this takes a verry long time before it will work again. Is there a way around this for example by making it perform it's rest after every use to get a slower acting but more reliable pixelsearch command?

I also wondered if anyone could help me create code to:

Take screenshots and save it in memmory I presume as a $ that is of type image.

Crop away all but a rectangular part of an image.

Join two images to create a larger image as big as the combined size of the two starting images. Alternitivly create images from scrach and copy and paste between them.

Save an image somewhere such as a file on the disk or the clipboard.

Is the correct solution to such operations using autoIT automating a 3rd party program such as paint, PSP etc... ?

Share this post

Link to post
Share on other sites

Post your current code to get better results.

For your ideal code:

(Is this what you want?)

Img1 400x400

Img2 300x300

Final Result = 700x700 ?

Then when/if you cropped part of an image it'd be smaller ideally.

You can take a screenshot of a window as far as I know of a window as long as you have the handle

Share this post

Link to post
Share on other sites

I want a 700x400 sized image in your example and I wan't the cropping to be done before the combining.

The other program is a Zuma playing bot.

Changing the line "$playSpeed = 300" to "$playSpeed = 20" makes the problem more clear. Quick bursts of activerty followed by waiting for ages. On the slower speed then it seems to be doing it sometimes and shows up by looking as if it can't find a ball even though it is there. It's like Java's garbege collection.

Im also having to declare vars like "$fullWidth" at the top and in "start" even though in order to be used "start" must have been called. Another Java like oddity.

Maybe AutoIT is writtain in Java.

I have a really lifelike pause and almost missing mechanism but I can't get the cursor to move around realistically yet. Would require jittery bezier curves I can't model.

; Zuma bot

; set up thease vars for the Zuma version you are using
$halfPlayAreaWidth = 420
$halfPlayAreaHeight = 260
$playSpeed = 300
$middleSize = 60
$gemColTol = 20
; end of set up vars

; position cursor over the ball the frog is holding and use o and p to start and stop the bot

$on = False
$hit = True
$di = 0

$fullWidth = 10
$fullHeight = 10
$frogPosX = 10
$frogPosY = 10
$frogLeftX = 10
$frogRightX = 10
$frogTopY = 10
$frogLowerY = 10
$playAreaLeftX = 10
$playAreaRightX = 10
$playAreaTopY = 10
$playAreaLowerY = 10

HotKeySet("o", "start")
HotKeySet("p", "stop")

While 1
    If $on = True Then
        if $hit = True then
            MouseMove($frogPosX, $frogPosY, 0)
            $hit = False
            $gemCol = PixelGetColor($frogPosX, $frogPosY)
        If $di = 0 Then
            taClick($playAreaLeftX, $playAreaTopY, $playAreaRightX, $frogTopY); top
            $di = 1
            taClick($playAreaLeftX, $frogLowerY, $playAreaRightX, $playAreaLowerY); lower
            $di = 0

Func taClick(Const $l, Const $t, Const $r, Const $b)
    $coord = PixelSearch($l, $t, $r, $b, $gemCol, $gemColTol)
    If Not @error Then
        MouseClick("left", $coord[0], $coord[1], 1, 0)
        $hit = True

Func start()
    $fullWidth = @DesktopWidth
    $fullHeight = @DesktopHeight
    $frogPosX = MouseGetPos(0)
    $frogPosY = MouseGetPos(1)
    $frogLeftX = $frogPosX - $middleSize
    $frogRightX = $frogPosX + $middleSize
    $frogTopY = $frogPosY - $middleSize
    $frogLowerY = $frogPosY + $middleSize
    $playAreaLeftX = $frogPosX - $halfPlayAreaWidth
    $playAreaRightX = $frogPosX + $halfPlayAreaWidth
    $playAreaTopY = $frogPosY - $halfPlayAreaHeight
    $playAreaLowerY = $frogPosY + $halfPlayAreaHeight
    $hit = True
    $on = True

Func stop()
    $on = False
Edited by alan2here

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