I want to make a program that analysises which key has been pressed the most as a part of my school assignment. I want that the key input be recieved by my program and later by the program it was intended for. Is there a way to do this? Please describe with a sample piece of code if it is possible. Thanks in advance!
Yes it is possible. These types of programs are generally called "keyloggers".
You may Google to find out more about this kind of programs. For building one yourself in C/C++ for windows platform, you need to know windows API programming. For windows API tutorial check this out.
I wonder, how can this be a school assignment !
Thanks for the reply. Please can you guide me a bit on how to code it? And yes, it is indeed an assignment.
Posting requests for help must be well thought out if you want help quickly and correctly. Your post did not meet the criteria for quality help. You may get some posts, but are they going to be useful? Check your post with these checkpoints - what is it you missed:
- Ask a question that can be answered. Do not ask
-What's wrong with my code?
-Why doesn't this work?
-Anything else that does not give us useful information.
- Post your code. If we don't know what you did, how can we possibly help?
-Use PROPER FORMATTING -- see this
-Use CODE Tags so your formatting is preserved.
If we can't follow your code, it's difficult to help. We don't care that you're still working on it. If you want us to read it, it must be readable.
- Explain what the code is supposed to do. If we don't know where the target is, how can we help you hit it?
- Explain what actually happened! If we don't know where the arrow went when you shot it, how can we tell what went wrong and how far from the target you are?
- If you have errors, post them! We can't see your screen. We can't read your mind. You need to tell us what happened.
- Do not ask for code. We are not a coding service. We will help you fix your code.
-If anyone posts working code for you, they are a cheater.
-If you use that code you are a cheater.
- Do not bore us with how new you are. We can tell by your code.
-Do not apologize. We were all new, and unless you are completely brain dead you will get better.
-Do not ask us to "take it easy on you."
-Do not say "I don't know what's going on." That's obvious since you posted for help. Use that time wisely by explaining as best you can so we can help.
- Do not apologize for posting 'late'. We don't have any expectations on when you should be posting - 10 minutes or 10 days. We aren't timing your responses.
- Do not post your requirements and nothing else. We view that as a lazy do-nothing student that wants us to do their work for them. That's cheating and we will be hard on you.
- Do not attach files except when absolutely necessary. Most of us are not going to download files. Add the information to your post.
- Do not tell us how urgent it is. Seriously, for us there is no urgency at all. Many that can help will ignore any URGENT or ASAP requests.
- Create a good title for your post. The title C++ in the C++ forum is bloody redundant and worthless! What's wrong? equally so. Specifically what are you having trouble with? There is your title. (note: my program is not the answer.)
Think more about your next post so we don't have to play 20 questions to get the info we need to help you.