diff --git a/robotgo.go b/robotgo.go index ab29081..0d0f699 100644 --- a/robotgo.go +++ b/robotgo.go @@ -1293,6 +1293,16 @@ ____ __ ____ __ .__ __. _______ ______ ____ __ ____ */ +// 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 func ShowAlert(title, msg string, args ...string) int { var ( diff --git a/window/goWindow.h b/window/goWindow.h index 32b159c..74a790f 100644 --- a/window/goWindow.h +++ b/window/goWindow.h @@ -18,6 +18,27 @@ int show_alert(const char *title, const char *msg, return alert; } +intptr scalex(){ + #if defined(IS_WINDOWS) + // Get desktop dc + HDC desktopDc = GetDC(NULL); + // Get native resolution + intptr horizontalDPI = GetDeviceCaps(desktopDc, LOGPIXELSX); + // intptr verticalDPI = GetDeviceCaps(desktopDc, LOGPIXELSY); + return horizontalDPI; + #endif +} + +intptr scaley(){ + #if defined(IS_WINDOWS) + // Get desktop dc + HDC desktopDc = GetDC(NULL); + // Get native resolution + intptr verticalDPI = GetDeviceCaps(desktopDc, LOGPIXELSY); + return verticalDPI; + #endif +} + bool is_valid(){ bool abool = IsValid(); return abool; @@ -68,7 +89,7 @@ void set_active(const MData win){ DWORD dwProcessId = 0; GetWindowThreadProcessId(hWnd, &dwProcessId); - if(dwProcessId == pInfo->dwPid) { + if (dwProcessId == pInfo->dwPid) { pInfo->hWnd = hWnd; return FALSE; } diff --git a/window/window.h b/window/window.h index 718b6d7..d1c4a94 100644 --- a/window/window.h +++ b/window/window.h @@ -560,7 +560,7 @@ bool IsMaximized(void){ void SetActive(const MData win){ // Check if the window is valid - if (!IsValid()) {return;} + if (!IsValid()) { return; } #if defined(IS_MACOSX) // Attempt to raise the specified window object