Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help with Keyboard

Status
Not open for further replies.

dotnetprogrammer

Programmer
Aug 17, 2000
77
US
I need to write a keyboard remapping App using VB. Here is a description of it has to do:

When I type a+e, the "keyboard remapping program" has to generate æ (ASCII 0230) character instead. When I type o followed by two periods (.), those three keystrokes has to translate as ö (ASCII 0246), etc. (get the idea?).

When my "keyboard remapping program" is active, keystrokes made in any application (Word. Excel, etc.) will have to remap the keystrokes.

I think I have to use global KeyHook through Win API, but I am not sure how to do it.

MSDN probably has an example of such "KeyHook" API, and I could not figure out how to implement it.
Any help will be highly appreciated. [sig][/sig]
 
Keyhooks can really tie up a system.

You might try this:

Place a label and a timer control on a form to test it. Set the timer interval to some ridiculously low number (1).
[tt]
Private Sub Timer1_Timer()
Label1.Caption = GetInput
End Sub
[/tt]
At the module level:
[tt]
Private Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Long) As Integer

Public Function GetInput()
Dim i As Integer
For i = 0 To 255
If (GetAsyncKeyState(i) And &H8001) <> 0 Then
GetInput = i
Exit Function
End If
Next i
End Function
[/tt]

Then check your resources. Hopefully the app won't tie up the system too much.

Hope this is waht you were looking for....
[sig]<p> <br><a href=mailto: > </a><br><a href= plain black box</a><br>Don't sit down. It's time to dig another one.[/sig]
 
I'll have to take back part of my previous post. I just created a simple app that intercepts keystrokes and compares the last word typed against a list of offensive words. If there is a match, the app replaces the word with a bland euphemism.

It uses GetAsyncKeyState in a timer control with the interval set at 10 milliseconds. I closely monitored all resources before, during and after running the program and couldn't see a perceptible change.

Maybe the function would work well enough in fh's remapping app but changing the keystate before it reaches other apps (Wordpad, etc.) introduces many questions. Perhaps fh has already addressed them.
[sig]<p> <br><a href=mailto: > </a><br><a href= plain black box</a><br>Don't sit down. It's time to dig another one.[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top