Unfortunately, there is no library for this. There are several bindings for magickwand (the C programming language and ImageMagick image processing libraries), see http://go-lang.cat-v.org/library-bindings , but they are incomplete and do not have a screen capture function.
Meanwhile, as GeertJohan suggested, you can use os.exec to launch an external program and capture the screen (see code example below). For example, you can use the import command from imagemagick to capture a screen (should work on a platform that can run imagemagick)
package main import ( "bytes" "fmt" "log" "os/exec" ) func main() { var buf bytes.Buffer path, err := exec.LookPath("import") if err != nil { log.Fatal("import not installed !") } fmt.Printf("import is available at %s\n", path) cmd := exec.Command("import", "-window", "root", "root.png") cmd.Stdout = &buf cmd.Stderr = &buf err = cmd.Run() if err != nil { panic(err) } fmt.Println(buf.String()) }
rputikar
source share