1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
| package main
import ( . "fmt" "github.com/go-vgo/robotgo" )
func main() { robotgo.TypeString("Hello World") robotgo.KeyTap("enter") robotgo.KeyTap("a", "control") robotgo.KeyTap("h", "command")
robotgo.KeyTap("i", "alt", "command") arr := []string{"alt", "command"} robotgo.KeyTap("i", arr)
robotgo.KeyTap("w", "command") robotgo.KeyTap("m", "command") robotgo.KeyTap("f1", "control") robotgo.KeyTap("a", "control") robotgo.KeyToggle("a", "down") robotgo.KeyToggle("a", "down", "alt") robotgo.KeyToggle("a", "down", "alt", "command") robotgo.KeyToggle("enter", "down") robotgo.TypeString("en")
robotgo.MoveMouse(100, 200) robotgo.MouseClick() robotgo.MouseClick("right", false) robotgo.MouseClick("left", true) robotgo.ScrollMouse(10, "up") robotgo.MouseToggle("down", "right") robotgo.MoveMouseSmooth(100, 200) robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0) x, y := robotgo.GetMousePos() Println("pos:", x, y) if x == 456 && y == 586 { Println("mouse...", "586") }
robotgo.MouseToggle("up") robotgo.MoveMouse(x, y) robotgo.MoveMouse(100, 200)
for i := 0; i < 1080; i += 1000 { Println(i) robotgo.MoveMouse(800, i) } gbit_map := robotgo.BCaptureScreen() Println("Capture_Screen...", gbit_map.Width)
sx, sy := robotgo.GetScreenSize() Println("...", sx, sy)
color := robotgo.GetPixelColor(100, 200) Println("color----", color, "-----------------")
color2 := robotgo.GetPixelColor(10, 20) Println("color---", color2)
abit_map := robotgo.CaptureScreen() Println("a...", abit_map)
bit_map := robotgo.CaptureScreen(100, 200, 30, 40) Println("CaptureScreen...", bit_map)
fx, fy := robotgo.FindBitmap(bit_map) Println("FindBitmap------", fx, fy)
bit_pos := robotgo.GetPortion(bit_map, 10, 10, 11, 10) Println(bit_pos)
bit_str := robotgo.TostringBitmap(bit_map) Println("bit_str...", bit_str)
robotgo.SaveBitmap(bit_map, "test.png") robotgo.SaveBitmap(bit_map, "test31.tif", 1) robotgo.Convert("test.png", "test.tif")
open_bit := robotgo.OpenBitmap("test.tif") Println("open...", open_bit)
Println("---请按v键---") eve := robotgo.AddEvent("v")
if eve == 0 { Println("---你按下v键---", "v") }
Println("---请按k键---") keve := robotgo.AddEvent("k") if keve == 0 { Println("---你按下k键---", "k") }
Println("---请按鼠标左键---") mleft := robotgo.AddEvent("mleft") if mleft == 0 { Println("---你按下左键---", "mleft") }
abool := robotgo.ShowAlert("hello", "robotgo") if abool == 0 { Println("ok@@@", "确认") } robotgo.ShowAlert("hello", "robotgo", "确认", "取消") mdata := robotgo.GetActive() hwnd := robotgo.GetHandle() Println("hwnd---", hwnd) title := robotgo.GetTitle() Println("title-----", title) robotgo.CloseWindow() robotgo.SetActive(mdata) }
|