From 01212c568407d752c42443c582914bb6dbab856c Mon Sep 17 00:00:00 2001 From: vcaesar Date: Mon, 27 Feb 2023 09:49:26 -0800 Subject: [PATCH] Fixed: fixed code and CI --- robotgo_win.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/robotgo_win.go b/robotgo_win.go index b803145..d2208bc 100644 --- a/robotgo_win.go +++ b/robotgo_win.go @@ -71,14 +71,16 @@ func GetMainId() int { // if "displayId == -2" this function will get the desktop scale value func ScaleF(displayId ...int) (f float64) { if len(displayId) > 0 && displayId[0] != -1 { - dpi := GetDPI(win.HWND(displayId[0])) - f = float64(dpi) / 96.0 - } else { - if displayId == -2 { - f = float64(GetDPI(GetDesktopWindow())) / 96.0 - } else { - f = float64(GetMainDPI()) / 96.0 + if displayId[0] >= 0 { + dpi := GetDPI(win.HWND(displayId[0])) + f = float64(dpi) / 96.0 } + + if displayId[0] == -2 { + f = float64(GetDPI(GetDesktopWindow())) / 96.0 + } + } else { + f = float64(GetMainDPI()) / 96.0 } if f == 0.0 {