开发者

realtime measurement of mouse click intervals

I'm writing a application[net/wpf/c#] that is supposed to measure how fast an user clicks (responds) after hearing a word. Its called a Auditory Processing Speed Test (PST) and the average human speed is around 70-140ms. To get an idea of the precision of events generated, I wrote the following.

public partial class MainWindow : Window
{
    System.Diagnostics.Stopwatch w = new System.Diagnostics.Stopwatch();

    public MainWindow () { InitializeComponent(); }

    private void textBlock1_PreviewMouseDown (object sender, MouseButtonEventArgs e)
    {
        e.Handled = true;
        w.Stop();
        System.Diagnostics.Debug.WriteLine(w.ElapsedMilliseconds);
        w.Reset(); w.Start();
    }

    private void Grid_KeyDown (object sender, KeyEventArgs e)
    {
        e.Handled = true;
        w.Stop();
        System.Diagnostics.Debug.WriteLine(w.ElapsedMilliseconds);
        w.Reset(); w.Start();
    }
}

private void Application_Startup (object sender, StartupEventArgs e)
{
    Process thisProc = Process.GetCurrentProcess();
    thisProc.PriorityClass = ProcessPriorityClass.RealTime;
    ProcessThreadCollection myThreads = thisProc.Threads;

    foreach (ProcessThread 开发者_Python百科pt in myThreads) {
        pt.PriorityLevel = ThreadPriorityLevel.TimeCritical;
    }
}

The fastest I can click is around 100ms, and if the keep the keyboard key depressed then down I get down to 30ms of response time. Is there any way I can make it faster? TIA


Have you considered polling the mouse via DirectInput.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜