How to check whether a GUI used DPIScale ?
How to check whether a GUI used DPIScale ?
How to check whether a GUI used DPIScale ?
Re: How to check whether a GUI used DPIScale ?
Since you control the script, you know what's in it.
Re: How to check whether a GUI used DPIScale ?
Code: Select all
processID := ???
if !hProcess := DllCall("OpenProcess", "UInt", PROCESS_QUERY_INFORMATION := 0x0400, "Int", false, "UInt", processID, "Ptr")
throw
if !DllCall("shcore\GetProcessDpiAwareness", "Ptr", hProcess, "Int*", value)
throw
DllCall("CloseHandle", "Ptr", hProcess)
switch value
{
case 0: MsgBox PROCESS_DPI_UNAWARE`nValue: 0`nDPI unaware. This app does not scale for DPI changes and is always assumed to have a scale factor of 100% (96 DPI). It will be automatically scaled by the system on any other DPI setting.
case 1: MsgBox PROCESS_SYSTEM_DPI_AWARE`nValue: 1`nSystem DPI aware. This app does not scale for DPI changes. It will query for the DPI once and use that value for the lifetime of the app. If the DPI changes, the app will not adjust to the new DPI value. It will be automatically scaled up or down by the system when the DPI changes from the system value.
case 2: MsgBox PROCESS_PER_MONITOR_DPI_AWARE`nValue: 2`nPer monitor DPI aware. This app checks for the DPI when it is created and adjusts the scale factor whenever the DPI changes. These applications are not automatically scaled by the system.
}
Re: How to check whether a GUI used DPIScale ?
swagfag wrote: ↑02 Dec 2022, 13:37Code: Select all
processID := ??? if !hProcess := DllCall("OpenProcess", "UInt", PROCESS_QUERY_INFORMATION := 0x0400, "Int", false, "UInt", processID, "Ptr") throw if !DllCall("shcore\GetProcessDpiAwareness", "Ptr", hProcess, "Int*", value) throw DllCall("CloseHandle", "Ptr", hProcess) switch value { case 0: MsgBox PROCESS_DPI_UNAWARE`nValue: 0`nDPI unaware. This app does not scale for DPI changes and is always assumed to have a scale factor of 100% (96 DPI). It will be automatically scaled by the system on any other DPI setting. case 1: MsgBox PROCESS_SYSTEM_DPI_AWARE`nValue: 1`nSystem DPI aware. This app does not scale for DPI changes. It will query for the DPI once and use that value for the lifetime of the app. If the DPI changes, the app will not adjust to the new DPI value. It will be automatically scaled up or down by the system when the DPI changes from the system value. case 2: MsgBox PROCESS_PER_MONITOR_DPI_AWARE`nValue: 2`nPer monitor DPI aware. This app checks for the DPI when it is created and adjusts the scale factor whenever the DPI changes. These applications are not automatically scaled by the system. }
Thank you both for the suggestions .
I searched MSDN,
the return code is S_OK(0), if "GetProcessDpiAwareness" successfully retrieved the DPI awareness of the specified process.
Code: Select all
gui,+hwndhg1 -DPIScale
gui,Margin,30,20
gui,Color,white
gui,add,Text,% "xm w150 " " hwndhT_"1 , % " hello world "1
gui,add,Edit,% "xm w150 " " vE"1 " hwndhE"1 " r1 +Multi " , % " hello world 1"
gui,show,AutoSize
;processID := ""
;WinGet processID, PID, ahk_id %hg1%
processID := DllCall("GetCurrentProcessId") ;Same to "WinGet"
if !hProcess := DllCall("OpenProcess", "UInt", PROCESS_QUERY_INFORMATION := 0x0400, "Int", false, "UInt", processID, "Ptr")
throw
;S_OK 0x00000000 The function successfully retrieved the DPI awareness of the specified process.
;E_INVALIDARG 0x80070057 The handle or pointer passed in is not valid.
;E_ACCESSDENIED 0x80070005 The application does not have sufficient privileges.
;if !DllCall("shcore\GetProcessDpiAwareness", "Ptr", hProcess, "Int*", value) ;S_OK : 0
ret := DllCall("shcore\GetProcessDpiAwareness", "Ptr", hProcess, "Int*", value)
DllCall("CloseHandle", "Ptr", hProcess)
if(ret=0){ ;S_OK := 0
switch value
{
case 0: MsgBox PROCESS_DPI_UNAWARE`nValue: 0`nDPI unaware. This app does not scale for DPI changes and is always assumed to have a scale factor of 100`% (96 DPI). It will be automatically scaled by the system on any other DPI setting.
case 1: MsgBox PROCESS_SYSTEM_DPI_AWARE`nValue: 1`nSystem DPI aware. This app does not scale for DPI changes. It will query for the DPI once and use that value for the lifetime of the app. If the DPI changes, the app will not adjust to the new DPI value. It will be automatically scaled up or down by the system when the DPI changes from the system value.
case 2: MsgBox PROCESS_PER_MONITOR_DPI_AWARE`nValue: 2`nPer monitor DPI aware. This app checks for the DPI when it is created and adjusts the scale factor whenever the DPI changes. These applications are not automatically scaled by the system.
}
}
Return
GuiClose:
ExitApp
esc::ExitApp
Re: How to check whether a GUI used DPIScale ?
Here's mine.
Code: Select all
Gui, % dpi := "-DPIScale"
Gui, Font, s10
Gui, Add, Text,, DPI:
Gui, Font, w700 cBlue
Gui, Add, Text, x+m w200, %dpi%
Gui, Show,, DPI