|
-
May 19th, 2002, 09:47 PM
#1
Api to catch kestrokes
I need to catch keyboard input so i can then send information codes to programs so a Sanskrit font will be typed. We will programatically catch up to three keys for 1 sanskrit char, one key flagging tht there is a 3 key code coming. How to do through the Api as the catch must be in the backround while a word processing or page formating program is running as the active window. Tnakh you for your help and suggestions. [email protected]
-
May 20th, 2002, 02:03 AM
#2
Frenzied Member
If you are running Windows NT/2000/XP you can install a WH_KEYBOARD_LL hook with the SetWindowsHook API call.
HTH,
Duncan
-
May 22nd, 2002, 06:28 AM
#3
Hyperactive Member
Just a query duncan - will that set a global hook? I've read in many places that VB cannot set a global hook, but I'm still curious. I need to be told from a reputable API source... you.
-
May 22nd, 2002, 07:14 AM
#4
Frenzied Member
Generally speaking you can't implement a system wide hook in Visual basic, because you can't get an activeX dll injected into another application - you need a dll with an exports table for that...
However some global hooks occur in the operating system layer, specifically WH_KEYBOARD_LL, WH_MOUSE_LL and WH_JOURNALRECORD so they don't suffer from this restriction.
You can implement a global keyboard hook using the EventVB.dll thus:
(The syntax is a bit ugly - it's a work in progress...)
VB Code:
'\\ Form declarations
Private WithEvents apiLink As EventVB.ApiFunctions
Private WithEvents hook As EventVB.EnumHandler
'\\ Form load
Private Sub Form_Load()
Set apiLink = New EventVb.ApiFunctions
Set hook = apiLink.EventHandlerLink
hook.StartHook WH_KEYBOARD_LL,apiLink.AppModuleHandle, 0
End Sub
'\\ Form unload
Private Sub Form_Unload(Cancel As Integer)
hook.StopHook WH_KEYBOARD_LL
End Sub
Private Sub hook_HOOKPROCKEYBOARDLL(Action As EventVB.enHookCode, ByVal KeyState As Long, ByVal KeyStrokeInfo As EventVB.ApiKBDLLHOOKSTRUCT, lMsgRet As Long)
'\\ Tp prevent a message being passed on to the application,
'\\ set lMsgRet = 1
End Sub
HTH,
Duncan
-
May 22nd, 2002, 07:18 AM
#5
Frenzied Member
because you can't get an activeX dll injected into another application
Note that I am working on a way around this at the moment but it is proving very troublesome so it's not yet ready ...
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
|