473,407 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Access and Keyhook? Will it work?

I have been playing with this code for a while and have yet to get it to work, in access. What am I doing wrong? My goal is to "hijack" they keyboard while I am running certian functions, then unhooking the keys at the end of my sub/function.

Expand|Select|Wrap|Line Numbers
  1. Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
  2. Public Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
  3. Public 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
  4. Public Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Long, lParam As Any) As Long
  5. Public Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
  6. Public Const HC_ACTION = 0
  7. Public Const WM_KEYDOWN = &H100
  8. Public Const WM_KEYUP = &H101
  9. Public Const WM_SYSKEYDOWN = &H104
  10. Public Const WM_SYSKEYUP = &H105
  11. Public Const VK_TAB = &H9
  12. Public Const VK_CONTROL = &H11
  13. Public Const VK_ESCAPE = &H1B
  14. Public Const VK_STARTKEY = &H5B
  15.  
  16.  
  17. Public Const WH_KEYBOARD_LL = 13
  18. Public Const WH_KEYBOARD = 13
  19. Public Const LLKHF_ALTDOWN = &H20
  20.  
  21. Public Type KBDLLHOOKSTRUCT
  22. vkCode As Long
  23. scanCode As Long
  24. flags As Long
  25. time As Long
  26. dwExtraInfo As Long
  27. End Type
  28.  
  29. Dim p As KBDLLHOOKSTRUCT
  30.  
  31. Function LowLevelKeyboardProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  32. Dim fEatKeystroke As Boolean
  33.  
  34. If (nCode = HC_ACTION) Then
  35. If wParam = WM_KEYDOWN Or wParam = WM_SYSKEYDOWN Or wParam = WM_KEYUP Or wParam = WM_SYSKEYUP Then
  36. CopyMemory p, ByVal lParam, Len(p)
  37. fEatKeystroke = _
  38. ((p.vkCode = VK_TAB) And ((p.flags And LLKHF_ALTDOWN) <> 0)) Or _
  39. ((p.vkCode = VK_ESCAPE) And ((p.flags And LLKHF_ALTDOWN) <> 0)) Or _
  40. ((p.vkCode = VK_ESCAPE) And ((GetKeyState(VK_CONTROL) And &H8000) <> 0)) Or _
  41. p.vkCode = VK_STARTKEY
  42.  
  43. End If
  44. End If
  45.  
  46. If fEatKeystroke Then
  47. LowLevelKeyboardProc = -1
  48. Else
  49. LowLevelKeyboardProc = CallNextHookEx(0, nCode, wParam, ByVal lParam)
  50. End If
  51. End Function
  52.  
  53.  
  54.  
Apr 12 '11 #1
0 1003

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Mark | last post by:
Hi - could anyone please tell me why this line: <td width="116" height="22" nowrap id="toptSearch" class="mtTabOnTop" onClick="changeLoc('fixit_proceduresresultstick.asp','search')">Search <img...
1
by: Lal - Luxor | last post by:
please help me. how to work object.move will work on ve.net regards lal
2
by: Money | last post by:
When we do this Test *ptr=new Test; then runtime memory manager will allocate 10*sizeof(Test) + X bytes(X varying from implementation to implementation) But instead if I call operator new...
4
by: alice | last post by:
I'm trying to get sounds to play on image mouseovers using dreamweaver 8, and I found out that the code it generates to do this only works for IE. Is there a way to do this so that it will work...
1
by: laziers | last post by:
Hi, What kind of data access you will use for the project with very large database : 1. NHibernate 2. Linq 3. Sql queries + stored procedures 4. DataSets
2
by: Damfino | last post by:
Hi all, Newbie question here wrt defining a class that will work on bits read from a binary file. How would you go about doing it? As an example please look at the structure of my data given...
1
by: Bergamot | last post by:
marss wrote: You may be trying to fix the wrong problem. Post a URL, then maybe we'll see a better way to accomplish whatever your goal is. -- Berg
2
by: Lori Phillips | last post by:
I need to create a macro in Access that will have a 10% discount and can't figure it out.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.