Sometime ago I developed a small app for myself that would send a series of key strokes to another app based on the contents of a file. It worked very well. Sadly today I am unable to recreate this app. for some unknown reason.
I have a very basic hook app which monitors for a particular key press combo. ie ALT & F12 (Whatever). This then opens a file that contains the keys I want to pass to another app. The purpose is to make life easy for myself by automation of repetitive tasks.
My problem is that when I capture the key combo and it runs the appropriate procedure, I get double entry of what is meant to be passed via the Keybd_Event.
Im not sure I am calling the proc in the correct place and I dont recall how I overcome this issue years ago.
The following (shortened) is what I have which does work but its sending twice.
What do I need to do to recieve '123' in (for example) notepad, or Excel. I dont want '123123'
' This will be dragged from a text file later
keybd_event VK_1, 0, 0, 0
keybd_event VK_1, 0, KEYEVENTF_KEYUP, 0 ' 1
keybd_event VK_2, 0, 0, 0
keybd_event VK_2, 0, KEYEVENTF_KEYUP, 0 ' 2
keybd_event VK_3, 0, 0, 0
keybd_event VK_3, 0, KEYEVENTF_KEYUP, 0 ' 3
' I have all the correct Decs in place
Public Function LowLevelKeyboardProc(ByVal uCode As Long, ByVal wParam As Long, lParam As KBDLLHOOKSTRUCT) As Long
If uCode >= 0 Then
If lParam.vkCode = VK_END Then 'simplicity till the details are sorted.
LowLevelKeyboardProc = 1
LowLevelKeyboardProc = CallNextHookEx(hHook, uCode, wParam, lParam)