PDA

View Full Version : سوال: تعداد کلیک ماوس



hadi88
سه شنبه 12 اردیبهشت 1396, 02:31 صبح
باسلاممن برنامه زیر رو برای اینکه تعداد کلیک ماوس رو بشماره (حتی اگه کنترل خارج از برنامه باشه هم بتونه شمارش کنه) استفاده می کنم ولی تعداد کلیک رو نمیشماره.
هر یک از دوستان در این زمینه بتونه کمکم کنه ممنون میشم.
بااحترام



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.Diagnostics;
using System.Threading;
using System.Runtime.InteropServices;

namespace Index
{
public partial class Form1 : Form
{
int n;
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vk);
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern bool UnregisterHotKey(IntPtr hWnd, int id);
enum KeyModifier
{
None = 0
}
public Form1()
{
InitializeComponent();
int id = 0;
RegisterHotKey(this.Handle, id, (int)KeyModifier.None, Keys.LButton.GetHashCode());
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == 0x0312)
{
n = Convert.ToInt32(button1.Text);
n++;
button1.Text = n.ToString();
}
}
}
}