public delegate int GetMsgProc(int nCode, int wParam, ref Message msg);
private IntPtr HookHandle;
private GetMsgProc ProcessMessagesCallback;
IntPtr hInstance;
IntPtr form;
IntPtr ThreadID;
private void SetHook()
{
int PiD = 0;
form = FindWindow("ThunderRT6FormDC", " ");
IntPtr hInstance = (IntPtr)Win32.User32.GetWindowLong(form, Win32.User32.GWL_HINSTANCE);
ThreadID = (IntPtr)Win32.User32.GetWindowThreadProcessId(msvb_tool, ref PiD);
WinInputHook hook = new WinInputHook(form , ThreadID, hInstance);
}
class WinInputHook : IDisposable
{
public delegate int GetMsgProc(int nCode, int wParam, ref Message msg);
/// Handle for the created hook.
private readonly IntPtr HookHandle;
private readonly GetMsgProc ProcessMessagesCallback;
public WinInputHook(IntPtr whnd, IntPtr theadID, IntPtr inst)
{
int it = theadID.ToInt32();
// Create the delegate callback:
this.ProcessMessagesCallback = new GetMsgProc(ProcessMessages);
// Create the keyboard hook:
this.HookHandle = SetWindowsHookEx(HookId.WH_CALLWNDPROC, this.ProcessMessagesCallback, inst, it); // . HookHandle = 0 .
}
private int ProcessMessages(int nCode, int wParam, ref Message msg)
{
MessageBox.Show("URA!!!"); //
}
}
? ? WM_INITDIALOG, =) , ... , . , hook .