vb.net-use USB pushbutton to trigger windows form button

S

srussell

Building program used for timing marathon "type" races. Developed
simple code that uses the forms timer1. When started it places count-
up timer displayed in textbox and works fine. Have a screen button
when pressed copies the current time at that very moment and pastes it
into another text box. I will develop the database engine later and
will have no problem with that, done it before. I want to use a remote
USB plunger button or even presentation IR button to trigger runners
as they cross the finish line. I want the remote button associated
with the form button so when plugger is pressed it does the same as
pressing the button on the screen. I used AcceptButton on form and
when you hit the enter key it does work. But while the race is going
on, someone will be inputing racers demographic info and the plunger
operation will run in the background. How can I assign, say,,, the
down-arrow key, similar to advance on powerpoint presentation, so when
the plunger is pressed the computer thinks it is the down arrow key,
presses the form button and copies and pastes the current time into
the text box, (then database, I can do that part). I just need some
code that says the down-arrow key on keyboard was pressed, and
associated screen button was fired.
Thanks a bunch
 
F

Family Tree Mike

You will want to use thie Windows API KeyboardHook(). There are many
examples of this searching google. However, this will catch keyboard events
by the user sitting at the terminal entering the demographic data, as you
described, if they hit the key you are trapping.

Your description glosses past how you are determining which runner has which
time. I'm not a runner, but getting the order of the runners seems as
important as getting the times.
 
S

srussell

You will want to use thie Windows API KeyboardHook().  There are many
examples of this searching google.  However, this will catch keyboard events
by the user sitting at the terminal entering the demographic data, as you
described, if they hit the key you are trapping.  

Your description glosses past how you are determining which runner has which
time.  I'm not a runner, but getting the order of the runners seems as
important as getting the times.





- Show quoted text -


Good question. As the runners cross the finish line a tear-off strip
on their shirt has their assigned number. When you cross the line and
the plunger is pressed, an volunteer person rips the number off the
shirt. A prepunched hole allows them to place the small strip on a
hanger (open coat hanger) Imagine the first persons tag is first on
the hanger, then the second and so on. As the race is going on someone
take the strips to a computer operator and he types in number starting
with the first strip on the hanger. The database has three tables, one
with the plunger times as the person crosses the line, second with the
strips in order and third with the demographics with the person
assigned the tag. When you run the database report it shows the first
time (1:15:356), the first tag (121) on the hanger and that tag is
associated with the person (Joe Blow is 121) and he is the winner
(1:17:22) (215), etc.We have a DOS based software that is NOT user
friendly BUT WORKS GREAT and I think I can do a windows form much
better. The plunger is attached to a serial port and I'm trying to
come up with a USB port button, which has turned out to be the hard
part because of "switch bounce" in most plunger buttons. An IR
presentation button may work but I need to assign the down-key to the
form button.
 
M

mg

The plunger is attached to a serial port and I'm trying to
come up with a USB port button, which has turned out to be the hard
part because of "switch bounce" in most plunger buttons. An IR
presentation button may work but I need to assign the down-key to the
form button.

You might have a look at something like the Digi-Bee

http://www.pc-control.co.uk/digibee_info.htm

I have used the Mini-Bee for a timing bell sounder and it works well.
It comes with a DLL that is easy to to get going in your application.

Just out of curiosity,
-are the start/finish lines in the same place?
-is a form timer over an hour or two accurate enough?
 
S

srussell

You might have a look at something like the Digi-Bee

http://www.pc-control.co.uk/digibee_info.htm

I have used the Mini-Bee for a timing bell sounder and it works well.
It comes with a DLL that is easy to to get going in your application.

Just out of curiosity,
-are the start/finish lines in the same place?
-is a form timer over an hour or two accurate enough?


I use the "marathon" as only a way to describe the "race" Actually it
is more in line with 4K, 8K 10K races. For the most part the timed
portion is more like 45 minutes or less. At this time I have not
really tested the accuracy over this length. I'm trying to get the
mechanics done first and then look at which mode will be best. I know
I can get accuracy at the end of the day but if I cant figure out how
to get all of the other functions working, it will have been a waste
of time. Below is the simple code. If anyone has a better suggestion,
PLEASE let me know.
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer2.Tick

Dim I, J, K As Int32

J = CType(TextBox1.Text.Substring(3, 2), Integer)

K = CType(TextBox1.Text.Substring(0, 2), Integer)

' L = CType(TextBox1.Text.Substring(0, 2), Integer)

If J Mod 59 = 0 And J > 0 Then

K += 1

TextBox1.Text = Format(K, "00") & ":00"


Console.WriteLine(TextBox1.Text & " , " &
Now.ToLongTimeString & " , " & (I + 1).ToString)

Else

J += 1

TextBox1.Text = Format(K, "00") & ":" & Format(J, "00")

End If

End Sub

Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

TextBox1.Text = "00:00:00"

Timer2.Start()

End Sub


Private Sub TextBox1_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles TextBox1.TextChanged

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
TextBox1.SelectionStart = 0
TextBox1.SelectionLength = TextBox1.Text.Length

If TextBox1.SelectionLength > 0 Then
TextBox1.Copy()
TextBox2.Paste()
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top