2010-11-18 112 views
1

我正在写一个应用程序[net/wpf/c#],它应该测量用户在听到单词后点击(响应)的速度。它被称为听觉处理速度测试(PST),人类的平均速度大约为70-140ms。为了了解生成的事件的精确性,我写了以下内容。实时测量鼠标点击间隔

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 pt in myThreads) { 
     pt.PriorityLevel = ThreadPriorityLevel.TimeCritical; 
    } 
} 

我可以点击最快的是100毫秒左右,如果保持压下键盘键再往下我坐下来的响应时间30毫秒。有什么办法可以让它变得更快吗? TIA

+0

PS:我的keyboad重复间隔设置为最高。 – user109134 2010-11-18 01:42:39

回答

1

你有没有考虑过通过DirectInput轮询鼠标。