简体   繁体   English

如果要编程一些可以更改Windows中键盘/鼠标配置的东西,该从哪里开始?

[英]Where do I start if I want to program something that can change the configuration of Keyboard/Mouse in Windows?

Configuration as in the options you see in the Keyboard/Mouse settings under Windows. 按照Windows下“键盘/鼠标”设置中看到的选项进行配置。 I have some .NET programming experience. 我有一些.NET编程经验。

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? 如果只希望它影响自己的过程,则可以使用InputLanguage类来更改键盘布局,但是如果我理解正确,那么您想更改系统范围的设置吗?

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. 正如Stuart所说,您实际上不应该通过应用程序执行此操作,因此我认为没有任何“受支持的”方法可以执行此操作。 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. 但是,我认为所有这些设置都存储在注册表中,因此您可以通过更改这些设置并重新启动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. 如果您要更改布局以外的其他键盘设置,或者要更改鼠标设置,则可以尝试使用Google搜寻设置的名称+“注册表键”或类似的名称来查找其存储位置,或者在菜单上询问超级用户站点。

Win-API is your friend here. Win-API是您的朋友。 Google this API for more information, with this you can retrieve and set a lots of systems parameters about mouse and keyboad: 谷歌此API以获取更多信息,通过它您可以检索并设置有关鼠标和键盘的许多系统参数:

SystemParametersInfo SystemParametersInfo
The SystemParametersInfo function queries or sets systemwide parameters. SystemParametersInfo函数查询或设置系统范围的参数。 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. 例如,如果将uAction SPI_GETKEYBOARDDELAY发送给该函数,则将检索键盘重复延迟设置。 The pvParam parameter must point to an integer variable that receives the setting. pvParam参数必须指向接收设置的整数变量。

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 SPI_GETMOUSE,SPI_GETMOUSEHOVERHEIGHT,SPI_GETMOUSEHOVERTIME,SPI_GETMOUSEHOVERWIDTH,SPI_GETMOUSEKEYS,SPI_GETMOUSETRAILS,SPI_GETNONCLIENTMETRICS,SPI_GETSTICKYKEYS,SPI_GETTOGGLEKEYS,SCROLGETLHE

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 SPI_SETDOUBLECLICKTIME,SPI_SETDOUBLECLKHEIGHT,SPI_SETDOUBLECLKWIDTH,SPI_SETKEYBOARDDELAY,SPI_SETKEYBOARDPREF,SPI_SETKEYBOARDSPEED,SPI_SETLANGTOGGLE,SPI_SETMOUSE,SPI_SETMOUSESUSE_USEH,使用过

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我想解析并向电子邮件发送自动回复。 我从哪里开始? - I want to parse and send an automated response to an email. Where do I start? 在哪里可以找到“ SuperWebSocket”(Supersocket)的配置文件? 或者如何在代码中更改websocket的ReceiveBufferSize? - Where can I find the configuration file for “SuperWebSocket” (Supersocket)? Or how can I change ReceiveBufferSize for websocket in code? 从哪里开始面向方面编程? - Where do I start with Aspect Oriented Programming? 我想远程启动进程时要使用的Windows类 - What Windows Class to use when I want to start a process remotely NET中的异步流复制从哪里获得收益 - Where do I gain something with asynchronous stream copy in .net 我如何自动启动Windows服务 - How can i start windows service automatically 如何触发或抑制Windows虚拟键盘的显示 - How do I trigger or supress the display of Windows Virtual Keyboard 如何在Windows窗体应用程序中创建复合键盘快捷方式? - How do I create compound keyboard shortcuts in a Windows Forms application? 每次在Windows中启动应用程序时如何记录日志? - How do I log every time I start an application in Windows? 如何使用 C# 更改鼠标方案 - How can I change mouse scheme using C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM