I'm working on a program idea which needs to respond when a particular Function key is pressed on the keyboard(like F10).
(A) is that possible?
(B) what language should i use (i'll be getting the development outsourced, so its not 开发者_C百科a problem) (c) any sample code which shows how it works?a. Yes, of course.
b. Whatever is best for the rest of the program, assuming that it can call Windows APIs (or that such feature is builtin) and that the programmer knows how to intercept the message generated by RegisterHotKey.
c. See the RegisterHotKey function.
Note that F10 is really a bad idea, since it's the default key to activate the main menu; I don't even think you can register it.
Have a look at this Code Project article, I use this for an application I wrote, and works in Vista and Windows 7. The Hot key API won't allow you to register against default hot keys like Win+E, alt+F4 etc, but most other combination are accepted.
The article is for the .Net language 1.0 and up, but since it uses API calls, it can easily be modified for any mainstream language that can make Windows API calls, ie pretty much all of them.
精彩评论