c# - Capture keystrokes (e.g., function keys) while a messagebox is up -


We have a large WinForms application, and there is an underlying bug reporting system that can be activated during testing through F5 Could Keys I'm capturing F5 key with Net's prefilter message system. It works fine on main forms, modal dialog boxes etc.

Unfortunately, this program also shows the Windows Message Box when it is required. When there is a bug with it, for example, the wrong text in the message box or it should not be there, the message filter is not executed at all when the messagebox is correct!

I know that I can fix it by regularizing my own messagebox, or by kicking a different thread that chooses GetAsyncKeyState and calls the error reporter from there. Although I was hoping for a method that was less than a hack. Here is the code that the problem appears:

  Public Class Form1 implementations IMessageFilter Personal Sub Form1_Click (ByVal handles Me.Click MsgBox as ByVal e System.EventArgs as this object) ("Now, a messagebox is up!") End Sub Personal Sub Form1_Load (ByVal handles this system.Object, as byVal E. System.EventArgs) MyBase.Load Application.AddMessageFilter (Me) End Sub Public Function PreFilterMessage (M. System.Windows.Forms.Message Form ByRef) _ Boolean Impacts as Imafefilter. Prefilter message conserve VK_F5 int 32 = & amp; Integer as H 74 CONST WM_KEYDOWN = & amp; H100 if m.msg = WM_KEYDOWN and m.WParam.ToInt32 = VK_F5 then takes a screenshot here in the 'reality code, saves the second end from the end function then the class  

iMess geFilter is a net attribute and the net message is brought by loop . Since MessageBox.Show native message loop (Runs inside MessageBox API call), IMessageFilter It is not called in it.

You need to hook a keyboard.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -