如果我想编写一些可以更改 Windows 中键盘/鼠标配置的程序,我应该从哪里开始?

发布于 2024-09-16 06:19:57 字数 55 浏览 2 评论 0原文

配置与您在 Windows 下的键盘/鼠标设置中看到的选项相同。 我有一些 .NET 编程经验。

Configuration as in the options you see in the Keyboard/Mouse settings under Windows.
I have some .NET programming experience.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

上课铃就是安魂曲 2024-09-23 06:19:57

Win-API 是您的朋友。谷歌这个API以获取更多信息,通过这个你可以检索和设置许多关于鼠标和键盘的系统参数:

系统参数信息
SystemParametersInfo 函数查询或设置系统范围的参数。该功能还可以在设置参数的同时更新用户配置文件。

Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long

例如,如果您将 uAction SPI_GETKEYBOARDDELAY 发送到该函数,您将检索键盘重复延迟设置。 pvParam 参数必须指向接收设置的整型变量。

其他一些(还有更多)有趣的常量是:
获取:
SPI_GETMOUSE、SPI_GETMOUSEHOVERHEIGHT、SPI_GETMOUSEHOVERTIME、SPI_GETMOUSEHOVERWIDTH、SPI_GETMOUSEKEYS、SPI_GETMOUSETRAILS、SPI_GETNONCLIENTMETRICS、SPI_GETSTICKYKEYS、SPI_GETTOGGLEKEYS、SPI_GETWHEELSCROLLLINES

设置:
SPI_SETDOUBLECLICKTIME、SPI_SETDOUBLECLKHEIGHT、SPI_SETDOUBLECLKWIDTH、SPI_SETKEYBOARDDELAY、SPI_SETKEYBOARDPREF、SPI_SETKEYBOARDSPEED、SPI_SETLANGTOGGLE、SPI_SETMOUSE、SPI_SETMOUSEBUTTONSWAP、SPI_SETMOUSEHOVERHEIGHT、SPI_SETMOUSEHOVERTIME、 HOVERWIDTH、SPI_SETMOUSEKEYS、SPI_SETMOUSETRAILS

Win-API is your friend here. Google this API for more information, with this you can retrieve and set a lots of systems parameters about mouse and keyboad:

SystemParametersInfo
The SystemParametersInfo function queries or sets systemwide parameters. This function can also update the user profile while setting a parameter.

Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long

If you for example send the uAction SPI_GETKEYBOARDDELAY to the function you will retrieve the keyboard repeat-delay setting. The pvParam parameter must point to an integer variable that receives the setting.

Some other (there are more) intreresting constants are:
GET:
SPI_GETMOUSE, SPI_GETMOUSEHOVERHEIGHT, SPI_GETMOUSEHOVERTIME, SPI_GETMOUSEHOVERWIDTH, SPI_GETMOUSEKEYS, SPI_GETMOUSETRAILS, SPI_GETNONCLIENTMETRICS, SPI_GETSTICKYKEYS, SPI_GETTOGGLEKEYS, SPI_GETWHEELSCROLLLINES

SET:
SPI_SETDOUBLECLICKTIME, SPI_SETDOUBLECLKHEIGHT, SPI_SETDOUBLECLKWIDTH, SPI_SETKEYBOARDDELAY, SPI_SETKEYBOARDPREF, SPI_SETKEYBOARDSPEED, SPI_SETLANGTOGGLE, SPI_SETMOUSE, SPI_SETMOUSEBUTTONSWAP, SPI_SETMOUSEHOVERHEIGHT, SPI_SETMOUSEHOVERTIME, SPI_SETMOUSEHOVERWIDTH, SPI_SETMOUSEKEYS, SPI_SETMOUSETRAILS

秉烛思 2024-09-23 06:19:57

如果您只想让它影响您自己的流程,您可以使用 InputLanguage 类来更改键盘布局,但如果我理解正确的话,您想更改系统范围的设置吗?

正如斯图尔特所说,你实际上不应该从应用程序中执行此操作,因此我认为没有任何“受支持”的方式来执行此操作。但是,我认为所有这些设置都存储在注册表中,因此您可以通过更改这些设置并重新启动电脑来完成。

以下是一些更改键盘布局可能值得查看的链接:

键盘布局代码
如何我在登录期间配置默认键盘布局吗?

这两个链接都很旧,但我认为很可能仍在使用相同的设置。

如果您想更改布局以外的其他键盘设置,或者如果您想更改鼠标设置,您可以尝试在谷歌上搜索设置名称+“注册表键”或类似的内容以查找其存储位置,或者可以在超级用户网站。

If you only wanted it to affect your own process you could use the InputLanguage class to change keyboard layout, but if I understand correctly you want to change the system wide settings?

As Stuart says, you're not really supposed to do this from an app so I don't think there's any "supported" way of doing it. However, I think all these settings are stored in the registry so you could probably do it by changing those settings and rebooting the PC.

Here's some links that might be worth looking at for changing the Keyboard layout:

Keyboard layout code
How do I configure the default keyboard layout during login?

Both those links are quite old but I think that it's likely that the same settings are still used.

If you want to change other keyboard settings than the layout, or if you want to change mouse settings, you could try googling for the name of the setting + "registry key" or something similar to find where it's stored, or maybe ask on the Superuser site.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文