I am currently working with a program which is supposed to run in the background but also check if "mod + o" is pressed then do something. But I cannot figure out how a vb.net program can listen to key presses when the program is not Selected / Opened.
相关问题
- 'System.Threading.ThreadAbortException' in
- how to use special characters like '<'
- C# to VB - How do I convert this anonymous method
- Scaling image for printing
- visual basics equal to or greater than
相关文章
- vb.net 关于xps文件操作问题
- Checking for DBNull throws a StrongTypingException
- Using the typical get set properties in C#… with p
- Load a .NET assembly from the application's re
- C# equivalent of VB DLL function declaration (Inte
- What other neat tricks does the SpecialNameAttribu
- Node.js multiline input
- Automatically install updates with ClickOnce deplo
You can use P/Invocation to be able to use WinAPI's GetAsyncKeyState() function, then check that in a timer.
EDIT:
To make the code only execute one time per key press, you can add a little
While
-loop to run until either of the buttons are released (add it inside yourIf
-statement):This will stop your code from executing more than once while you hold the keys down.
When using this in a Console Application just replace every
System.Windows.Forms.Keys
andKeys
withConsoleKey
, and replaceLWin
withLeftWindows
.