發表文章

目前顯示的是 3月, 2015的文章

(C#) 滑鼠連點兩下的時間間隔

圖片
今天要來跟大家介紹,滑鼠連點兩下要花多少時間,電子產品都有極限,滑鼠也一樣。 那要怎麼樣才能抓到滑鼠的數值呢? 接下來就給大家示範用C#調出滑鼠的時間間隔 首先開啟一個Windows Form 應用程式 接著在程式碼中加入以下程式碼片段(namespace可以改成你的名稱,Label負責顯示) using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Runtime.InteropServices;//DllImport要加這行 namespace MouseClick {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();         }         [DllImport("user32.dll", EntryPoint = "GetDoubleClickTime")]         public extern static int GetDoubleClickTime(); //回傳int,以毫秒為單位         private void Form1_Load(object sender, EventArgs e)         {             label1.Text = GetDoubleClickTime() + "毫秒";//顯示連按兩下滑鼠的時間間隔         }     } } 接下來點F5開始就完成啦,是不是很簡單呢? 參考資料: 指定進入點 https://msdn.microsoft.com/zh-tw/library/f5xe74x8(v=vs.110).aspx