简体   繁体   English

如何使用C#模拟功能键组合?

[英]How can I simulate function key combinations using C#?

I was hoping someone could help me with simulating a function key combination in C#, in this case FN + F4 . 我希望有人可以帮助我模拟C#中的功能键组合,在本例中为FN + F4

Here's what I'm trying to do... I have an older touchscreen netbook that I recently installed Windows 8 on. 这是我要尝试的操作...我有一台较旧的触摸屏上网本,最近在其上安装了Windows 8。 It has a swivel screen so you can fold it down and use it like a tablet. 它具有可旋转的屏幕,因此您可以将其向下折叠并像平板电脑一样使用。 Windows 8 runs surprisingly well on it. Windows 8可以在其上出色地运行。 I had a few minor issues, most of which I was able to work out, but one remains. 我遇到了一些小问题,其中大部分我都可以解决,但是仍然存在。

When you first power up the netbook or wake it from sleep, the screen is at 30% brightness, and Windows thinks that this is the max setting, so increasing the screen brightness through the normal methods does not work. 首次打开上网本电源或将其从睡眠状态唤醒时,屏幕处于30%的亮度,Windows认为这是最大设置,因此通过常规方法增加屏幕亮度不起作用。 On my netbook, pressing FN + F4 , restores the screen to full brightness. 在我的上网本上,按FN + F4可以将屏幕恢复到全亮度。 This is a minor annoyance though, because I have to swivel the screen back and forth to fix the brightness using the physical keyboard, when I'd like to just leave it in the tablet position and minimize wear and tear. 不过,这是一个小麻烦,因为当我想将其放置在平板电脑的位置并最大程度地减少磨损时,我必须使用物理键盘来回旋转屏幕以固定亮度。

What I'd like to do is write a little application that runs on start up, and simulates the function key combination, so the brightness is restored automatically. 我想做的是编写一个在启动时运行的小应用程序,并模拟功能键组合,以便自动恢复亮度。 Any suggestions would be greatly appreciated. 任何建议将不胜感激。 Thanks. 谢谢。

The Fn key is not a key that is sent from the keyboard to the computer. Fn键不是从键盘发送到计算机的键。 It is actually used to change the meaning of keys on the keyboard (such that the keyboard sends different scancodes when the key is pressed with Fn held down). 它实际上是用来更改键盘上按键的含义的(这样,在按住Fn的同时按下键盘时,键盘会发送不同的扫描代码)。

You should be able to easily write a simple Windows Forms program that listens to key presses and shows you what has been received. 您应该能够轻松编写一个简单的Windows窗体程序,该程序侦听按键并显示收到的信息。 Register for the KeyDown event. 注册KeyDown事件。 The KeyEventArgs your handler receives has various properties that you can inspect to see what is being received. 处理程序收到的KeyEventArgs具有各种属性,您可以检查这些属性以查看正在接收什么。

The FN key isn't a real keyboard key like the other modifiers ( shift , alt , ctrl ) nor is it a function key like the F1 - F12 . FN键不是像其他修饰符( shiftaltctrl )那样的真正键盘键,也不是F1 - F12这样的功能键。 The FN key is a hardware only key that simply tells the hardware to send a different keystroke while the FN key is being pressed. FN键是仅硬件的键,仅告诉硬件在按下FN键时发送不同的按键。

So, you are going to have to adjust the brightness manually like "my" stated in the comments or through some other mechanism. 因此,您将必须像注释中所述的“我的”或通过其他某种机制手动调整亮度。

Reference Link. 参考链接。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM