- 按键精灵脚本代码
Dim screenX,screenY
screenX = GetScreenX()
screenY = GetScreenY()
Dim touchX,touchY,mark1X,mark1Y,mark2X,mark2Y,touchX_start,touchX_end,steep,t
touchX_start = 8
touchX_end = screenX
steep = 2
touchY = screenY / 3
FindPic 0, 0, screenX, screenY, "Attachment:landmark1.png", "000000", 2, 0.9, mark1X, mark1Y
FindPic 0, 0, screenX, screenY, "Attachment:landmark2.png", "000000", 2, 0.9, mark2X, mark2Y
If mark1X > -1 and mark2X > -1 Then
touchX = touchX_start
While touchX <> touchX_end
TouchDown touchX, touchY, 1
TracePrint touchX,touchY,mark1X,mark2X
t = Time()
SnapShot t & ".ths.png", 0, mark1Y, mark1X, mark2Y + 40
TouchUp 1
touchX = touchX + steep
Wend
End If
- 截取数据png后,使用tess4j来识别图片中的数据即可。注意,需要先安装(Mac os X)
$ brew install tesseract
然后即可使用java代码来编程识别
import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;
import java.io.File;
import java.util.LinkedList;
public class Main {
public static void main(String[] args) {
LinkedList<File> list = new LinkedList<File>();
File file = new File("pictures");
File[] files = file.listFiles();
for (File imageFile : files) {
ITesseract instance = new Tesseract(); // JNA Interface Mapping
// ITesseract instance = new Tesseract1(); // JNA Direct Mapping
String result = "";
try {
result = instance.doOCR(imageFile);
String _time = result.split("\n")[2]
.replace("/02/021","/02/02 1")
.replace("/01/311","/01/31 1")
.replace("/01/291","/01/29 1")
.replace("/01/301","/01/30 1")
.replace("/02/011","/02/01 1")
.replace("O","0")
.replace("I",":");
StringBuilder time = new StringBuilder(_time)
.replace(13,14,":");
String price = result.split("\n")[0].replace(" ","");
System.out.println(time + "\t" + price);
// System.out.println(result);
} catch (Exception e) {
System.err.println( imageFile.getName() + e);
}
}
}
}
网友评论