如何在批处理脚本中更改鼠标设置?
我正在尝试创建一个脚本,以更改注册表中的鼠标设置.当我运行脚本时,我看到所做的更改,但是除非我注销并重新登录,否则更改将不生效.
I'm trying to make a script that changes my mouse settings in the registry. When I run the script I see that the changes are made, but they won't be taken into effect unless I log out and log back in, which is not feasible.
:: MouseSensitivity 10
:: MouseSpeed (Set Pointer Precision) 0
:: MouseThreshold1 0
:: MouseThreshold2 0
@ECHO OFF
REG ADD "HKEY_CURRENT_USER\Control Panel\Mouse" /v MouseSensitivity /t REG_SZ /d 10 /f
REG ADD "HKEY_CURRENT_USER\Control Panel\Mouse" /v MouseSpeed /t REG_SZ /d 0 /f
REG ADD "HKEY_CURRENT_USER\Control Panel\Mouse" /v MouseThreshold1 /t REG_SZ /d 0 /f
REG ADD "HKEY_CURRENT_USER\Control Panel\Mouse" /v MouseThreshold2 /t REG_SZ /d 0 /f
ECHO Execution logged on: %DATE% at %TIME% >> test.txt
:: /* Tried this, doesn't work.
:: RUNDLL32.EXE USER32.DLL, UpdatePerUserSystemParameters
:: */
@EXIT /B 0
更改注册表值将不会应用更改.
Changing registry values won't apply the changes.
Windows系统在启动时读取并加载它们,而在更改值时不会发生这种情况.您需要调用系统API来做到这一点.
The Windows system reads and loads them on startup, which doesn't happen on changing the values. You need to call system APIs to do that.
我使用了PowerShell脚本.您可以在以下位置找到代码
I've used a PowerShell script for same. You can find the code at
https://github.com/raevilman/windows-scripts/tree/master/mouse/speed
我在那里放置了两个批处理文件.一个用于触摸板,另一个用于USB鼠标,因为它们都以不同的速度运行.您肯定会根据需要拥有自己的版本.
There I have placed two batch files. One for the touchpad and one for the USB mouse, because they both operate on different speeds. You will definitely have your version as per needs.
PS:不要问PowerShell执行策略等问题.如果遇到这些问题,请用Google搜索.
PS: Don't ask about PowerShell execution policy, etc. If you face them, google it.