|
-
Mar 7th, 2009, 03:35 PM
#1
Thread Starter
Addicted Member
[2008] Change button text noob question
Hi, Im using keyboard hook to get a key you push down, and when that key is up it adds the key as button1.text so if I push A button1.text = A what I am have trouble with is getting it to after Ive changed it to A add a + then the next button you push gets added in so
button1.text = "push to bind"
on button push
keyboardhook1.install
and on key press, it changes e.g
push a text of button = A
how can I make it so it getse like A and then I push another button and it gets that button too,
Ive been trying with 3 timers and 2 labels, but that doesnt seem to be working(1 timer is enabled if label1.text changes it disbles then enabled timer and the net key goes to label2.text, and button1.text = label1.text & label2.text)
thankyou
-
Mar 7th, 2009, 04:43 PM
#2
Re: [2008] Change button text noob question
You want the text of a button, to reflect which keys have been pressed, is that right?
Code:
Private Sub Form1_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
Button1.Text += Chr(e.KeyValue)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.KeyPreview = True
Button1.Text = String.Empty
End Sub
-
Mar 7th, 2009, 05:15 PM
#3
Thread Starter
Addicted Member
Re: [2008] Change button text noob question
hmm that works thankyou, would you be able to tell me how to use your code, but only work 2 times, e.g first time you push key it renames label1.text to it and secound time to label2.text Ive been trying since youve posted but I cant get it right 
thankyou
-
Mar 7th, 2009, 05:20 PM
#4
Re: [2008] Change button text noob question
ok, so to collect just two keys, set a variable or something like this;
Code:
Private Sub Form1_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
If NumKeys < 2 Then
Button1.Text += Chr(e.KeyValue)
NumKeys += 1
If NumKeys = 1 Then Label1.Text = Chr(e.KeyValue)
If NumKeys = 2 Then Label2.Text = Chr(e.KeyValue)
End If
End Sub
Dim NumKeys As Integer = 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.KeyPreview = True
Button1.Text = String.Empty
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|