er*****@nowhere.com (J French) wrote in message news:<3f***************@news.btclick.com>...
On 3 Jan 2004 01:24:07 -0800, sa**********@rediffmail.com
(ArulPrakash) wrote:
thank you J French. It worked out. I thought of hooking the keyboard
and all that complex stuffs.
Not just complex - also rather dangerous
Out of curiousity, how did you intercept the WM_HOTKEY message ?
- sub-classing or like KPD's interesting method
I just copied the example from KPD given and modified the key
combination to match my requirement.
But I already completed the exercise by hooking the keyboard and
tracing each and every key pressed onto a text box. I will get all the
keypress actions i a text box and check for my hot key. that too
worked out.
here is the window procedure i have return with hooking the keyboard:
Public Function WindowProc(ByVal hwnd As Long, ByVal Msg As Long,
ByVal wParam As Long, ByVal lParam As Long) As Long
Dim RetVal As Long
Dim KeyAscii As Long
Dim KeyName As String
If Msg = WM_USER Then
If (lParam And &H80000000) = 0 Then
If GetKeyboardState(KeyboardState(0)) <> 0 Then
RetVal = ToAscii(wParam, lParam, KeyboardState(0),
KeyAscii, 0)
If (RetVal = 1) And ((KeyAscii > 31) Or (KeyAscii = 13))
Then
If KeyAscii = 13 Then
Form1.Text1.Text = Form1.Text1.Text & "{ENTER}"
Else
Form1.Text1.Text = Form1.Text1.Text &
Chr(KeyAscii)
End If
Else
KeyName = String(20, " ")
RetVal = GetKeyNameText(lParam, KeyName, 20)
If RetVal <> 0 Then
KeyName = Left(KeyName, RetVal)
Form1.Text1.Text = Form1.Text1.Text & "{" &
KeyName & "}"
End If
End If
End If
Else
End If
End If
If (GetKeyState(VK_SHIFT) And &HF0000000) And
(GetKeyState(VK_CONTROL) And &HF0000000) And (GetKeyState(VK_F12) And
&HF0000000) Then
Form1.Combo1.Text = Form1.Combo1.List(0)
Form1.Show
End If
WindowProc = CallWindowProc(PrevFuncPointer, hwnd, Msg, wParam,
lParam)
Exit Function
End Function
I made use of the API function "SetWindowsHookEx" and
"UnhookWindowsHookEx" and created a dll and used it in the exe. but i
had a problem that i have to register this exe in each and every
machine in the network and so on so i searched for another method to
assign hot key.
Any way thanks again J French.