forked from electricbubble/gwda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (37 loc) · 749 Bytes
/
main.go
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
package main
import (
"github.com/electricbubble/gwda"
"image"
"log"
)
func main() {
driver, err := gwda.NewUSBDriver(nil)
if err != nil {
log.Fatalln(err)
}
screenshot, err := driver.Screenshot()
if err != nil {
log.Fatal(err)
}
img, format, err := image.Decode(screenshot)
if err != nil {
log.Fatal(err)
}
_, _ = img, format
// userHomeDir, _ := os.UserHomeDir()
// file, err := os.Create(userHomeDir + "/Desktop/s1." + format)
// if err != nil {
// log.Fatal(err)
// }
// defer func() { _ = file.Close() }()
// switch format {
// case "png":
// err = png.Encode(file, img)
// case "jpeg":
// err = jpeg.Encode(file, img, nil)
// }
// if err != nil {
// log.Fatal(err)
// }
// log.Println(file.Name())
}