mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-02 23:23:55 +00:00
Merge pull request #141 from go-vgo/dev
add get Scale and GetScaleSize func
This commit is contained in:
commit
86d35b65b1
42
robotgo.go
42
robotgo.go
@ -188,13 +188,43 @@ func GetPixelColor(x, y int) string {
|
|||||||
return gcolor
|
return gcolor
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetScreenSize get screen size
|
// ScaleX get primary display horizontal DPI scale factor
|
||||||
|
func ScaleX() int {
|
||||||
|
return int(C.scalex())
|
||||||
|
}
|
||||||
|
|
||||||
|
// ScaleY get primary display vertical DPI scale factor
|
||||||
|
func ScaleY() int {
|
||||||
|
return int(C.scaley())
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetScreenSize get the screen size
|
||||||
func GetScreenSize() (int, int) {
|
func GetScreenSize() (int, int) {
|
||||||
size := C.get_screen_size()
|
size := C.get_screen_size()
|
||||||
// fmt.Println("...", size, size.width)
|
// fmt.Println("...", size, size.width)
|
||||||
return int(size.width), int(size.height)
|
return int(size.width), int(size.height)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Scale get the screen scale
|
||||||
|
func Scale() int {
|
||||||
|
dpi := map[int]int{
|
||||||
|
96: 100,
|
||||||
|
120: 125,
|
||||||
|
144: 150,
|
||||||
|
192: 200,
|
||||||
|
}
|
||||||
|
|
||||||
|
x := ScaleX()
|
||||||
|
return dpi[x]
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetScaleSize get the screen scale size
|
||||||
|
func GetScaleSize() (int, int) {
|
||||||
|
x, y := GetScreenSize()
|
||||||
|
s := Scale()
|
||||||
|
return x * s / 100, y * s / 100
|
||||||
|
}
|
||||||
|
|
||||||
// SetXDisplayName set XDisplay name
|
// SetXDisplayName set XDisplay name
|
||||||
func SetXDisplayName(name string) string {
|
func SetXDisplayName(name string) string {
|
||||||
cname := C.CString(name)
|
cname := C.CString(name)
|
||||||
@ -1293,16 +1323,6 @@ ____ __ ____ __ .__ __. _______ ______ ____ __ ____
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// ScaleX get primary display horizontal DPI scale factor
|
|
||||||
func ScaleX() int {
|
|
||||||
return int(C.scalex())
|
|
||||||
}
|
|
||||||
|
|
||||||
// ScaleY get primary display vertical DPI scale factor
|
|
||||||
func ScaleY() int {
|
|
||||||
return int(C.scaley())
|
|
||||||
}
|
|
||||||
|
|
||||||
// ShowAlert show a alert window
|
// ShowAlert show a alert window
|
||||||
func ShowAlert(title, msg string, args ...string) int {
|
func ShowAlert(title, msg string, args ...string) int {
|
||||||
var (
|
var (
|
||||||
|
Loading…
Reference in New Issue
Block a user