ãŸããã
ããããäœæããŠãããžãã¯ãšåå¿é床ãå¿ èŠãšããããã€ãã®ã¿ã¹ã¯ãå®è¡ããå¿ èŠããããŸããã APIã«ä¹ã蟌ãã§ããã°ã©ã ãã€ããªãéžæããããããŸããã§ããã èŠèŠçãªèªååãæ¡çšããããšã決å®ãããŸããã ããã€ãã®ããããèŠã€ããŸããããã©ããç§ã®èŠä»¶ã«éããŠããŸããã§ãããé ãããããã¹ã¯ãªããéšåãå€§å¹ ã«åæžãããŠããããããžã¥ã¢ã«ã³ã³ããŒãã³ããæäœããããã®æ©èœãäžååã§ããã éå»ã«ããžã¥ã¢ã«ãããã䜿çšããŠæåããçµéšãããã®ã§ïŒã¹ã¯ãªããéšåã¯é ããå€§å¹ ã«èª¿æŽãããŠããŸããïŒãå®è£ ããããšã«ããŸããã
æåã«å¿ èŠãªæ©èœ
次ã®æ©èœãå¿ èŠã§ããïŒ
- ããŠã¹ã®ã·ãã¥ã¬ãŒã·ã§ã³ãã«ãŒãœã«ã®åãããã¿ã³ãæŒãã
- ããŒããŒãã®ããŒã¹ãããŒã¯ã®ã·ãã¥ã¬ãŒã·ã§ã³ã
- ç»é¢äžã§äºåã«çšæãããç»åã®äžéšïŒã¢ã€ã³ã³ãæåãªã©ïŒãæ€çŽ¢ããèŠã€ãã£ãå Žåã¯ããã®æ å ±ã䜿ã£ãŠäœã§ãã§ããããã«ããŸãã
- ã¹ã¯ãªããã€ã³ã¿ããªã¿ãããã«ãããã¢ã¯ã·ã§ã³ã®ã¢ã«ãŽãªãºã ãç°¡åã«èšè¿°ã§ããäœåºŠãã³ã³ãã€ã«ããå¿ èŠããªããªããŸãã
æ¢åã®ã¢ããã°
ã¢ããã°ã¯ãããããããŸãããããããã«é·æãšçæããããŸãã æãæ©èœçãªãã®ãæ€èšããŠãã ããã
Sikuli-䟿å©ãªæ©èœã®å·šå€§ãªã»ããã䟿å©ãªPythonã¹ã¯ãªããèšèªãšæ§æãã¯ãã¹ãã©ãããã©ãŒã ãããã€ãã®èŠåã
ããããæåã®ã¿ã¹ã¯ã«ã¯æ£ç¢ºãªåå¿é床ãå¿ èŠã§ãããããã»ã©ã¯ãã®ããã«ã»ãšãã©ã®éšåãæäŸããããšã¯ã§ããŸããã§ããã
2çªç®ã®åé¡ã¯ãJava 1.6ã«ãã€ã³ãããããšã§ããããã«ãããã¿ã³ããªã³ãšãã³ã¹ããããšãªããããšãã°1.7ãŸãã¯1.8ã«å€æããããšãã§ããªããªããŸãã
Jythonã®å€ãããŒãžã§ã³ãããŸãæºè¶³ããŠããŸãããã2.5.2ã¯ããã»ã©æ代é ãã§ã¯ãããŸããã
ããã§ãªããã°ãSikuliã¯çŽ æŽãããããŒã«ã§ããç§ã¯çã«ã¢ããã€ã¹ããŸãïŒ
AutoIt-ã¹ã¯ãªããã«Basicã䜿çšããŸãã
ãã©ãŒã©ã ã®Kulibinsã¯ãç»é¢äžã®ç»åãæ€çŽ¢ããããšãå¯èœã«ããŸããããæ®å¿µãªããããã®æ©èœã¯äžå¿ èŠãªç°¡çŽ åãšå€ãã®å¶éã®ããã«ç§ã®èŠä»¶ãæºãããŠããŸããã§ããã
Windowsã§ã®ã¿åäœããã€ã³ã¹ããŒã«ãå¿ èŠã§ãã
ä»ã®ãã·ã³ã§äœ¿çšããã«ã¯ã³ã³ãã€ã«ãå¿ èŠã§ã; AutoItãã€ã³ã¹ããŒã«ãããŠããªãå Žåãã¹ã¯ãªããããã°ããä¿®æ£ããæ¹æ³ã¯ãããŸããã
AutoHotKey-ã¹ã¯ãªãããèšè¿°ããããã«ç¬èªã®æ§æã䜿çšããŸãããããã¯ãŸã é·ãéç 究ããå¿ èŠããããŸããããæãããããšåŒã¶æ¹ãæ£ããã§ãããã é©åãªç¿æ £ãªãã«çã«åå²ããããžãã¯ã§äœããè¡ãããšã¯å°é£ã§ãã ç»é¢äžã®ç»åã®æ€çŽ¢ãåãæšãŠãããããŠãããç§ã®ããŒãºã«åã£ãŠããŸããã§ããã
Linux / Unixã·ã¹ãã çšã®ããŒããããã€ããããã€ã³ã¹ããŒã«ãå¿ èŠã§ã
Clickermann-ç¬èªã®èšèªã䜿çšããŠã¹ã¯ãªãããèšè¿°ããŸãããããã¯ãŸã 調æ»ããå¿ èŠããããŸãã ç°¡çŽ åã«ãããããšãã°ãåãhttpãªã¯ãšã¹ããªã©ã®æ©èœãã«ãããããŸããã
ãã¯ã»ã«ã®åºæ¬çãªæ€çŽ¢ã¯ãããŸãããç»é¢äžã®ç»åã®æ€çŽ¢ã¯ãããŸããã
UOPilot-ç§ã«åããªãã£ãããã»ã¹ã«ä»éããŠãã¯ãªãã«ãŒãã³ã®ãããªç æ°ããããŸãã ã¯ãã¹ãã©ãããã©ãŒã ã¯ãªãã倧ããªã¹ã¯ãªããã¯æžãã®ã«äŸ¿å©ã§ã¯ãããŸããã
ãŸããå€ãã®ãã¯ããããããã®ã»ãšãã©ã¯ãç¹°ãè¿ãå®è¡ãã®ååã«åºã¥ããŠåäœãããŠãŒã¶ãŒã¢ã¯ã·ã§ã³ãèšæ¶ããã³ç¹°ãè¿ããŸãã
ãããŠãæ®ãã®ãã®ã«ã¯ãç»é¢äžã®ã¢ã€ã³ã³ã®æ€çŽ¢æ©èœããããŸããã§ããã
Habréã®ã¢ããã°
ç§ã¯èšäºãèªã¿ãŸãã ãèè ã¯ã¬ãŒã¶ãŒèŠåç¯æ£ã®å²åŒãåŸãããã«ããããäœããŸããã ãã®èšäºã§ã¯ãæžã蟌ã¿äžã«çºçããå€ãã®åé¡ã«ã€ããŠèª¬æããŸãã ãããã®åé¡ã®ã»ãšãã©ã¯ç解ããããåçŽåã®ããã«çºçããæŸèæã¯æ°ããæŸèæã§è§£æ±ºãããŸããããã®èšäºãèªãããšããå§ãããŸãã
èªåã®èªè»¢è»ã®ãã¯ãããžãŒãéžæãã
æåããJava SEã䜿çšããŠã«ãŒãã«èªäœãäœæããããšã決å®ãããŸãããããã¯ãç§ãJavaãæãé »ç¹ã«äœ¿çšãããããæéã®ç¯çŽã«ãªããŸãã ããã«ãç§ã¯Robotã¯ã©ã¹ã«ç²ŸéããŠãããããããŠã¹ãšããŒããŒãã®ã³ã³ãããŒã«ãç°¡åã«ã·ãã¥ã¬ãŒãã§ããŸãã
ã¹ã¯ãªããã€ã³ã¿ãŒããªã¿ãŒãè¿œå ããå ŽåãPythonã¯éåžžã«ã·ã³ãã«ã§äººæ°ã®ãããã®ãšããŠéžæãããŸããã Javaã®å ŽåãJVMäžã§å®è¡ãããã€ã³ã¹ããŒã«ãå¿ èŠãšããªãJythonå®è£ ããããŸãã ããã«ãã¹ã¯ãªããããçŽæ¥Javaã¯ã©ã¹ããã³ãªããžã§ã¯ããæäœã§ããããã«ãªãããããã®ã³ã¢ã«ãããã®ãå¶éããããšãªããã¹ã¯ãªããã®å¯èœæ§ãå€§å¹ ã«æ¡å€§ããŸãã
ãã®åŸã圌ã¯OpenCLã䜿çšããŠGPGPUãä»ããŠç»é¢äžã®åçã®æ€çŽ¢ãè¿œå ããŸãããJavaã«ã¯JOCLã®å®è£ ããããŸããããããã«ã€ããŠã¯åŸã§è©³ãã説æããŸãã
Swingã®ã°ã©ãã£ã«ã«ã€ã³ã¿ãŒãã§ã€ã¹ãã·ã³ãã«ã§ãããšåæã«ãJREã§ããã«äœ¿çšã§ããæ©èœã³ã³ããŒãã³ãã§ãã
æåã®ã¹ããã
Javaã«ã¯ãããŒããŒãã®ããŒã¹ãããŒã¯ãããŠã¹ã®åããããã³ã¯ãªãã¯ãã·ãã¥ã¬ãŒãã§ããRobotã¯ã©ã¹ããããç¹å¥ãªåé¡ã¯ãããŸããã§ããã ããã§ãmouseMove + mousePress + mouseReleaseã䜿çšããŠmouseClickïŒxãyïŒã®ãããªã¡ãœããã§ããã€ãã®æ©èœãæ¡åŒµãããããã®ã¢ã¯ã·ã§ã³ã®éã«Thread.sleepïŒmsïŒãè¿œå ãããã®åŸããªãŒããŒããŒãã«ããç°ãªãåŒæ°ãæã€ããã€ãã®ã¡ãœãããè¿œå ããŸããã åäžã®ã¡ãœãããšåããã©ãã°ã¢ã³ãããããã
public void mouseClick(int x, int y) throws AWTException { mouseClick(x, y, InputEvent.BUTTON1_MASK, mouseDelay); } public void mouseClick(int x, int y, int button_mask) throws AWTException { mouseClick(x, y, button_mask, mouseDelay); } public void mouseClick(int x, int y, int button_mask, int sleepTime) throws AWTException { bot.mouseMove(x, y); bot.mousePress(button_mask); sleep(sleepTime); bot.mouseRelease(button_mask); } public void mouseClick(MatrixPosition mp) throws AWTException { mouseClick(mp.x, mp.y); } public void mouseClick(MatrixPosition mp, int button_mask) throws AWTException { mouseClick(mp.x, mp.y, button_mask); } public void mouseClick(MatrixPosition mp, int button_mask, int sleepTime) throws AWTException { mouseClick(mp.x, mp.y, button_mask, sleepTime); } public MatrixPosition mousePos() { return new MatrixPosition(MouseInfo.getPointerInfo().getLocation()); }
keyClickïŒïŒã¡ãœãããåãæ¹æ³ã§è¿œå ãããŸããã
public void keyPress(int key_mask) { bot.keyPress(key_mask); } public void keyPress(int... keys) { for (int key : keys) bot.keyPress(key); } public void keyRelease(int key_mask) { bot.keyRelease(key_mask); } public void keyRelease(int... keys) { for (int key : keys) bot.keyRelease(key); } public void keyClick(int key_mask) { bot.keyPress(key_mask); sleep(keyboardDelay); bot.keyRelease(key_mask); } public void keyClick(int... keys) { keyPress(keys); sleep(keyboardDelay); keyRelease(keys); }
ãããã¯ãã¹ãŠãã¹ã¯ãªããã§ã®ã¢ã¯ã·ã§ã³ã®èšè¿°ã容æã«ããããã«å¿ èŠã§ããã ã¹ã¯ãªããã£ã³ã°ã®ã¬ãã«ãããæœè±¡çãªãããªãã¯ãããå¿ èŠãšããããªããããããããã«äžããŸãã
èªãã§âŠäŒã¿ãŸãããïŒ ãããŠãããã«é²ãã§ãããŸãããïŒ
ã³ã¢ã®ç®
次ã®ã¹ãããã¯æãé£ãããæãæéãããããŸãããç»é¢ã®ã¹ã¯ãªãŒã³ã·ã§ãããæ®ããäºåã«æºåãããã¢ã€ã³ã³ãèŠã€ããæ©èœãè¿œå ããŸãã
ãŸããç»é¢ã®ã¹ã¯ãªãŒã³ã·ã§ãããæ®ãæ¹æ³ãšä¿åããæ¹æ³ã¯ïŒ
第äºã«ããã¿ãŒã³ïŒã¢ã€ã³ã³ïŒãæ€çŽ¢ããæ¹æ³ã¯ïŒ
第äžã«ããã®ãã¿ãŒã³ïŒã¢ã€ã³ã³ïŒã¯ã©ãã§å ¥æã§ããŸããïŒ
ã¹ã¯ãªãŒã³ã·ã§ãããæ®ãã®ãããã»ã©é£ãããªãå Žå
public void grab() throws Exception { image = robot.createScreenCapture(screenRect); }
æ€çŽ¢ã§ç¹å®ã®åé¡ãçºçããããšãæ€çŽ¢ã®ãã¿ãŒã³ãã©ãã§ååŸã§ãããïŒ äœæããŸãããã©ã®ããã«ïŒ
æåã®ãã¿ãŒã³ãäœæããããã«ãPrintScreenã䜿çšããŠå€ãè¯ããã€ã³ãã䜿çšããã¹ã¯ãªãŒã³ã·ã§ããããšãã£ã¿ãŒã«ã¢ããããŒãããã¹ã¯ãªãŒã³ã·ã§ããããå°ããªæçãåãåããå¥ã®.bmpãã¡ã€ã«åœ¢åŒã§ä¿åããŸããã
ããŠããã¿ãŒã³èªäœã¯ããã«ãããBufferedImageã®ã³ãŒãããããŒãããŸããã BufferedImageã«ãã¹ã¯ãªãŒã³ã·ã§ãããäœæãããŸããæ€çŽ¢ã¢ã«ãŽãªãºã ãäœæããå¿ èŠããããŸãã ãããã¯ãŒã¯äžã§ããã«ãŒããã©ãŒã¹ãå®è¡ãããªãã·ã§ã³ã«åºäŒããŸãã-å°ããªç»åã®æåã®ãã¯ã»ã«ã倧ããªç»åã®æåã®ãã¯ã»ã«ãååŸããããããæ¯èŒããŸãããã¯ã»ã«ãåãã«ã©ãŒã³ãŒããæã£ãŠããå Žåããã®ç¹ã«é¢é£ããæ®ãã®ãã¯ã»ã«ããã§ãã¯ããŸãã ãã¹ãŠã®ãã¯ã»ã«ãäžèŽããå Žåãããã¯ç®çã®ç»åãèŠã€ãã£ãããšãæå³ããŸãã äžèŽããªãå Žåã¯ã倧ããªç»åãã次ã®ãã¯ã»ã«ãååŸããã¢ã¯ã·ã§ã³ãç¹°ãè¿ããŸãã
ããã¯ããŸãè¯ãèãããŸããããããŸããããŸãã
for (int y = 0; y < screenshot.getHeight() - fragment.getHeight(); y++) { __columnscan: for (int x = 0; x < screenshot.getWidth() - fragment.getWidth(); x++) { if (screenshot.getRGB(x, y) != fragment.getRGB(0, 0)) continue; for (int yy = 0; yy < fragment.getHeight(); yy++) { for (int xx = 0; xx < fragment.getWidth(); xx++) { if (screenshot.getRGB(x + xx, y + yy) != fragment.getRGB(xx, yy)) continue __columnscan; } } System.out.println(âfound!â); } }
å§ããŠ...ããŸããããŸãïŒ äžèŽãããã®ã1ã€èŠã€ãããŸããïŒ ããããããªããã£ããã§ãããç§ãã¡ã«ã¯ãŸã£ããåãå ¥ããããŸããã getRGBïŒïŒã¡ãœãããæ¯ååŒã³åºãããããã»ããµãŒã®ãã£ãã·ã¥ãéåžžã«éå¹ççã«äœ¿çšãããç§ãã¡ã«ãšã£ãŠããã¯çŽç²ãªãããªãã¯ã¹æ€çŽ¢ãšèšããŸãã ãã¯ã»ã«ãããªãã¯ã¹ïŒ ãã®ãããã¹ã¯ãªãŒã³ã·ã§ãããæ ŒçŽããBufferedImageãªããžã§ã¯ããint [] []ãããªãã¯ã¹ã«å€æããããšã«ããŸããããã®ãããç®çã®ãã©ã°ã¡ã³ããint [] []ãããªãã¯ã¹ã«å€æãããããªãã¯ã¹ãåŠçãããµã€ã¯ã«ãä¿®æ£ããŸãã éå§ããŠ...èŠã€ãããŸããã
æ€çŽ¢ãšã³ãžã³ã§åçãç©æ¥µçã«æ€çŽ¢ããçµæããã¹ãŠã®çç±ãBufferedImageããŒã¿ãæ ŒçŽãããARGB / RGBA / RGB圢åŒã§ããããšãæããã«ãªããŸããã ã¹ã¯ãªãŒã³ã·ã§ããã«ã¯ãBGRãã©ã°ã¡ã³ããå«ãARGBãã¡ã€ã«ããããŸããã
ãã¹ãŠã1ã€ã®åœ¢åŒãã€ãŸãARGBã¹ã¯ãªãŒã³ã·ã§ãã圢åŒã«çž®å°ããªããã°ãªããŸããã§ããããã©ã°ã¡ã³ããã¹ã¯ãªãŒã³ã·ã§ãã圢åŒã«ããã®ã¯ãæ¯åã¹ã¯ãªãŒã³ã·ã§ãã圢åŒã«ãããããé«éã§ãã å°ãããã®ã¯å€§ããªãã©ãŒãããã«ã€ãªãããŸãããããã«ã¯ããªãã®æéãããããŸããããæçµçã«ã¯åäœãããã¿ãŒã³ã¯ã¹ã¯ãªãŒã³ã·ã§ããäžã§ã¯ããã«éããã»ãŒ2åéãé 眮ããå§ããŸããïŒ
// USED FOR BMP/PNG BUFFERED_IMAGE private int[][] loadFromFile(BufferedImage image) { final byte[] pixels = ((DataBufferByte) image.getData().getDataBuffer()) .getData(); final int width = image.getWidth(); if (rgbData == null) rgbData = new int[image.getHeight()][width]; for (int pixel = 0, row = 0; pixel < pixels.length; row++) for (int col = 0; col < width; col++, pixel += 3) rgbData[row][col] = -16777216 + ((int) pixels[pixel] & 0xFF) + (((int) pixels[pixel + 1] & 0xFF) << 8) + (((int) pixels[pixel + 2] & 0xFF) << 16); // 255 // alpha, r // gb; return rgbData; }
ããã«ãæ¡ä»¶ã®ãããªãã¯ã¹è¡ã®ãã£ãã·ã¥ãªã©ã®å°ããªæé©åã«ãããæ€çŽ¢çµæã®é床ãåäžããŸããã
public MatrixPosition findIn(Frag b, int x_start, int y_start, int x_stop, int y_stop) { // precalculate all frequently used data final int[][] small = this.rgbData; final int[][] big = b.rgbData; final int small_height = small.length; final int small_width = small[0].length; final int small_height_minus_1 = small_height - 1; final int small_width_minus_1 = small_width - 1; final int first_pixel = small[0][0]; final int last_pixel = small[small_height_minus_1][small_width_minus_1]; int[] row_cache_big = null; int[] row_cache_big2 = null; int[] row_cache_small = null; for (int y = y_start; y < y_stop; y++) { row_cache_big = big[y]; __columnscan: for (int x = x_start; x < x_stop; x++) { if (row_cache_big[x] != first_pixel || big[y + small_height_minus_1][x + small_width_minus_1] != last_pixel) // if (row_cache_big[x] != first_pixel) continue __columnscan; // No first match // There is a match for the first element in small // Check if all the elements in small matches those in big for (int yy = 0; yy < small_height; yy++) { row_cache_big2 = big[y + yy]; row_cache_small = small[yy]; for (int xx = 0; xx < small_width; xx++) { // If there is at least one difference, there is no // match if (row_cache_big2[x + xx] != row_cache_small[xx]) { continue __columnscan; } } } // If arrived here, then the small matches a region of big return new MatrixPosition(x, y); } } return null; }
long vs intã®ãããªãã¯ã¹ã®ã¿ã€ããè©ŠããŠã¿ãŸããããæè¯ã®çµæã¯ãi7 4790ã®64/32ãããJVMæ§æã®äž¡æ¹ã§int [] []ãããªãã¯ã¹ã䜿çšãããŸãŸã§ããã
ããããã¬ãŒã³
ã€ãŸããã¹ã¯ãªããéšåã¯äŸ¿å©ã§ããå¿ èŠããããæ§æã¯ãã以äžèª¬æããããšãªãæ確ã§ãã çæ³çã«ã¯ããããã«ãŒãã«ã«åã蟌ãããšãã§ããããã¥ã¡ã³ããè±å¯ãªäžè¬çãªèšèªãé©ããŠããŸãã ã«ãŒãã«APIã®äœ¿çšã¯ç°¡åã§èŠãããããã®ã§ãªããã°ãªããŸããã
éžæè¢ã¯Pythonã«ããã人æ°ããããåŠç¿ãããããããææžåãããŠãããå€ãã®æ¢è£œã®ã©ã€ãã©ãªããããæãéèŠãªã®ã¯ãã¹ã¯ãªããã¯ããã¹ããšãã£ã¿ãŒã§ç°¡åã«ç·šéã§ããããšã§ãïŒ ããã«ãç§ã¯ãã£ãšãããç 究ããããšæã£ãŠããŸããã
Javaã«ã¯ãJythonãšåŒã°ããçµã¿èŸŒã¿Pythonå®è£ ããããŸãã JVMäžã§å®è¡ãããéå§ããã®ã«ç¹å¥ãªãã®ã¯å¿ èŠãããŸãããæåéããã¹ãŠã®ã¯ã©ã¹ãJavaã©ã€ãã©ãªãããã³.jarããã¯ã䜿çšã§ããŸãã é çªã«ãããã¯æ£ããéžæã«å¯Ÿããèªä¿¡ã匷ããã ãã§ãã
Jythonããããžã§ã¯ãã«æ¥ç¶ããã€ã³ã¿ãŒããªã¿ãŒãªããžã§ã¯ããäœæããŠãã¹ã¯ãªãããã¡ã€ã«ãå®è¡ããŸãã
class JythonVM { private boolean isJythonVMLoaded = false; private Object jythonLoad = new Object(); private PythonInterpreter pi = null; public JythonVM() { // TODO Auto-generated constructor stub } void load() { System.out.println("CORE: Loading JythonVM..."); pi = new PythonInterpreter(); isJythonVMLoaded = true; System.out.println("CORE: JythonVM loaded."); synchronized (jythonLoad) { jythonLoad.notify(); } } void run(String script) throws Exception { System.out.println("CODE: Waiting for JythonVM to load"); if (!isJythonVMLoaded) synchronized (jythonLoad) { jythonLoad.wait(); } System.out.println("CORE: Running " + script + "...\n\n"); pi.execfile(script); System.out.println("CORE: Script execution finished."); } }
ã¹ã¯ãªãããèŠãŠãã ãã
# -*- coding: utf-8 -*- print("hello")
ã¹ã¯ãªãããããå¿ èŠãªã«ãŒãã«ã¯ã©ã¹ãããŒãããåçŽã«ãªããžã§ã¯ããäœæããŸãã ãããã£ãŠãã¯ã©ã¹ã¡ãœããããã«ã§ããŸããã€ãŸããã«ãŒãã«APIã䜿çšããŠå¿ èŠãªã¢ã¯ã·ã§ã³ãå®è¡ã§ããŸãã
ãããã®ã¯ã©ã¹ã¯Actionããã³MatrixPositionã§ããããåŸã§ã¿ã€ãFragmentNotLoadedExceptionããã³ScreenNotGrabbedExceptionã®äŸå€ã¯ã©ã¹ãè¿œå ãããŸãã
ã¢ã¯ã·ã§ã³-ã«ãŒãã«æ©èœã«ã¢ã¯ã»ã¹ããããã®ã¡ã€ã³ã¯ã©ã¹ãšããŠäœ¿çšãããŸãã åé¡ã解決ããããã«å¿ èŠãªäœåãªè¡ã®æ°ãæžããããã«ãã¹ã¯ãªãããèšè¿°ããããã»ã¹ãåçŽåããããã«èšèšããã䟿å©ãªã¡ãœãããå«ãŸããŠããŸãã åãmouseClickãkeyClickãã¹ã¯ãªãŒã³ã·ã§ããå ã®ãã©ã°ã¡ã³ãã®æ€çŽ¢ãã¹ã¯ãªãŒã³ã·ã§ããèªäœã®äœæãªã©ã
ããã«ããã®ã¯ã©ã¹ã®å€ãã®ãªããžã§ã¯ããäœæããããã«å¿ããŠäžåºŠã«è€æ°ã®ã¹ã¬ããã§ç¬ç«ããŠäœ¿çšã§ããŸãïŒ
ã«ãŒãã«APIã䜿çšããããã«ãæ°è¡ã§ã¹ã¯ãªãããè£å®ããŸããã
# -*- coding: utf-8 -*- from bot.penguee import Action a = Action() # API print("hello") # , a.mouseMove(1000, 500) # x 1000, y 500
MatrixPosition-ç»é¢äžã®åº§æšã®ã©ãããŒãšããŠäœ¿çšãããŸãã ãã®åœ¢åŒã§ã¯ããããAPIã¯åº§æšãè¿ããŸãã ãã¡ããããã§ã«å¿ èŠãªæ©èœãåããæ¢è£œã®Pointã¯ã©ã¹ãæãåºããŸãã ãã ãããã¹ãŠãããã»ã©åçŽã§ã¯ãªããããXããã³Yãã£ãŒã«ãã«ã¯pos.getX pos.getYã¡ãœãããä»ããŠã®ã¿ã¢ã¯ã»ã¹ã§ããŸããããã«ãããã¹ã¯ãªããäœæäžã«å€ãã®äžäŸ¿ãçããŸãã pos.x pos.yãä»ããŠãã£ãŒã«ãã«ã¢ã¯ã»ã¹ããæ¹ãã¯ããã«äŸ¿å©ã§ãã ããã«ãç·Žç¿ã§ã¯ãäœçœ®ã«ãç¬èªã®ååãå¿ èŠã§ããããšã瀺ãããŠããŸããããã¯ãäœçœ®ã䞊ã¹æ¿ããïŒç»é¢ã®æ°åãã¢ã«ãã¡ãããé ã«åŠçããïŒãªã©ã®ã¿ã¹ã¯ã«å¿ èŠã§ããããšãå€æããŸããã
addãsubã¡ãœããã䜿çšããŠå¯èœæ§ãåºããçŸåšã®ãªããžã§ã¯ãã®åº§æšãåºæºã«ããæ°ããäœçœ®ãäœæã§ããŸãã
# -*- coding: utf-8 -*- from bot.penguee import MatrixPosition, Action a = Action() print("hello") mp = MatrixPosition(1000, 500) print(mp.x, mp.y) a.mouseMove(mp)
ãã®åŸã®æ¹å
ãã¿ãŒã³åº§æšãã£ãã·ã¥
æ€çŽ¢ã®çµ±èšãããç»é¢äžã®äœçœ®ãå€æŽããªãéçãªç»åãã»ãšãã©èŠã€ããå¿ èŠãããããšãæããã«ãªããŸããã ãã®ããã座æšä»ãã®ãã£ãã·ã¥ãè¿œå ãããŸããã ç»åããã£ãã·ã¥ã«ããå ŽåããŸããã£ãã·ã¥ããã座æšã«ç»åãååšãããã©ããããã§ãã¯ãããååšããªãå Žåã¯ç»é¢ã®æ®ãã®éšåãæ€çŽ¢ãããŸãã ãã®å°ããªè©³çŽ°ã«ãããã¹ã¯ãªããã®å®è¡é床ãå€§å¹ ã«åäžããŸããã
ãµãŒãã¹äžã®GPGPU
ç§ã¯åžžã«ã倧ç»é¢ã§ãã¿ãŒã³ãèŠã€ããããã»ã¹ãéããããã£ãã®ã§ãããã¢ã«ãŽãªãºã ã®æé©åã«ã¯éçããããŸãã ããã«å ç«ã¡ãæ€çŽ¢ããã»ã¹å šäœãããã»ããµäžã§è¡ããããããå¥ã ã®ã¹ã¬ããã«åå²ããŠããå®éã®é床ã¯åäžããŸããããè² è·ã®åé¡ãäžæ¡å¢å ããŸãã GPGPUã®ã«ãŒãã«ã³ãŒããèšè¿°ããçµéšããããããOpenCLã©ã€ãã©ãªãããŒãããããã»ããµãŒã§äœ¿çšããããã®ãšåãæ€çŽ¢ã¢ã«ãŽãªãºã ãæããŸããïŒãããªã«ãŒãã®æé©ãªãœãªã¥ãŒã·ã§ã³ã§ã¯ãããŸããïŒã
æ¯èŒã®ããã«ãç»é¢è§£å床ã1920 * 1080ã®Intel i7 4790ã§ã¯ãããã»ããµæ€çŽ¢ã¯ææªã®å ŽåïŒç»é¢ã®æãé ãé ïŒã§0-12msãè²»ãããIntel HD 4600ã§ã¯0-2msãå®å®ããŠããŸãã ãã ããã¹ã¯ãªãŒã³ã·ã§ããã®ãããªãã¯ã¹ããããªã«ãŒãã®ã¡ã¢ãªã«ããŒãããå¿ èŠããããæéãããããããã¹ã¯ãªãŒã³ã·ã§ããèªäœãäœæããããé·ãããã»ã¹ã§æ¯æãå¿ èŠããããŸãã åæã«ãããã¯åãã¹ã¯ãªãŒã³ã·ã§ããã§å€ãã®ç°ãªãåçãæ€çŽ¢ã§ãããšããäºå®ã«ãã£ãŠè£ãããæçµçã«ããã»ããµæ€çŽ¢ã®åã«ããã©ãŒãã³ã¹ãåäžããŸãã
ã¹ã¬ããã»ãŒã
ã¹ããªãŒã ã䜿çšãããã©ã°ã¡ã³ããçžäºã«ç¬ç«ããŠæ€çŽ¢ã§ããããã«ããããšãç¹ã«éèŠã§ããããã«ãããã¹ã¯ãªãããèšè¿°ãããšãã«ãã°ãçºçããªãããã«ããããã¡ããªããžã§ã¯ããããŒã«ã«ã«ãªããŸãã
ã¯ãã¹ãã©ãããã©ãŒã
ã¹ã¯ãªããã¯ã©ã®ãã©ãããã©ãŒã ã§ãåãããã«æ©èœããŸãããäŸå€ã¯ã³ã³ãœãŒã«ã«åºåãããããã¹ãããªãã¬ãŒãã£ã³ã°ã·ã¹ãã ããšã«ç°ãªããšã³ã³ãŒãã£ã³ã°ã®ã¿ã§ãããããããã¯å¥ã®åé¡ã§ãã JVMã䜿çšãããšãã€ã³ã¹ããŒã«ããå¿ èŠãªããä»»æã®ãã©ãããã©ãŒã ã§ããããå®è¡ã§ããŸãã ãTook and runningãã
æçµçµæ
ã¹ã¯ãªããããåŒã³åºãããšãã§ããã«ãŒãã«ã¡ãœããã®æ°ã¯70å以äžããããã®æ°ã¯åžžã«å¢å ããŠããŸãã
ãã®ããŒã«ã¯ããœãããŠã§ã¢ããã³ã°ã©ãã£ã«ã«ã€ã³ã¿ãŒãã§ã€ã¹ã®ãã¹ãã«é©ããŠããŸãã äœããèªååããå¿ èŠãããå Žåã«åœ¹ç«ã¡ãŸããããã€ããªãéžæããããã®æ¬²æ±ãååãªç¥èããããŸããïŒenikeesã«é©ããŠããŸãïŒã
å®éã®äœ¿çšäŸ
æãããªçç±ãããååããœãŒã¹ã³ãŒãã¯æããŸããã
- ãªã³ã©ã€ã³MMOã²ãŒã ã®ãªãŒã¯ã·ã§ã³çšã®ååŒãããã§ãããªã¢ã«ã¿ã€ã ãããã¯ãååã®äŸ¡å€ãšå販ã«ããå©çã®æ°å€ãåæãããªãŒããŒã¬ã€ã¬ã€ã€ãŒã䜿çšããŠãå©çã®æ°ããŠãŒã¶ãŒã®ç»é¢ã«çŽæ¥æžã蟌ã¿ãŸãã
- ã·ã³ã°ã«ãã¬ã€ã€ãŒã²ãŒã çšã®ããã·ããã¯ãã¯ã建ç©ãèªåçã«æ¹åããã¢ããã°ã¬ãŒããã¿ã³ã®ååšãååçã«èŠ³å¯ããã³ã³ãããŒã«ãäžç¬ååããããçæéã§ç®çã®ãã¿ã³ãã¯ãªãã¯ããŸãã
- Skypeã§æ°ããã¡ãã»ãŒãžãåä¿¡ãããšãããã°ã©ã ãšç®çã®ãã€ã¢ãã°ã®ãŠã£ã³ããŠãéããŸãã
- åŸæ¥å¡ã®ååã«ãã£ãŠè¡ãããä»äºã®ãªãã£ã¹ã«ãŠã³ããããŒã¿ã¯APIãæããªãããŸãã¯ããŒã¿ããŒã¹ã«ç°¡åã«ã¢ã¯ã»ã¹ã§ããªãå€ãããã°ã©ã ã®ã€ã³ã¿ãŒãã§ã€ã¹ããèŠèŠçã«ååŸãããŸãã
- 1Cããã®ååã®ãªãã£ã¹ã«ãŠã³ãã§ã¯ãEnikeyã¯APIãšããŒã¿ããŒã¹ãçŽæ¥æäœã§ããŸããããã®ãããã䜿çšããŸããã
GUIãããã®ã¬ãã¥ãŒ
解æããç°¡åãªã¹ã¯ãªãããæžã
YouTubeãã¬ã€ãªã¹ã
ãããªããã®ã¹ã¯ãªãã
# -*- coding: utf-8 -*- from bot.penguee import MatrixPosition, Action from java.awt.event import InputEvent, KeyEvent a = Action() p1 = MatrixPosition(630, 230) p2 = MatrixPosition(1230, 780) while True: a.grab(p1, p2) a.searchRect(630, 230, 1230, 780) # if a.find("verstak.gui"): a.searchRect(760, 320, 960, 500) # emptyCells = a.findAllPos("cell_empty") a.searchRect(700, 520, 1220, 770) # if a.findClick("coal.item"): coalRecentPos = a.recentPos() print(coalRecentPos.name) for i in range(len(emptyCells)): a.mouseClick(emptyCells[i], InputEvent.BUTTON3_MASK) a.sleep(50) a.mouseClick(coalRecentPos) a.searchRect(630, 230, 1230, 780) # result = a.findPos("verstak.arrow").relative(70, 0) a.keyPress(KeyEvent.VK_SHIFT) a.sleep(100) a.mouseClick(result) a.sleep(100) a.keyRelease(KeyEvent.VK_SHIFT) elif a.find("pech.gui"): if a.find("pech.off"): a.searchRect(700, 520, 1220, 770) # if a.findClick("coal.block"): coalBlockRecentPos = a.recentPos() a.searchRect(630, 230, 1230, 780) # a.mouseClick(a.findPos("pech.off"), InputEvent.BUTTON3_MASK) a.mouseClick(coalBlockRecentPos) result = a.findPos("verstak.arrow").relative(70, 0) a.keyPress(KeyEvent.VK_SHIFT) a.sleep(100) a.mouseClick(result) a.sleep(100) a.keyRelease(KeyEvent.VK_SHIFT) if a.find("pech.empty"): a.searchRect(700, 520, 1220, 770) # if a.findClick("gold.ore"): a.searchRect(630, 230, 1230, 780) # a.mouseClick(a.findPos("pech.empty")) a.sleep(6000)
Githubãªã³ã¯
APIãªãã¡ã¬ã³ã¹
UPDïŒ02/28/2019ãã¬ã€ãªã¹ããè¿œå ããããªã³ã¯ãæŽæ°ãããŸãã
å°æ¥ã®ããŒãžã§ã³ã§ã¯ïŒ
ãã©ã°ã¡ã³ã圢åŒã¯ãäžäœäºææ§ãåããŠ.bmpãã.pngã«å€æãããŸããã
85ïŒ 90ïŒ 95ïŒ ãªã©ãé¡äŒŒã®ïŒå®å šã§ã¯ãªãïŒäžèŽã®æ€çŽ¢ãè¿œå ãããŸãã...
éææ§ã®ãããã©ã°ã¡ã³ãã®æ€çŽ¢ãè¿œå ãããŸããããã©ã°ã¡ã³ãã¯ã©ã®ãããªåœ¢ç¶ã§ãããŸããŸãã
ã¯ã€ãã¯ã¹ã¿ãŒããé«éåããPythonæ¡åŒµã¹ã¯ãªãããè¿œå ããŸãã