32 lines
803 B
C#
32 lines
803 B
C#
using System;
|
|||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Linq;
|
||
|
|
using System.Text;
|
||
|
|
using System.Threading.Tasks;
|
||
|
|
using System.Windows.Forms;
|
||
|
|
|
||
|
|
namespace JinYuan.Helper
|
||
|
|
{
|
||
|
|
public class InputMessageFilter : IMessageFilter
|
||
|
|
{
|
||
|
|
private Action onActivity;
|
||
|
|
|
||
|
|
public InputMessageFilter(Action onActivity)
|
||
|
|
{
|
||
|
|
this.onActivity = onActivity;
|
||
|
|
}
|
||
|
|
|
||
|
|
public bool PreFilterMessage(ref Message m)
|
||
|
|
{
|
||
|
|
// 鼠标移动(0x0200)、鼠标按下(0x0201)、键盘按下(0x0100)等
|
||
|
|
if (m.Msg == 0x0200 || m.Msg == 0x0201 || m.Msg == 0x0204
|
||
|
|
|
||
|
|
|| m.Msg == 0x0100 || m.Msg == 0x0101)
|
||
|
|
{
|
||
|
|
onActivity?.Invoke();
|
||
|
|
}
|
||
|
|
return false; // 不拦截消息,继续传递
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|