질문 : this 질문에서 언급했듯이 커서를 잠깐 동안 (예 : 3-5 초) 커서를 두 번 두 번 클릭하면 응용 프로그램에 기능을 구현하려고합니다. 해당 스레드에서 제공되는 응답에 따라 다음과 같이 썼습니다. 이 코드는 예상대로 작동하지 않습니다. 누군가 제발 도와 줄 수 있니?타이머를 사용하여 더블 클릭 이벤트 구현하기
#region Timer Mouse Double Click event
timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
//Here, the timer for Timer click event will start when mouse hovers over an area
private void form_MouseHover(object sender, System.EventArgs e)
{
timer.Start();
}
private void form_MouseLeave(object sender, System.EventArgs e)
{
timer.Stop();
}
void timer_Elapsed(object sender, ElapsedEventArgs e)
{
timer.Stop();
DoubleClickEvent();
}
//This method allows the user to click a file/folder by hovering/keeping still the mouse for specified time
void DoubleClickEvent()
{
DoClickMouse(0x2); // Left mouse button down
DoClickMouse(0x4); // Left mouse button up
}
static void DoClickMouse(int mouseButton)
{
var input = new INPUT()
{
dwType = 0, // Mouse input
mi = new MOUSEINPUT() { dwFlags = mouseButton }
};
if (SendInput(1, input, Marshal.SizeOf(input)) == 0)
{
throw new Exception();
}
}
[StructLayout(LayoutKind.Sequential)]
struct MOUSEINPUT
{
int dx;
int dy;
int mouseData;
public int dwFlags;
int time;
IntPtr dwExtraInfo;
}
struct INPUT
{
public uint dwType;
public MOUSEINPUT mi;
}
[DllImport("user32.dll", SetLastError = true)]
static extern uint SendInput(uint cInputs, INPUT input, int size);
#endregion
여기서 작동하지 않는 항목은 무엇입니까? – Tigran
더블 클릭 이벤트가 전혀 발생하지 않습니다! – ykombinator
나는 [Reactive Extensions] (http://stackoverflow.com/questions/5228364/reactive-framework-doubleclick)를 사용하여 제안을 제안합니다. –