|
-
Aug 18th, 2012, 07:12 PM
#1
Thread Starter
Hyperactive Member
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
Last edited by useruseronline; Aug 18th, 2012 at 07:18 PM.
-
Aug 18th, 2012, 08:38 PM
#2
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
-
Aug 19th, 2012, 01:08 AM
#3
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)
-
Aug 19th, 2012, 10:09 AM
#4
Thread Starter
Hyperactive Member
Re: chr problem !!!
can u please give an example code ... how to but select case ...
-
Aug 19th, 2012, 11:07 AM
#5
Re: chr problem !!!
Post #3 is an example. What more do you need ?
-
Aug 19th, 2012, 11:18 AM
#6
Thread Starter
Hyperactive Member
Re: chr problem !!!
its not working .... thats why i asked for example
-
Aug 19th, 2012, 11:32 AM
#7
Re: chr problem !!!
What does 'its not working' mean ?
-
Aug 19th, 2012, 11:35 AM
#8
Thread Starter
Hyperactive Member
Re: chr problem !!!
it still gives blank symbol for enter key ..
-
Aug 19th, 2012, 11:41 AM
#9
Thread Starter
Hyperactive Member
Re: chr problem !!!
it still gives blank symbol for enter key ..
-
Aug 19th, 2012, 07:15 PM
#10
Thread Starter
Hyperactive Member
-
Aug 19th, 2012, 11:53 PM
#11
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.
-
Aug 20th, 2012, 01:58 AM
#12
Frenzied Member
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
-
Aug 20th, 2012, 02:32 AM
#13
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.
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
|