• winform 判断鼠标在一段时间内是否移动 分类: .NET 20120406 15:40 1236人阅读 评论(2) 收藏


            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
                }
            }


    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    RSA使用
    C#获取主机信息
    NSIS打包软件使用
    C#获取局域网主机
    C#实现Web链接启动应用程序
    4.布局介绍
    Server Sql 多表查询、子查询和分页
    C# File类常用方法
    Vue 使用技巧手记
    前端面试题手记
  • 原文地址:https://www.cnblogs.com/configman/p/4657593.html
Copyright © 2020-2023  润新知