I have to develop some kind of bot for a testing background with Java. We used Selenium for all the web stuff, and outside the browser: Pixel recognition; that is, taking a screenshot, then compare it with a image I hav开发者_如何学编程e already, and get the coordinates of where that pattern is on the screenshot.
Any Framework or free Java libraries that could make this job easier?
Thanks in advance!
You could probably get the following to work:
- Use java.awt.Robot to take a screen capture as a BufferedImage
- Convert the BufferedImage to a byte array
- Do a standard string matching search to locate the pattern in the byte array. Even a naive string search (i.e. checking for the pattern at every possible location) could well be fast enough.
- Convert the position in the byte array back to image co-ordinates
You could read this simple example.
精彩评论