【发布时间】:2011-08-06 07:32:05
【问题描述】:
我需要通过cmd(或任何脚本,如 VBS/JS)或从注册表启用/禁用 ClearType(或“调整 Windows 的外观和性能 > 屏幕字体的平滑边缘”) /em> 注销或重新启动 Windows。
也许可以只为一个应用程序启用 ClearType。
【问题讨论】:
标签: windows-7 command-line registry cleartype
我需要通过cmd(或任何脚本,如 VBS/JS)或从注册表启用/禁用 ClearType(或“调整 Windows 的外观和性能 > 屏幕字体的平滑边缘”) /em> 注销或重新启动 Windows。
也许可以只为一个应用程序启用 ClearType。
【问题讨论】:
标签: windows-7 command-line registry cleartype
制作带有扩展名的文件 .reg 这是文件的注册表
Disable_Smooth_edges_of_screen_fonts
[HKEY_CURRENT_USER\Control Panel\Desktop]
"FontSmoothing"="0"
Enable_Smooth_edges_of_screen_fonts
[HKEY_CURRENT_USER\Control Panel\Desktop]
"FontSmoothing"="2"
您也可以通过 cmd 执行此操作 这是命令的语法
REG ADD KeyName [/v ValueName | /ve] [/t Type] [/s Separator] [/d Data] [/f]
您必须注销才能使您的更改生效
【讨论】:
如果不重新启动,我不知道该怎么做...
但我发现更改 FontSmoothing 键是不够的...
有关如何完全删除 ClearType 和 FontSmoothing 的完整过程,请查看:
Completley Disable Font Smoothing and ClearType in Windows 7
【讨论】:
以下对我有用: 控制面板>系统>高级系统设置>高级>(性能)设置>视觉效果>选择“自定义”并取消选中“屏幕字体的平滑边缘”
【讨论】:
查看以下链接中描述的内容:
http://www.vbforums.com/showthread.php?t=491091
调用 API 可能会触发系统范围的更新,因此您无需注销/登录即可看到更改。
当然,这不仅限于vb.net。
【讨论】:
在 Windows 下编写脚本的现代方式是使用 PowerShell。以下脚本需要 2.0 版,可从 Windows XP SP3 获得:
#requires -version 2.0
param([bool]$enable)
$signature = @'
[DllImport("user32.dll")]
public static extern bool SystemParametersInfo(
uint uiAction,
uint uiParam,
uint pvParam,
uint fWinIni);
'@
$SPI_SETFONTSMOOTHING = 0x004B
$SPI_SETFONTSMOOTHINGTYPE = 0x200B
$SPIF_UPDATEINIFILE = 0x1
$SPIF_SENDCHANGE = 0x2
$FE_FONTSMOOTHINGCLEARTYPE = 0x2
$winapi = Add-Type -MemberDefinition $signature -Name WinAPI -PassThru
if ($enable)
{
[void]$winapi::SystemParametersInfo($SPI_SETFONTSMOOTHING, 1, 0, $SPIF_UPDATEINIFILE -bor $SPIF_SENDCHANGE)
[void]$winapi::SystemParametersInfo($SPI_SETFONTSMOOTHINGTYPE, 0, $FE_FONTSMOOTHINGCLEARTYPE, $SPIF_UPDATEINIFILE -bor $SPIF_SENDCHANGE)
}
else
{
[void]$winapi::SystemParametersInfo($SPI_SETFONTSMOOTHING, 0, 0, $SPIF_UPDATEINIFILE -bor $SPIF_SENDCHANGE)
}
如果由于某种原因无法使用 PowerShell,则需要 DynamicWrapperX 才能在 WSH 中执行 WinAPI 函数。你首先需要在目标机器上注册它,然后你就可以使用这个 VBScript:
Set WinAPI = CreateObject("DynamicWrapperX")
WinAPI.Register "user32.dll", "SystemParametersInfo", "i=uuuu"
Const SPI_SETFONTSMOOTHING = &H004B
Const SPI_SETFONTSMOOTHINGTYPE = &H200B
Const SPIF_UPDATEINIFILE = &H1
Const SPIF_SENDCHANGE = &H2
Const FE_FONTSMOOTHINGCLEARTYPE = &H2
If WScript.Arguments(0) Then
WinAPI.SystemParametersInfo SPI_SETFONTSMOOTHING, 1, 0, SPIF_UPDATEINIFILE Or SPIF_SENDCHANGE
WinAPI.SystemParametersInfo SPI_SETFONTSMOOTHINGTYPE, 0, FE_FONTSMOOTHINGCLEARTYPE, SPIF_UPDATEINIFILE Or SPIF_SENDCHANGE
Else
WinAPI.SystemParametersInfo SPI_SETFONTSMOOTHING, 0, 0, SPIF_UPDATEINIFILE Or SPIF_SENDCHANGE
End If
两个脚本都接受一个参数,0 表示禁用 ClearType,1 表示启用。无需重启。
【讨论】:
.ps1 文件。然后你可以像powershell "& 'C:\myscript.ps1' 1"一样从命令行运行它。不过,可以调整系统注册表,以便您可以双击该文件。
File C:\asd.ps1 cannot be loaded because the execution of scripts is disabled on this system. 错误,这似乎很常见。我想我必须使用第一个谷歌结果来解决这个问题。
Set-ExecutionPolicy Unrestricted -Force 应该允许运行所有脚本,但Set-ExecutionPolicy RemoteSigned 可能更安全。检查这个:stackoverflow.com/questions/4037939
powershell "& 'C:\myscript.ps1' 0"。
Python 版本:
# make sure you install pywin32
# from http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/
import win32con
import win32gui
win32gui.SystemParametersInfo(win32con.SPI_SETFONTSMOOTHING, True, 0) # enable only
win32gui.SystemParametersInfo(win32con.SPI_SETFONTSMOOTHINGTYPE,
win32con.FE_FONTSMOOTHINGCLEARTYPE,
win32con.SPIF_UPDATEINIFILE | win32con.SPIF_SENDCHANGE)
【讨论】:
只是为了添加更多选项,我有 C# 版本,在其中添加了 GetFontSmoothing。
[DllImport("user32.dll", SetLastError = true)]
static extern bool SystemParametersInfo(uint uiAction, uint uiParam, ref int pvParam, uint fWinIni);
const uint SPI_GETFONTSMOOTHING = 74;
const uint SPI_SETFONTSMOOTHING = 75;
const uint SPI_UPDATEINI = 0x1;
const UInt32 SPIF_UPDATEINIFILE = 0x1;
private Boolean GetFontSmoothing()
{
bool iResult;
int pv = 0;
/* Call to systemparametersinfo to get the font smoothing value. */
iResult = SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, ref pv, 0);
if (pv > 0)
{
//pv > 0 means font smoothing is on.
return true;
}
else
{
//pv == 0 means font smoothing is off.
return false;
}
}
private void DisableFontSmoothing()
{
bool iResult;
int pv = 0;
/* Call to systemparametersinfo to set the font smoothing value. */
iResult = SystemParametersInfo(SPI_SETFONTSMOOTHING, 0, ref pv, SPIF_UPDATEINIFILE);
Console.WriteLine("Disabled: {0}", iResult);
}
private void EnableFontSmoothing()
{
bool iResult;
int pv = 0;
/* Call to systemparametersinfo to set the font smoothing value. */
iResult = SystemParametersInfo(SPI_SETFONTSMOOTHING, 1, ref pv, SPIF_UPDATEINIFILE);
Console.WriteLine("Enabled: {0}", iResult);
}
【讨论】: