1 Star 0 Fork 8

jee/Answer

forked from Henson/Answer 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
automatic.go 1.20 KB
一键复制 编辑 原始数据 按行查看 历史
Henson 提交于 2018-01-22 14:15 . init
package Answer
import (
"math/rand"
"os/exec"
"strconv"
"time"
"github.com/henson/Answer/device"
"github.com/henson/Answer/util"
"github.com/ngaut/log"
)
//PressArea 随机区域
func PressArea(choice int, cfg *util.Config) (x, y string) {
var P, H, K int
switch cfg.APP {
case "xigua":
P, H = cfg.XgAy, cfg.XgAh
case "cddh":
P, H = cfg.CdAy, cfg.CdAh
case "huajiao":
P, H = cfg.HjAy, cfg.HjAh
case "zscr":
P, H = cfg.ZsAy, cfg.ZsAh
}
K = 20
y = strconv.Itoa(P + K + (((H-4*K)/3)+K)*choice + 40)
x = strconv.Itoa(RandInt(40, 800))
return
}
//PressEcho 生成选项区域图
func PressEcho(cfg *util.Config) {
png, _ := device.NewAndroid(cfg).GetImage()
img0, _ := util.CutImage(png, 30, 420, 840, 90)
img1, _ := util.CutImage(png, 30, 520, 840, 90)
img2, _ := util.CutImage(png, 30, 625, 840, 90)
util.SavePNG("./images/0.png", img0)
util.SavePNG("./images/1.png", img1)
util.SavePNG("./images/2.png", img2)
}
//Press 点击屏幕
func Press(x, y string) {
err := exec.Command("adb", "shell", "input", "tap", x, y).Run()
if err != nil {
log.Errorf(err.Error())
}
}
//RandInt 随机数
func RandInt(min, max int) int {
rand.Seed(time.Now().UnixNano())
return min + rand.Intn(max-min)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/jempson/Answer.git
git@gitee.com:jempson/Answer.git
jempson
Answer
Answer
master

搜索帮助