Skip to content

Commit

Permalink
set DPI awareness for win8.1 above windows os
Browse files Browse the repository at this point in the history
Signed-off-by: xcgspring <[email protected]>
  • Loading branch information
xcgspring committed Jan 21, 2015
1 parent 3afed35 commit 88a3264
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
14 changes: 13 additions & 1 deletion AXUI/driver/windows/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
from UIElement import UIElement
#set DPI awareness for win8.1
from AXUI.logger import LOGGER
import subprocess
p = subprocess.Popen("wmic path win32_operatingsystem get version", stdout=subprocess.PIPE)
(stdout, stderr) = p.communicate()
windows_version = stdout.split()[1]
if int(windows_version.split(".")[0]) >= 6 and int(windows_version.split(".")[1]) >= 3:
LOGGER().debug("Set DPI awareness for windows verison: %s" % windows_version)
import ctypes
shcore = ctypes.windll.shcore
shcore.SetProcessDpiAwareness(2)

from UIElement import UIElement
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <Windows.h>
#include <stdlib.h>
#include "wingetopt.h"
#include "ShellScalingApi.h"

int CaptureAnImage(HWND hWnd, RECT rcClient, char* filename)
{
Expand Down Expand Up @@ -162,6 +163,13 @@ int _tmain(int argc, _TCHAR* argv[])
BOOL flag_hWnd = FALSE, flag_filename = FALSE;
BOOL flag_left = FALSE, flag_right = FALSE, flag_top = FALSE, flag_bottom = FALSE;

//set DPI awareness for winblue
if (NTDDI_VERSION >= NTDDI_WINBLUE)
{
SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
}

//get options
char* optstr = "l:r:t:b:f:";
int opt;

Expand Down Expand Up @@ -211,6 +219,8 @@ int _tmain(int argc, _TCHAR* argv[])
RECT rcClient;
GetClientRect(hWnd, &rcClient);

//printf("%d, %d, %d, %d", rcClient.left, rcClient.right, rcClient.top, rcClient.bottom);

// Get customer resize area
if (flag_left && rcClient.left<left)
rcClient.left = left;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>shcore.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down
Binary file modified AXUI/driver/windows/screenshot/screenshot.exe
Binary file not shown.

0 comments on commit 88a3264

Please sign in to comment.