PDA

View Full Version : Would it be possible to...


Rappa
08-05-2006, 02:59 AM
Hear me out, im not asking anyone to do anything, just asking if it is, in theory, possible.

Build an application in C# using timers to record the four arrow keys when they are pressed, and record how long each is pressed and then play it back on the screen. Like a macro. For Example:

Left arrow held: .033sec
Right arrow held: .2sec
up arrow held: .0038sec
left arrow: 1.2sec
right arrow: .0333sec

and then play it back on the users screen. Get it?

Is it possible? If so. Lot of work?

Zex
08-05-2006, 03:06 AM
Very possible, probably not that hard. The way I would do it is have a time_t variable before the key input that sets to the time before the key input, and then another one after the key input. Then probably set a variable in a structure.

Rappa
08-05-2006, 03:12 AM
well i have absolutley no idea what that could possible mean lol. example? possibly?

Brandoe85
08-05-2006, 03:16 AM
Use the key events:
http://www.codeguru.com/Csharp/Csharp/cs_syntax/anandctutorials/article.php/c5823/

For the time, check out the Timer class on msdn.

Good luck;

Zex
08-05-2006, 03:20 AM
Well maybe:

/*
* Basic time structures. <time.h> I do believe.
*/
float difference;
time_t start;
time_t end;

/* Get a time before the key is pressed */
gettimeofday( &start, NULL );

while( key_pressed )
{
<>
}

/* Get a time after the key is released */
gettimeofday( &end, NULL );
/* The difference in time values,
difference = end.tv_usec - start.tv_usec;

Now, I do apologize but I dont have too much console programming background, as far as the keypress situation I wouldnt know where to start, but maybe someone else may if you dont.

Rappa
08-05-2006, 03:23 AM
eh forget it ill never figure it out

Zex
08-05-2006, 03:27 AM
Heh, try not to get discouraged. The hardest part is figuring out how exactly everything works. gettimeofday( &time, NULL ) sets time to the time at which the function was executed. By getting a time before and after the keypress, we gain the ability to find out how long the key was down by simply subtracting the start time from the finish time.

Brandoe85
08-05-2006, 03:38 AM
Use the key events:
http://www.codeguru.com/Csharp/Csharp/cs_syntax/anandctutorials/article.php/c5823/

For the time, check out the Timer class on msdn.

Good luck;

It's not hard, if you want to learn, read.

Good luck;

Rappa
08-05-2006, 04:18 AM
ok, i will. Ill get back to you guys

Rappa
08-05-2006, 04:41 AM
well i read it but i really didnt understand it fully. i have no idea how to tie that in with recording

nmaj
08-05-2006, 12:46 PM
Hi....

newbie here.....

Don't actually have formal programming course.... hoping to learn more from here....

Thanks to all...

Brandoe85
08-05-2006, 06:00 PM
Use the KeyDown and KeyUp Event. When the KeyDown event fires start the timer, when the KeyUp event fires stop it. Doe that help?

Good luck;

Rappa
08-05-2006, 06:07 PM
yes it does i just have to figure out how to do that now.

Rappa
08-07-2006, 08:46 PM
how would i do that?