https://github.com/chixm/winscreencap
Golang Windows Screen Capture Library
https://github.com/chixm/winscreencap
Last synced: 5 months ago
JSON representation
Golang Windows Screen Capture Library
- Host: GitHub
- URL: https://github.com/chixm/winscreencap
- Owner: chixm
- License: mit
- Created: 2023-09-29T12:16:38.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-22T12:12:29.000Z (about 2 years ago)
- Last Synced: 2024-05-22T12:56:21.093Z (about 2 years ago)
- Language: Go
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# winscreencap
Golang Windows Screen Capture Library
## Install
```
go get github.com/chixm/winscreencap
```
## Choose Window and Capture Image
How to save the window named "game" as an png image screenshot.png
```
hwnd, err := winscreencap.FindWindowByName(`game`)
if err != nil {
t.Error(err)
return
}
img, err := winscreencap.CaptureWindow(hwnd)
if err != nil {
fmt.Println("Error:", err)
return
}
file, err := os.Create("screenshot.png")
if err != nil {
fmt.Println("Error:", err)
return
}
defer file.Close()
err = png.Encode(file, img)
if err != nil {
fmt.Println("Error:", err)
return
}
```