2014 Mid-Autumn Festival, with Java for QQ game beauty finding fault writing aid

Source: Internet
Author: User

Introduction

This year the Mid-Autumn festival busy at home, always find something to do.
I started to learn python a few days ago and had a plan to get this language out early, but it was a pity to have been dragged to the present. Admittedly, I'm also a patient with procrastination. In the process of learning Python, I would like to know what this language is suitable to do, what can be done, and then, from the Internet a huge amount of information learned that Python is not only suitable as a programmer to learn the first language, but also hackers like the language, Python is called the "glue language" of various languages. In this process, inadvertently saw a python predecessor's blog-with Python to write QQ beauty pick-up game plug-in (click Jump to see). For the plug-in, never involved, but also completely do not understand, but that blog gave me ideas, aroused my interest, programming so long, never considered to do plug-ins, do not know whether Java can be achieved. I try to find the answer from the Internet, basically say that Java is not suitable for plug-ins, because of his operating mechanism constraints-run in the sandbox, so that they do not have free access to the underlying API. But I have known Java a robot class, can implement the screen, simulation mouse keyboard operation. For the implementation of the plug-in (or called auxiliary more appropriate) should not be a problem, so the development of beauty with Java to assist the idea of finding a way to emerge. Experience   
Executable Jar:http://pan.baidu.com/s/1i3vgstb source code download: http://pan.baidu.com/s/1pJx63Mj This program and source code is only used for study studies, please do not use for commercial and illegal purposes, The resulting legal disputes, self-responsibility, the author does not bear any responsibility! parsing    Implementation ideas:1. Capture the screen; 2. According to the unique icon of the game window, find the upper-left coordinate of the game window, 3. Calculate the position of the two contrasting pictures according to the coordinates of the window, then cut out two pictures.  4. Compare two pictures to find a different place.    5. Create a transparent background window that will find the two pictures in different places with dots drawn on the transparent background window. The development process mainly involves a few points, has been divided into a description:

1. screen and picture cut. (click here to view)

2. look up the picture on the image algorithm. (click here to view)

3. compare two pictures of the same size to find different places.

Similar to the image above the algorithm to find the image, in fact, is to read two images for the BufferedImage object, take out each pixel of the GRB value to compare, with a two-dimensional array of the same size record comparison results, the same pixel location record is 0, the location of the pixel is not the same as 1. When the picture is finished, you get a two-bit array that marks the similarities and differences between the two images.

4. the magic of the transparent background window.

When the window background is completely transparent, it is found that the transparent place is similar to the hole in the window. This feature can be used very well, for example, can be implemented in any shape of the window.

Here, using this feature, I used to draw two pictures in different places, traverse the comparison of the results of the two-bit array, only focus on the point labeled 1, and ignore the left and right are 1 points, so that the effect of drawing formed the middle of the area, plus I let the transparent window always keep the front, so, Although Java's transparent window is always covered in the game interface, but the mouse can still click on the game interface controls, very magical!

5. set the global (operating system level) hotkey. (click here to view)

6. drag and drop the mouse. (click here to view)

7. memory release.

This thought does not need this step, when I finished the actual test, found that compared to more than 10 pictures, then click the button, did not respond, to the console output a look, the original is memory overflow. Because the member variables of the written class have several large two-dimensional arrays, each comparison is a re-instantiation of the class. Therefore, it is necessary to proactively request a Java virtual machine for garbage collection as soon as possible, that is, call System.GC (), it is necessary to note that even if you call the System.GC (), there is no guarantee that the Java Virtual machine garbage collection immediately. In addition, in order for the Java Virtual machine to effectively find unused objects, it is necessary to assign null values to the unused member variables. For simplicity, although I'm still re-instantiating the class every time I compare, I'm asking for garbage processing to free up memory before I compare it.

SummaryAfter writing, I found that there have been Java predecessors have written this assistance. Write this small program almost spent two days of my time, finally wrote out, also have a lot of harvest and experience. Then, blogging is the first two days of coding summary, at the same time, with the small partners to share and progress together.

2014 Mid-Autumn Festival, with Java for QQ game beauty finding fault writing aid

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.