切换高对比度主题 - windows 10
Toggle HighContrast Theme - windows 10
我希望能够通过按 F1 在 Windows 10 中切换 HighContrast 主题。
在 Windows10 中切换高对比度主题的快捷方式是:
Left Alt + Left Shift + Print Screen
https://msdn.microsoft.com/en-us/library/hh923906.aspx
这是我的脚本:
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; Toggle HighContrast Theme: Alt + Shift + PrintScreen
F1::
Send !+{PrintScreen}
Return
使用这个:
F1::
Send {LAlt down}{LShift down}{PrintScreen}{LAlt Up}{LShift Up}
return
来自官方documentation:
按如下方式按下:{LWin down} {RWin down}
像这样释放用尽:{LWin up} {RWin up}
您可以通过手动 运行 .theme 文件来应用设置。问题是它将打开“设置”对话框。此脚本将 运行 高对比度 1 主题文件,等待“设置”对话框打开,然后关闭它。
编辑:添加了在两个主题之间切换的代码
hc := false
hctheme := "C:\Windows\Resources\Ease of Access Themes\hc1.theme"
stdtheme := "C:\Windows\Resources\Themes\theme1.theme"
; your personalized theme may be in
; C:\Users\{user.name}\AppData\Local\Microsoft\Windows\Themes\Custom.theme
F1::
hc := !hc
if (hc)
run %hctheme%
else
run %stdtheme%
WinWait Settings
WinClose Settings
return
在测试中,似乎 Alt+PrtScr 键盘组合在 OS被 AutoHotKey 覆盖以添加 Shift 修饰符,然后它才默认为活动 window 截取屏幕截图。 (看看AHK论坛,这似乎也是共识。)
我确实设法找到了一些 script suggestions here,其中这个轻微的修改对我在 Win10 Pro 上有效:
F1:: ;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
我希望能够通过按 F1 在 Windows 10 中切换 HighContrast 主题。
在 Windows10 中切换高对比度主题的快捷方式是:
Left Alt + Left Shift + Print Screen
https://msdn.microsoft.com/en-us/library/hh923906.aspx
这是我的脚本:
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; Toggle HighContrast Theme: Alt + Shift + PrintScreen
F1::
Send !+{PrintScreen}
Return
使用这个:
F1::
Send {LAlt down}{LShift down}{PrintScreen}{LAlt Up}{LShift Up}
return
来自官方documentation:
按如下方式按下:{LWin down} {RWin down} 像这样释放用尽:{LWin up} {RWin up}
您可以通过手动 运行 .theme 文件来应用设置。问题是它将打开“设置”对话框。此脚本将 运行 高对比度 1 主题文件,等待“设置”对话框打开,然后关闭它。
编辑:添加了在两个主题之间切换的代码
hc := false
hctheme := "C:\Windows\Resources\Ease of Access Themes\hc1.theme"
stdtheme := "C:\Windows\Resources\Themes\theme1.theme"
; your personalized theme may be in
; C:\Users\{user.name}\AppData\Local\Microsoft\Windows\Themes\Custom.theme
F1::
hc := !hc
if (hc)
run %hctheme%
else
run %stdtheme%
WinWait Settings
WinClose Settings
return
在测试中,似乎 Alt+PrtScr 键盘组合在 OS被 AutoHotKey 覆盖以添加 Shift 修饰符,然后它才默认为活动 window 截取屏幕截图。 (看看AHK论坛,这似乎也是共识。)
我确实设法找到了一些 script suggestions here,其中这个轻微的修改对我在 Win10 Pro 上有效:
F1:: ;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