go 实现安卓可输入中文2018-11-02

2018-11-02  本文已影响5人  夏树的宝马
package main

import (
    "os/exec"
    "fmt"
    "os"
)

func main()  {

    //cmd:=exec.Command("sh","-c","input text aa")
    //cmd:=exec.Command(os.Getenv("SHELL"),"-c","input text aa55")
    //cmd:=exec.Command(os.Getenv("SHELL"),"-c","input text 发电房")
        //如果要输入中文需要安卓另外一个apk 下载链接见参考
    cmd:=exec.Command(os.Getenv("SHELL"),"-c","am broadcast -a ADB_INPUT_TEXT --es msg '可以可以'")
    bytes,err:=cmd.Output()
    if err!=nil{
        fmt.Println(err)
    }
    resp:=string(bytes)
    fmt.Println(resp)
}

参考:https://blog.csdn.net/slimboy123/article/details/54140029

上一篇下一篇

猜你喜欢

热点阅读