|
-
Dec 16th, 2006, 12:03 AM
#1
Thread Starter
Frenzied Member
[2.0] A hopefully easy question about forms
Alright I would like to know how to approach having your form respond to keys pressed on the keyboard when the form is not active.
Here's an example. You know how some macro programs have press F8 or some key like that to start the current macro? And you can press F8 even when the window is not maximized or active! How would I do this? Here's all I want to know:
Question: When a form is minimized or just not active and you press F8 on the keyboard, how can I make a messagebox come up? I should be able to fiqure out the rest.
-
Dec 16th, 2006, 12:25 AM
#2
Re: [2.0] A hopefully easy question about forms
Here's some good information, plus a search for the appropriate terms will provide more.
-
Dec 16th, 2006, 01:13 AM
#3
Thread Starter
Frenzied Member
Re: [2.0] A hopefully easy question about forms
muchos gracios! works great
-
Dec 16th, 2006, 01:25 AM
#4
Thread Starter
Frenzied Member
Re: [2.0] A hopefully easy question about forms
wait.. i need ALL this code just to do this small simple thing? I cannot even put all the code in here! "The text that you have entered is too long (39630 characters). Please shorten it to 10000 characters long." Ouch. Well I'll try to shorten it
-
Dec 16th, 2006, 01:49 AM
#5
Re: [2.0] A hopefully easy question about forms
I haven't looked at the code involved but I very much doubt that you need that much. At a glance it looks like that article provides a class that wraps the interaction with the Windows API. If that's the case then the author has already done the hard work for you and all you need to do is create an instance of that class and access its members. The alternative is to declare the API functions yourself. That would still not take as much code as you mention because it would be specific to your situation, not for the general case as that author is trying to provide, but it would be more complex than simply using a single managed class.
-
Dec 16th, 2006, 02:03 AM
#6
Thread Starter
Frenzied Member
Re: [2.0] A hopefully easy question about forms
Yes but the thing is that this program will be processing so many keyboard buttons every single millisecond and often it makes the computer slow down as it is. If I had a lot more code then it'd probably crash the computer or something considering the memory use. There isn't just an easy way to make it so IF and application is running AND you press F8, THEN a MessageBox executes? I don't think doing just that should take that much.
-
Dec 16th, 2006, 07:20 PM
#7
Re: [2.0] A hopefully easy question about forms
 Originally Posted by Fromethius
There isn't just an easy way to make it so IF and application is running AND you press F8, THEN a MessageBox executes? I don't think doing just that should take that much.
That's being a bit naive. Why should every application be aware of the input to every other application? If that was the case then everything would always be slower because every application would have to process all input. In the grand scheme of things it's a rare thing for an application to have to respond to keyboard input when it's not active. There is a way to do it, and that way is with keyboard hooks.
I doubt that your user is pressing multiple keys per millisecond so this application of yours must be very unusual. To assume that something should be able to be done just because you want it to be is unrealistic.
I've never set a keyboard hook myself (because, like the majority, I've never had need) so I don't know everything that's involved but from what I do understand of it it should take thousands of lines of code. I think you need to look into it a bit deeper and understand exactly what is involved. As I said, you can find other relevant information by searching now that you know the correct key words to search for.
-
Dec 16th, 2006, 07:36 PM
#8
Thread Starter
Frenzied Member
Re: [2.0] A hopefully easy question about forms
Alright, and the REASON I am doing this is because I am making a macro program. And yea, I'll look into Keyboard hooks and I also did last night and it seems sooo freaking long. I can, no problem, get it to work right this minute, but is it really worth 40000 lines of code?
-
Dec 16th, 2006, 07:43 PM
#9
Re: [2.0] A hopefully easy question about forms
 Originally Posted by jmcilhinney
I've never set a keyboard hook myself (because, like the majority, I've never had need) so I don't know everything that's involved but from what I do understand of it it should take thousands of lines of code.
Oops. I badly misrepresented my case there. I actually meant that it should NOT take thousands of lines of code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|