Last active
December 19, 2015 16:29
-
-
Save ponkore/5983780 to your computer and use it in GitHub Desktop.
sikuli-api-1.0.2 をつかったサンプルプログラム。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defproject sandbox "0.1.0-SNAPSHOT" | |
:description "FIXME: write description" | |
:url "http://example.com/FIXME" | |
:license {:name "Eclipse Public License" | |
:url "http://www.eclipse.org/legal/epl-v10.html"} | |
:dependencies [[org.clojure/clojure "1.5.1"]] | |
:resource-paths ["lib/sikuli-api-1.0.2-standalone.jar"]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns sandbox.sikuli | |
(:require [clojure.string :as str] | |
[clojure.java.io :as io]) | |
(:import [org.sikuli.api API DesktopScreenRegion ImageTarget] | |
[org.sikuli.api.robot Mouse] | |
[org.sikuli.api.robot.desktop DesktopMouse] | |
[org.sikuli.api.visual Canvas DesktopCanvas] | |
[java.net URL])) | |
;;image-target (ImageTarget. (java.io.File. "/Users/masao/Desktop/google-code.png")) | |
(defn- show-label | |
"" | |
[canvas region label] | |
(doto canvas | |
(.addLabel region label) | |
(.addBox region) | |
(.display 3))) | |
(defn test1 | |
"" | |
([] (test1 "http://code.google.com" "http://code.google.com/images/code_logo.gif" "あいうえお")) | |
([url image-url label] | |
(let [scr (DesktopScreenRegion.) | |
canvas (DesktopCanvas.) | |
mouse (DesktopMouse.) | |
image-target (-> image-url (URL.) (ImageTarget.))] | |
(API/browse (URL. url)) | |
(when-let [region (.wait scr image-target 5000)] | |
(show-label canvas region label) | |
(.click mouse (.getCenter region)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment