private int JournalRecordHook_Callback(int code, IntPtr wParam, IntPtr lParam, ref bool callNext) { if (code == HC_ACTION) { EVENTMSG em = (EVENTMSG)Marshal.PtrToStructure(lParam, typeof(EVENTMSG)); JournalMessage jm = JournalMessage.Create(em); if (RecordEvent != null) { RecordEvent(this, new JournalRecordEventArgs(jm)); } } else if (code == HC_SYSMODALON) { if (SystemModalDialogAppeared != null) { SystemModalDialogAppeared(this, new EventArgs()); } } else if (code == HC_SYSMODALOFF) { if (SystemModalDialogDisappeared != null) { SystemModalDialogDisappeared(this, new EventArgs()); } } return(0); }
private int JournalPlaybackHook_Callback(int code, IntPtr wParam, IntPtr lParam, ref bool callNext) { if (code == HC_GETNEXT) { callNext = false; int tick = Environment.TickCount; if (nextEventTime > tick) { return(nextEventTime - tick); } if (nextEvent == null) { nextEventTime = 0; nextEvent = GetNextJournalMessage(ref nextEventTime); if (nextEventTime <= tick) { if (nextEvent == null) { // shutdown the hook Unhook(); return(1); } nextEventTime = nextEvent.Time; } if (nextEventTime > tick) { return(nextEventTime - tick); } } // now we have the next event, which should be sent EVENTMSG em = (EVENTMSG)Marshal.PtrToStructure(lParam, typeof(EVENTMSG)); em.hWnd = nextEvent.HWnd; em.time = nextEvent.Time; em.message = nextEvent.Message; em.paramH = nextEvent.ParamH; em.paramL = nextEvent.ParamL; Marshal.StructureToPtr(em, lParam, false); return(0); } if (code == HC_SKIP) { nextEvent = null; nextEventTime = 0; } else if (code == HC_SYSMODALON) { SystemModalDialogAppeared?.Invoke(this, EventArgs.Empty); } else if (code == HC_SYSMODALOFF) { SystemModalDialogDisappeared?.Invoke(this, EventArgs.Empty); } return(0); }
internal JournalRecordEventArgs(JournalMessage msg) { this.msg = msg; }
private int JournalPlaybackHook_Callback(int code, IntPtr wParam, IntPtr lParam, ref bool callNext) { if (code == HC_GETNEXT) { callNext = false; int tick = Environment.TickCount; if (nextEventTime > tick) { return nextEventTime - tick; } if (nextEvent == null) { nextEventTime = 0; nextEvent = GetNextJournalMessage(ref nextEventTime); if (nextEventTime <= tick) { if (nextEvent == null) { // shutdown the hook Unhook(); return 1; } else { nextEventTime = nextEvent.Time; } } if (nextEventTime > tick) { return nextEventTime - tick; } } // now we have the next event, which should be sent EVENTMSG em = (EVENTMSG)Marshal.PtrToStructure(lParam, typeof(EVENTMSG)); em.hWnd = nextEvent.HWnd; em.time = nextEvent.Time; em.message = nextEvent.Message; em.paramH = nextEvent.ParamH; em.paramL = nextEvent.ParamL; Marshal.StructureToPtr(em, lParam, false); return 0; } else if (code == HC_SKIP) { nextEvent = null; nextEventTime = 0; } else if (code == HC_SYSMODALON) { if (SystemModalDialogAppeared != null) SystemModalDialogAppeared(this, new EventArgs()); } else if (code == HC_SYSMODALOFF) { if (SystemModalDialogDisappeared != null) SystemModalDialogDisappeared(this, new EventArgs()); } return 0; }