Hi
i want to calculate the delay and the duration of a keypress can
somebody help me with the code?
thank you in advance! :wave:
Printable View
Hi
i want to calculate the delay and the duration of a keypress can
somebody help me with the code?
thank you in advance! :wave:
If I'm understanding you correctly, you want the KeyboardDelay and KeyboardSpeed properties of the SystemInformation class, assuming WinForms. If that's not what you want then you'll need to provide a clearer explanation.
hi jmcilhinney
i want to calculate how much time in milliseconds a key from the
keyboard is pressed and the time between two keystrokes.
thank you :)
any help?
In that case, you can handle the KeyDown and KeyUp events. The time between a KeyDown and a KeyUp is the amount of time a key was depressed and the time between a KeyUp and a KeyDown is the amount of time between presses. You might use a Stopwatch, or you could just record the current time and subtract each time. Both events will tell you which key was involved. If you want to record separately for each key then you could use a Dictionary to record separate values for each key.
By the way, please don't bump your threads. If you don't have any new information to add or a new question to ask then don't post. Posts like "any help?" don;t achieve anything but moving your thread back to the top of the list, which is against forum rules.
following some of jmcilhinney's advices.. i did this:
i know my code is a bit of nonsense, but that's how far i could goCode:Public Class Form1
Dim StopWatchInstance As New System.Diagnostics.Stopwatch()
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
StopWatchInstance.Start()
End Sub
Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
StopWatchInstance.Stop()
Console.WriteLine(StopWatchInstance.Elapsed)
End Sub
End Class
with almost zero experience on VB net.
can somebody help me put things in an order? :)
What exactly is the problem? You're starting the Stopwatch when the key goes down and stopping it when the key goes up. That will measure time the key is depressed, and you're then displaying that time in the Output window. So, that's what you've got. What does it not do that you want it to do? What does it do that you don't want it to? It's your app so these are things that you must know, so you need to explain it to us.
Let's look at my previous post:Now let's look at your previous post:Quote:
What does it not do that you want it to do? What does it do that you don't want it to? It's your app so these are things that you must know, so you need to explain it to us.
Does that address what I posted? No, it doesn't. Please READ what's posted and if questions are asked, please ANSWER them.Quote:
it does nothing
when i press "start debugging" only a window pops up with the text box.
So, what exactly do you expect to happen? Firstly, you're handling the KeyDown and KeyUp events of TextBox1, so you will have to set focus to TextBox1 and press some keys. Secondly, you're sending the elapsed time to standard output, so to see it you must watch wherever standard output is being sent. Like I said, that should be the Output window. It is for me at least, although I have a feeling it can be the Intermediate window in some configurations.
Again, please make the effort to provide a FULL and CLEAR description of what you're trying to do, what you're actually doing and what happens. Just saying "it doesn't work" doesn't cut it. Imagine if someone took a car to a mechanic and said "it doesn't work" and the mechanic spent hours trying to find a problem, only to discover that the person wasn't turning the ignition key. You need to provide us with ALL the relevant information. Exactly what you expect to happen and exactly was does happen are always relevant.
there is a form with a text box in the middle, by double clicking with the mouse the text box
you can see the code i posted.
running the code the form appears and i can type in the text box
but other than that nothing else happens.
what i'm expecting to happen is to type a character and then see how
much time in milliseconds has passed since keydown/keyup.
if i manage to do that then what i want to do next is to figure out how am i going to make it
calculate the time in millisecond for words... (delay between keystrokes and duration of a keystroke)
i don't know how to complete the "Console.write" command
it is supposed i'm sending data to the output stream...
as i said i'm not an expert :(
Your level of expertise is irrelevant. I'm asking you what you expect. Where do you want to see the elapsed time? If you don't know you want then how can you possibly achieve it? If you don;t know what you want then how can you say that your code isn't working, because you don't know what it's supposed to do in the first place?
This is getting rather frustrating. Please stop and think. What do you want your application to do? How do you want the application to display the elapsed time. Only if you know what it's supposed to do can you make it do it. Only If we know what you want it to do can we help you make it do it. What exactly do you want your app to do? Please don't say that you want it to display the elapsed time because it's already doing that. How, where and in what manner do you want it to display the elapsed time?
ok so! what i did is the following... :)
now i can see the output of the timer to the msgbox while hoursCode:MsgBox("Time elapsed: " + StopWatchInstance.Elapsed.ToString)
StopWatchInstance.Reset()
ago i didn't knew how to use the "StopWatchInstance.Elapsed" and
i was always getting error messages.
i also added the "StopWatchInstance.Reset()" because without it
keeps counting.
so far so good!!!! :bigyello:
how am i going to proceed? since what i care to do is to count the
delay and duration of words and not just letters.