如何在批处理脚本中更改鼠标设置? [英] How do I change mouse settings in my batch script?

查看:396
本文介绍了如何在批处理脚本中更改鼠标设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个脚本,以更改注册表中的鼠标设置.当我运行脚本时,我看到所做的更改,但是除非我注销并重新登录,否则更改将不生效.

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.

这篇关于如何在批处理脚本中更改鼠标设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆