OSDN Git Service

double click
[winautomata/winautomata.git] / click.c
diff --git a/click.c b/click.c
index e0f68ed..b35288e 100644 (file)
--- a/click.c
+++ b/click.c
@@ -1,9 +1,11 @@
 #include <windows.h>
+#include <unistd.h>
 
 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
             PSTR lpCmdLine, int nCmdShow)
 {
     int button = 0; // 0:left 1:right 2:middle
+    int double_click = 0; // 0: single 1: double
 
     char buf[256];
     char* p2 = buf;
@@ -21,6 +23,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
             else if(strcmp(buf, "-middle") == 0) {
                 button = 2;
             }
+            else if(strcmp(buf, "-double") == 0) {
+                double_click = 1;
+            }
 
             if(*p == 0) break;
 
@@ -97,7 +102,14 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
         inputs[1].mi.dwExtraInfo = 0;
     }
 
-    SendInput(2, inputs, sizeof(INPUT));
+    if(double_click) {
+        SendInput(2, inputs, sizeof(INPUT));
+        usleep(50);
+        SendInput(2, inputs, sizeof(INPUT));
+    }
+    else {
+        SendInput(2, inputs, sizeof(INPUT));
+    }
 
     return 0;
 }