- int x, y;
- DateTime start;
- public Form1()
- {
- InitializeComponent();
- x = Control.MousePosition.X;
- y = Control.MousePosition.Y;
- this.timer1.Enabled = true;
- this.timer1.Interval = 1000;
- }
- #region 判断鼠标在1分钟内是否移动
- bool ff = true;
- private void timer1_Tick_1(object sender, EventArgs e)
- {
- int x1 = Control.MousePosition.X;
- int y1 = Control.MousePosition.Y;
- if ((x == x1) && (y == y1) && ff)
- {
- start = DateTime.Now;
- ff = false;
- }
- if (x != x1 || y != y1)
- {
- x = x1;
- y = y1;
- start = DateTime.Now;
- ff = true;
- }
- TimeSpan ts = DateTime.Now.Subtract(start);
- //鼠标或键盘误动作1分钟后开始播放视频
- if (ts.Minutes >= 1)
- {
- //do something
- }
- }
winform 界面内判断鼠标在一分钟内是否移动

最新推荐文章于 2022-12-07 18:11:51 发布