Windows has a built in Alt+Shift+PrtScn to toggle into high contrast mode, but Send !+{PrintScreen} doesn't work. It seems that hotkey is protected from simulation. Someone suggested me to use dllcall with
SystemParametersInfo
SPI_SETHIGHCONTRAST
0x0043
Only problem is, I know nothing about dllcall & even googling didn't reveal any code to set high contrast mode. I'm running AHK 64, any help please?
Turn On high contrast mode with autohotkey Topic is solved
-
- Posts: 34
- Joined: 09 Jun 2017, 09:19
Re: Turn On high contrast mode with autohotkey Topic is solved
This should do it. Cheers. Btw for anyone who wants to test, it was quite slow setting this to on, on my Windows 7 PC.
Link:
See if High Contrast Theme is On -- Help with DllCall("SystemParametersInfo") - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=38972
Code: Select all
q:: ;set high contrast on
vFlags := 0x1 ;on
;vFlags := 0x0 ;off
vSize := A_PtrSize=8?16:12
VarSetCapacity(HIGHCONTRAST, vSize, 0)
NumPut(vSize, &HIGHCONTRAST, 0, "UInt") ;cbSize
;HCF_HIGHCONTRASTON := 0x1
NumPut(vFlags, &HIGHCONTRAST, 4, "UInt") ;dwFlags
;SPI_SETHIGHCONTRAST := 0x43
DllCall("user32\SystemParametersInfo", UInt,0x43, UInt,vSize, Ptr,&HIGHCONTRAST, UInt,0)
return
See if High Contrast Theme is On -- Help with DllCall("SystemParametersInfo") - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=38972
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
-
- Posts: 34
- Joined: 09 Jun 2017, 09:19
Re: Turn On high contrast mode with autohotkey
Thanks, that works perfectly fine on Windows 10, no additional delays compared to manually toggling to high contrast mode using Alt+Shift+PrtScnjeeswg wrote:This should do it. Cheers. Btw for anyone who wants to test, it was quite slow setting this to on, on my Windows 7 PC.Link:Code: Select all
q:: ;set high contrast on vFlags := 0x1 ;on ;vFlags := 0x0 ;off vSize := A_PtrSize=8?16:12 VarSetCapacity(HIGHCONTRAST, vSize, 0) NumPut(vSize, &HIGHCONTRAST, 0, "UInt") ;cbSize ;HCF_HIGHCONTRASTON := 0x1 NumPut(vFlags, &HIGHCONTRAST, 4, "UInt") ;dwFlags ;SPI_SETHIGHCONTRAST := 0x43 DllCall("user32\SystemParametersInfo", UInt,0x43, UInt,vSize, Ptr,&HIGHCONTRAST, UInt,0) return
See if High Contrast Theme is On -- Help with DllCall("SystemParametersInfo") - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=38972
Re: Turn On high contrast mode with autohotkey
- Warning: I've written some code for on/off/toggle, however, I had slightly curious results, ending up with Explorer looking part high contrast/part normal. It might have been that the system went funny when I tried putting high contrast on, when it already was on, or something else. For this reason perhaps it's better to get the state, before you try to set the state. Anyhow, setting the theme in Control Panel, puts everything back to normal, or, more or less back to normal.
- Waiting a minute each time you change something, or wanting to restart the PC, to try tests from scratch, is not got great when you want to do a quick test.
- Waiting a minute each time you change something, or wanting to restart the PC, to try tests from scratch, is not got great when you want to do a quick test.
Code: Select all
return
;w:: ;set high contrast on
;e:: ;set high contrast off
if InStr(A_ThisHotkey, "w")
vFlags := 0x1 ;on
if InStr(A_ThisHotkey, "e")
vFlags := 0x0 ;off
vSize := A_PtrSize=8?16:12
VarSetCapacity(HIGHCONTRAST, vSize, 0)
NumPut(vSize, &HIGHCONTRAST, 0, "UInt") ;cbSize
;HCF_HIGHCONTRASTON := 0x1
NumPut(vFlags, &HIGHCONTRAST, 4, "UInt") ;dwFlags
;SPI_SETHIGHCONTRAST := 0x43
DllCall("user32\SystemParametersInfo", UInt,0x43, UInt,vSize, Ptr,&HIGHCONTRAST, UInt,0)
return
;==================================================
;q:: ;toggle high contrast
vSize := A_PtrSize=8?16:12
VarSetCapacity(HIGHCONTRAST, vSize, 0)
NumPut(vSize, &HIGHCONTRAST, 0, "UInt") ;cbSize
;SPI_GETHIGHCONTRAST := 0x42
DllCall("user32\SystemParametersInfo", UInt,0x42, UInt,vSize, Ptr,&HIGHCONTRAST, UInt,0)
vFlags := NumGet(&HIGHCONTRAST, 4, "UInt") ;dwFlags
;JEE_Progress(vFlags, 1000)
if (vFlags & 1) ;HCF_HIGHCONTRASTON := 0x1
vFlags -= 1
else
vFlags += 1
;JEE_Progress(vFlags, 1000)
VarSetCapacity(HIGHCONTRAST, vSize, 0)
NumPut(vSize, &HIGHCONTRAST, 0, "UInt") ;cbSize
NumPut(vFlags, &HIGHCONTRAST, 4, "UInt") ;dwFlags
;SPI_SETHIGHCONTRAST := 0x43
DllCall("user32\SystemParametersInfo", UInt,0x43, UInt,vSize, Ptr,&HIGHCONTRAST, UInt,0)
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: Turn On high contrast mode with autohotkey
Thank you so much for this code! It works great! I haven't noticed any side effects with it yet.
By the way, toggling the high contrast theme, either by LShift+LAlt+PrtSc or by your code, takes just a few seconds on my computer with Win11.
Who is online
Users browsing this forum: No registered users and 215 guests