May 20, 2015 07:22 PM
(This post was last modified: May 20, 2015 11:11 PM by CraftyDan.)
Hello,
I have been researching a way to record all keyboard and mouse input from the user without having the program in focus. I am trying to make my own hotkey program that i can use to automate a few things, and also create some macro's. So I would want the be able to access any keyboard input, and mouse movement(coordinates) plus any mouse buttons being pressed. From my research I have found a way to do this with dll injection. These are not preferable for me. I would just like my program to pickup any input and have it virtually press buttons are move and click the mouse. I have used other hotkey programs like G-Hotkey and AHK(To complicated for me) to do these task, so I know it can be done. I just need a way to do this in C++ if possible. Thanks for your time :).
Just to give another perspective. The Keylogger's that are in the hacking section find a way to record all keyboard inputs and what not. If anyone is familiar with one of those I would need a similar code.
Google c++ keyboard hooking. It will get you started in the right direction
DO NOT DEAL WITH THIS MEMBER
Record the macro:
Hook the target program's messages and record the params
Replay the macro:
send the recorded messages to the target program in same order
May 21, 2015 06:49 AM
(This post was last modified: May 21, 2015 07:37 AM by Motautronic.)
i would recomend you head over to www.pastebin.com and do a search in there. i could near guarantee, you will find yourself i nice example to get the ball rolling.
Code #include <iostream>
#include <fstream>
#include <windows.h>
#include <winuser.h>
using namespace std;
int main()
{
FILE *OUTPUT_FILE;
while(true)
{
for(int i = 8; i <= 190; i++)
{
if(GetAsyncKeyState(i) == -32767)
{
OUTPUT_FILE = fopen("log.txt", "a+");
fprintf(OUTPUT_FILE, "%s", &i);
fclose(OUTPUT_FILE);
}
}
}
return 0;
}
this is just to show how easy it is.
(May 21, 2015 06:49 AM)Motautronic Wrote: i would recomend you head over to www.pastebin.com and do a search in there. i could near guarantee, you will find yourself i nice example to get the ball rolling.
Code #include <iostream>
#include <fstream>
#include <windows.h>
#include <winuser.h>
using namespace std;
int main()
{
FILE *OUTPUT_FILE;
while(true)
{
for(int i = 8; i <= 190; i++)
{
if(GetAsyncKeyState(i) == -32767)
{
OUTPUT_FILE = fopen("log.txt", "a+");
fprintf(OUTPUT_FILE, "%s", &i);
fclose(OUTPUT_FILE);
}
}
}
return 0;
}
this is just to show how easy it is.
Not only is this using one of the worst methods, but that is also some of the most ugly C++ code I've seen.
Thanks for all the responses. I am currently doing more research and hopefully get my program up and running if I find what I am looking for. Thanks.
(May 21, 2015 12:35 PM)0xDEAD10CC Wrote: Not only is this using one of the worst methods, but that is also some of the most ugly C++ code I've seen.
Even thought I like the GetaSynckeymethod, I agree that's its probably the worst code ever written.
May 21, 2015 04:35 PM
(This post was last modified: May 21, 2015 05:00 PM by Motautronic.)
lol i never said it was beautiful (did you really expect to see a top of the line, fully featured key logger? even when the op clearly says its just a hotkey automation program), i was mearly showing how basic one can start from, and for the purpose it may be suitable its only a hotkey automation program, not a keylogger. i was hoping to plant the idea and get his mind going on getting more ideas.
but thanks for your comment, your assistance to the OP has been out standing. wheres your link? wheres you example? wheres your helpful input? im sure the OP appreciates my help and the ADVICE on how to be able to create his/her own script.
May 21, 2015 04:56 PM
(This post was last modified: May 21, 2015 05:09 PM by 0xDEAD10CC.)
(May 21, 2015 04:35 PM)Motautronic Wrote: lol i never said it was beautiful, i was mearly showing how basic one can start from, and for the purpose it may be suitable its only a hotkey automation program, not a keylogger. i was hoping to plant the idea and get his mind going on getting more ideas.
but thanks for your comment, your assistance to the OP has be out standing. wheres your link? wheres you example? wheres your helpful input? im sure the OP appreciates my help and the ADVICE on how to be able to create his/her own script.
It's not suitable at all. Do you know how that function works? This garbage infinite loop junk that can't hardly do anything else... Btw, because it's so resource consuming and unreliable that it's never going to be the best solution for what he wants, how do you possibly expect that he gets all the other mouse input at the same time too, in addition to automating other tasks with a loop like that? You clearly do not know... He isn't creating just a hotkey program, he wants to record all keyboard and mouse input to create macros and automate other tasks. The better solution would be to use a low level keyboard and mouse hook, because then you have the CPU time to construct the macros and/or automate other things at the same time.
If you call that "ADVICE" -- it certainly isn't worth paying attention to.
so where was the help earlier? look its like your trying to argue over me giving advice when you failed to provide any intelligent input previously.
and no there is nothng wrong with registerhotkey func, id hope the op would have done research just like they have said they have done and determined what is suitably best for the program. the op may have already decided it wasnt suitable and im not here trying to convince them into using it or trying to bullshit and say its a script of perfect that god farted out.
i dont have have time for this petty crap. enjoy your day :) best of luck OP
May 21, 2015 05:27 PM
(This post was last modified: May 21, 2015 05:30 PM by 0xDEAD10CC.)
(May 21, 2015 05:11 PM)Motautronic Wrote: so where was the help earlier? look its like your trying to argue over me giving advice when you failed to provide any intelligent input previously.
and no there is nothng wrong with registerhotkey func, id hope the op would have done research just like they have said they have done and determined what is suitably best for the program. the op may have already decided it wasnt suitable and im not here trying to convince them into using it or trying to bullshit and say its a script of perfect that god farted out.
i dont have have time for this petty crap. enjoy your day :) best of luck OP
The help earlier was pointing out that he/she should NOT be doing anything remotely like the code you posted. You aren't giving him advice, you're giving him bad information and poor code. The intelligent input would have been recognized by anybody who's been programming for longer than 2 days btw. 😉
The funny thing is that now you have nothing to defend your proposed "advice"... Seems like you just found a bit of code that you thought might work and decided to just throw it at the thread blindly. I throw in my own examples and help when I want, and point out what is good and bad all the other times. He was already given the best thing to research by post #2 of this thread, so I decided NOT to provide input of my own. With a bit of research he would have what he wants, and nothing like the shit you posted in here...
There's no point in suggesting a keyboard/mouse hook after it was already mentioned, so please explain your point here...? To me you just seem like another skid that would rather post something regardless of how good or bad it is, just to appear like you know what you're talking about... Trust me, I've seen it a million times whenever a "hello world" program question comes to these parts of the forum; everyone and their dog enjoys answering those, but the more difficult questions you don't see those same little script kiddies posting. :)
Chill people, Just asked for advice. Thanks for letting me know that function was recourse intensive and not practical, but no need in being an asshole. stop arguing. Any other advice would be helpful.
May 21, 2015 06:33 PM
(This post was last modified: May 21, 2015 08:05 PM by Motautronic.)
this post was initially removed out of respect for the of the op but since 0xDEAD10CC has replied to it, i thin it should go back (it will be just another thing for him try bitch about).
well thats just classic, before you even posted that i had already PMed the OP that this is exactly what you members do. ohhh and the inaccurate assumption's and even how ya think everyone is a skid. you did exactly that.
do you understand the expression "give a dog a bone", it was mearly a lead, somewhere for the op to start and your still crying over it. im not trolling and i wouldnt even bother to troll but you force trolling upon yourself from getting so worked up over a post. in the end the op decides whats best, im not holding a gun to his/her head.
and im not some young punk that just learnt how to turn a computer on. im over 35 and have had a computer obsession since i was about 7. i was around when the old Amstrad was my beasty computer that ran games from a freakin cassette tape.
there could even something that may come into factor depending on the op's situaton where registerhotkey and GetAsyncKeyState wont be a option. i do know of factors which will make registerhotkey not an option.
in the end just get over it, you are making this thread go to shit.
Edit: sorry for that late post, the site is running clunky today. i will not speak about that matter again
May 21, 2015 07:27 PM
(This post was last modified: May 21, 2015 07:35 PM by 0xDEAD10CC.)
(May 21, 2015 06:33 PM)Motautronic Wrote: well thats just classic, before you even posted that i had already PMed the OP that this is exactly what you members do. ohhh and the inaccurate assumption's and even how ya think everyone is a skid. you did exactly that.
do you understand the expression "give a dog a bone", it was mearly a lead, somewhere for the op to start and your still crying over it. im not trolling and i wouldnt even bother to troll but you force trolling upon yourself from getting so worked up over a post. in the end the op decides whats best, im not holding a gun to his/her head.
and im not some young punk that just learnt how to turn a computer on. im over 35 and have had a computer obsession since i was about 7. i was around when the old Amstrad was my beasty computer that ran games from a freakin cassette tape.
there could even something that may come into factor depending on the op's situaton where registerhotkey and GetAsyncKeyState wont be a option. i do know of factors which will make registerhotkey not an option.
in the end just get over it, you are making this thread go to shit.
Are you going to keep bullsh*tting, or are you actually going to support any of your statements with evidence? lol. Explain my inaccurate assumptions. :) You just sound like you're crying about being told your code and method was junk, and you can't defend against any of those claims others have made. Over 35 and your spelling is worse than my preschooler niece, nice. 🤝
Why are you talking about RegisterHotkey still? If you mention how some factors make it not an option, you clearly haven't provided them. Also, you mentioned a hotkey program which is why I mentioned that function. It's not suitable for what OP is trying to do. You posted code as though he was only looking for a simple hotkey program that does something upon specific key's... RegisterHotkey would have been 1000 times better than what you had for what you had intended as far as I see it, although your code is going to make performance go downhill along with reliability as soon as you introduce mouse tracking, macros, and automating other things... Are you implying that this can all happen within that infinite loop too, with maintaining the reliability of GetAsyncKeyState()? LOL!!
Yeah, this is going to turn out well... 😅
Code loop (GetAsyncKeyState())
{
// record mouse events
// save and replay macros (keyboard & mouse)
// automate other tasks...
}
Your presence here makes this thread go to shit... My first feedback was perfectly valid, and ^^ that is why.
1. The best suggestion you had was GetAsyncKeyState()
2. It was inefficient code to begin with, albeit it was already inefficient and CPU consuming before any code considerations
3. The only other thing you've done is cry about the criticism you'd received.
If the math adds up here, you sound like a 13 year old kid, not someone over 35... You must be new here. :)
are you freaking serious? it was just a state to show it get keystrokes. do you feel embarrassed by the way you are over reacting?
maybe i should have added "THERE ARE OTHER OPTIONS, SEEK AND YOU SHALL FIND" i really do apoligize if i ever at any time made him feel like i was giving him not alternative but to do what i say, or should i have held his hand while we went script shopping online?
sorry, as much fun as this has been i wont be checking in on this thread again. thank you all and have wonderful day :)
|