Hi, I'm feeling fustrated. I have hours looking for a good code to capture the keypress events in any windows no matter if my application is focused or not. I need to create an application to work in background to capture the F2 key.
I found this example but I can't make it work:
I don't know what to do with the code colored in RED shown below, this is the part that doesn't work.
----------------------------
Implements IMessageFilter
Const WM_KEYDOWN As Integer = &H100
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Application.AddMessageFilter(New MyAppFilter)
End Sub
Public Function PreFilterMessage(ByRef m As System.Windows.Forms.Message) As Boolean Implements System.Windows.Forms.IMessageFilter.PreFilterMessage
Question
daniel_rh
Hi, I'm feeling fustrated. I have hours looking for a good code to capture the keypress events in any windows no matter if my application is focused or not. I need to create an application to work in background to capture the F2 key.
I found this example but I can't make it work:
I don't know what to do with the code colored in RED shown below, this is the part that doesn't work.
----------------------------
Implements IMessageFilter
Const WM_KEYDOWN As Integer = &H100
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Application.AddMessageFilter(New MyAppFilter)
End Sub
Public Function PreFilterMessage(ByRef m As System.Windows.Forms.Message) As Boolean Implements System.Windows.Forms.IMessageFilter.PreFilterMessage
Select Case m.Msg
Case WM_KEYDOWN
Select Case m.WParam.ToInt32
Case Keys.F8
MsgBox("")
End Select
End Select
End Function
Edited by daniel_rhLink to comment
Share on other sites
2 answers to this question
Recommended Posts