Jump to content

Dose AU3_PixelSearch has bug in AutoItX

Recommended Posts

package cn.com.jautoitx;

import java.io.File;

import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.WinDef.POINT;
import com.sun.jna.platform.win32.WinDef.RECT;

 * @author zhengbo.wang
public class AutoItX {
    public static void main(String[] args) {
        File libFile = new File("lib/AutoItX3.dll");
        AutoItXLibrary autoItX = (AutoItXLibrary) Native.loadLibrary(libFile.getName(), AutoItXLibrary.class);

        RECT rect = new RECT();
        rect.left = 0;
        rect.top = 0;
        rect.right = 100;
        rect.bottom = 100;

        POINT point = new POINT();

        autoItX.AU3_PixelSearch(rect, 0xFFFFFF, 0, 1, point);
        System.out.println("point.x = " + point.x + ", point.y = " + point.y);

    protected static interface AutoItXLibrary extends Library {
         * Searches a rectangle of pixels for the pixel color provided.
         * @param rect
         *            position and size of rectangle.
         * @param color
         *            Colour value of pixel to find (in decimal or hex).
         * @param shadeVariation
         *            A number between 0 and 255 to indicate the allowed number
         *            of shades of variation of the red, green, and blue
         *            components of the colour. Default is 0 (exact match).
         * @param step
         *            Instead of searching each pixel use a value larger than 1
         *            to skip pixels (for speed). E.g. A value of 2 will only
         *            check every other pixel. Default is 1.
         * @param point
         *            Return the pixel's coordinates if success, sets
         *            oAutoIt.error to 1 if color is not found.
        public void AU3_PixelSearch(RECT rect, int color, Integer shadeVariation, Integer step, POINT point);

I write a simple java program。You can download AutoItXDemo.zip and import it into eclipse and run it.

The AutoItX contained in AutoItXDemo.zip is, and the output of the code is something like:

point.x = 0, point.y = 45

but when i use AutoItX, invalid memory access error happened.


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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...