-
chr problem !!!
i use the following code for virtual key code conversion
Code:
If code = HC_ACTION And wParam <> 257 Then
CopyMemory kybd, ByVal lParam, Len(kybd)
Form1.Text1.Text = Form1.Text1.Text & Chr(kybd.vkCode)
myfunc = CallNextHookEx(Hook, code, wParam, lParam)
Else
If code = HC_ACTION And wParam <> 13 Then
CopyMemory kybd, ByVal lParam, Len(kybd)
Form1.Text1.Text = Form1.Text1.Text & "enter key"
ElseIf code < 0 Then
myfunc = CallNextHookEx(Hook, code, wParam, lParam)
End If
End If
but it does not give any symbol for key 13 (enterkey) , how to do it ???
i want it write enterkey instead of blank symbol
-
Re: chr problem !!!
I think you should replace
If code = HC_ACTION And wParam <> 13 Then
with
If code = HC_ACTION And wParam = 13 Then
-
Re: chr problem !!!
I think you should split the code up so it describes exactly what you want to do
Code:
If code = HC_ACTION Then
CopyMemory kybd, ByVal lParam, Len(kybd)
Select Case wParam
Case 13
Form1.Text1.Text = Form1.Text1.Text & "enter key"
Case Else
Form1.Text1.Text = Form1.Text1.Text & Chr(kybd.vkCode)
End Select
End If
myfunc = CallNextHookEx(Hook, code, wParam, lParam)
As far as I understand Virtual Key Codes are in the range 1 to &HFF (255) so there's no need to check for wParam to be greater than 256.
Using the Select Case construct enables you to easily add other 'special cases' if and when required (eg if the user has pressed F1 you wont see anything added to Form1.Text1.Text)
-
Re: chr problem !!!
can u please give an example code ... how to but select case ...
-
Re: chr problem !!!
Post #3 is an example. What more do you need ?
-
Re: chr problem !!!
its not working .... thats why i asked for example
-
Re: chr problem !!!
What does 'its not working' mean ?
-
Re: chr problem !!!
it still gives blank symbol for enter key ..
-
Re: chr problem !!!
it still gives blank symbol for enter key ..
-
Re: chr problem !!!
-
Re: chr problem !!!
There is no symbol for the enter key it is a control key for a carriage return.
The sample doogle posted would put the words "enter key" in your text box.
-
Re: chr problem !!!
Try the following !
Code:
If code = HC_ACTION And wParam <> 257 Then
CopyMemory kybd, ByVal lParam, Len(kybd)
Form1.Text1.Text = Form1.Text1.Text & Chr(kybd.vkCode)
myfunc = CallNextHookEx(Hook, code, wParam, lParam)
Else
If code = HC_ACTION And wParam = vbKeyReturn Then
CopyMemory kybd, ByVal lParam, Len(kybd)
Form1.Text1.Text = Form1.Text1.Text & "enter key"
ElseIf code < 0 Then
myfunc = CallNextHookEx(Hook, code, wParam, lParam)
End If
End If
-
Re: chr problem !!!
Actually, looking at the original Code I can't see how it works at all.
I assume the code is in a Keyboard Hook routine in which case wParam is the Virtual-key Code and lParam is the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag. (see: http://msdn.microsoft.com/en-us/libr...v=vs.85).aspx) I think I'm surprised that the IDE doesn't crash when the CopyMemory is executed.
In the original code in Post #1 (and the code in Post #12) the second If statement is only executed when HC_ACTION <> 0 or wParam = 257. Since wParam will never exceed 255 the second If statement will never be executed.