c#
How do I make my application to know when the spacebar key is pressed globally on a low-level?
I want to call on a method to execute whenever the space key is pressed whether my application is on focus or running in the background. How do I this in C# ? Let s say the method to call on is sendData(). How do I hook my keyboard on a level level to execute the sendData() method whenever the space key is pressed using C#.
You need to listen for a key press, in your case you're looking for ConsoleKey.Spacebar, the documentation for it here: ConsoleKey Enum Here is a quick and dirty sample: Console.WriteLine("Press Spacebar to send data"); while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Spacebar)) { // iterate something (or nothing) } sendData(); // call your method afterwards It's important to note that Console.ReadKey is blocking. My code sample is just to illustrate some basics.
Related Links
LINQ Contains Syntax with List<string>
Visual Studio 2010 SDK, Get Caret Column
Reading rich text from an Excel cell
How to map class to database table?
How to open a window then load my XAML file to it? (XAML and C#)
Unexpected empty sequence in linq to sql result
C#: Line information when parsing XML with XmlDocument
Need help with a regular expression
Adding enum to combobox
Make font italic and bold
check a url is from a specific site
What are the new featurs of .Net4 that can improve the development in windows application,vsto
C# tool for printing into PDF which is compatible with Graphics class [duplicate]
Best way to separate two base64 strings
WinForm Controls in context menu
WPF: windowsformshost with webbrowser is very slow