See if High Contrast Theme is On -- Help with DllCall("SystemParametersInfo") Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Verdlin
Posts: 63
Joined: 04 Oct 2013, 08:55
Contact:

See if High Contrast Theme is On -- Help with DllCall("SystemParametersInfo")

26 Oct 2017, 09:53

Using Autohotkey_H. I'm trying to check if a high contrast theme is on (see this link for a C++ example)

DllCall returns 0, but dwFlags is always 0, even when the high contrast theme is off. What am I doing wrong?

Code: Select all

vHighContrast := Struct("UINT cbSize, DWORD dwFlags, LPTSTR lpszDefaultScheme", {cbSize:sizeof("UINT cbSize, DWORD dwFlags, LPTSTR lpszDefaultScheme")})
Msgbox % DllCall("SystemParametersInfo", "Uint", SPI_GETHIGHCONTRAST:=66, "Uint", 0, "ptr", &vHighContrast, "Uint", 0)
MsgBox % vHighContrast.dwFlags
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: See if High Contrast Theme is On -- Help with DllCall("SystemParametersInfo")  Topic is solved

26 Oct 2017, 20:10

I believe you need to pass oHighContrast[""] rather than &oHighContrast.

Code: Select all

q::
;SPI_GETHIGHCONTRAST := 0x42
oHighContrast := Struct("UINT cbSize, DWORD dwFlags, LPTSTR lpszDefaultScheme", {cbSize:sizeof("UINT cbSize, DWORD dwFlags, LPTSTR lpszDefaultScheme")})
vSize := sizeof(oHighContrast)
DllCall("user32\SystemParametersInfo", UInt,0x42, UInt,vSize, Ptr,oHighContrast[""], UInt,0)
vFlags := oHighContrast.dwFlags
MsgBox, % Format("0x{:X}", vFlags)

vSize := A_PtrSize=8?16:12
VarSetCapacity(HIGHCONTRAST, vSize, 0)
NumPut(vSize, &HIGHCONTRAST, 0, "UInt") ;cbSize
DllCall("user32\SystemParametersInfo", UInt,0x42, UInt,vSize, Ptr,&HIGHCONTRAST, UInt,0)
vFlags := NumGet(&HIGHCONTRAST, 4, "UInt") ;dwFlags
MsgBox, % Format("0x{:X}", vFlags)

;HCF_HIGHCONTRASTON := 0x1 ;constant from WinUser.h
MsgBox, % "high contrast: " ((vFlags & 0x1) ? "on" : "off")
return

;[note: setting uiParam as 0 rather than sizeof(HIGHCONTRAST) also seemed to work]
;SystemParametersInfo function (Windows)
;https://msdn.microsoft.com/en-us/library/windows/desktop/ms724947(v=vs.85).aspx
;Set the cbSize member of this structure and the uiParam parameter to sizeof(HIGHCONTRAST).
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mebelantikjaya and 327 guests