Systemweiter Keyboard-Hook

From: Lutz Winkler (lutz_winkler_at_t-online.nospam.de)
Date: 01/11/05


Date: Tue, 11 Jan 2005 18:51:55 +0100

Nach langen Recherchen habe ich endlich eine Möglichkeit gefunden, unter VB
eine systemweite Tastatur-Abfrage zu implementieren:

Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA"
(ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal
dwThreadId As Long) As Long
Private Const WH_KEYBOARD_LL = 13&
....
    hHook = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf KeyboardProc,
App.hInstance, App.ThreadID)
....
Public Function KeyboardProc(ByVal idHook As Long, ByVal wParam As Long,
ByVal lParam As Long) As Long
.... Hier können alle systemweit aufgetretenen Keyboard-Ereignisse
abgefangen werden.

So weit - so gut.
Funktioniert prima. Blöderweise aber nur unter WinXP!
Da gibt hHook das korrekte Handle zurück, unter Win98 nur 0 !
Prinzipiell kann ich unter Win98 mit dieser Funktion auch eine einen
Keyboard-Hook installieren, wenn ich an SetWindowsHookEx nicht
WH_KEYBOARD_LL sondern WH_KEYBOARD (2&) übergebe. Leider funktioniert der
Hook dann aber nur für das aufrufende Programm und nicht systemweit!

Kennt jemand einen Workaround? Kann ich durch ein Update Win98 eventl. doch
noch das korrekte Verhalten beibringen?



Relevant Pages

  • Re: Window on top mit Focus
    ... SendMessage lngDialog, WM_SETTEXT, 0, ByVal strDateiname ... > ByVal hwnd As Long _ ... > Private Declare Function GetSubMenu _ ...
    (microsoft.public.de.excel)
  • Re: Datei vom Filesystem auf FTP Server kopieren
    ... Private Const FTP_TRANSFER_TYPE_UNKNOWN = &H0 ... ByRef hInet As Long _ ... ByVal hInternetSession As Long, _ ... ByVal sServerName As String, _ ...
    (microsoft.public.de.excel)
  • Re: Datei vom Filesystem auf FTP Server kopieren
    ... > Private Declare Function InternetCloseHandle _ ... > ByRef hInet As Long _ ... > ByVal hInternetSession As Long, ... > ByVal sServerName As String, ...
    (microsoft.public.de.excel)
  • Re: A97 - registry auslesen mit Hauptbenutzerrechten
    ... lpSecurityDescriptor As Long ... "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ... Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias ... "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal ...
    (microsoft.public.de.access)
  • Re: Excel Programmierung im Tabellen - Tutorialdesign
    ... ByVal lpClassName As String, _ ... Private Declare Function FindWindowEx _ ... ByVal hWnd1 As Long, ByVal hWnd2 As Long, _ ... DeleteObject mlngRegion1 ...
    (microsoft.public.de.excel)