From 760c6af302d171cb287c434a7abbbe23ac8d66a4 Mon Sep 17 00:00:00 2001 From: vCaesar Date: Sat, 12 Nov 2016 15:17:52 +0800 Subject: [PATCH] Update Mouse --- event/goEvent.h | 32 ++++++++----------- .../hook/darwin/{post_event_c.h => event_c.h} | 3 +- .../hook/darwin/{input_hook_c.h => hook_c.h} | 3 +- event/hook/darwin/{input_helper.h => input.h} | 0 .../darwin/{input_helper_c.h => input_c.h} | 4 +-- .../{system_properties_c.h => properties_c.h} | 3 +- .../windows/{post_event_c.h => event_c.h} | 3 +- .../hook/windows/{input_hook_c.h => hook_c.h} | 7 ++-- .../hook/windows/{input_helper.h => input.h} | 0 .../windows/{input_helper_c.h => input_c.h} | 3 +- .../{system_properties_c.h => properties_c.h} | 3 +- event/hook/x11/{post_event_c.h => event_c.h} | 3 +- event/hook/x11/{input_hook_c.h => hook_c.h} | 3 +- event/hook/x11/{input_helper.h => input.h} | 0 .../hook/x11/{input_helper_c.h => input_c.h} | 0 .../{system_properties_c.h => properties_c.h} | 3 +- mouse/goMouse.h | 6 ++-- robotgo.go | 21 ++++++++++-- 18 files changed, 50 insertions(+), 47 deletions(-) rename event/hook/darwin/{post_event_c.h => event_c.h} (99%) rename event/hook/darwin/{input_hook_c.h => hook_c.h} (99%) rename event/hook/darwin/{input_helper.h => input.h} (100%) rename event/hook/darwin/{input_helper_c.h => input_c.h} (99%) rename event/hook/darwin/{system_properties_c.h => properties_c.h} (99%) rename event/hook/windows/{post_event_c.h => event_c.h} (99%) rename event/hook/windows/{input_hook_c.h => hook_c.h} (99%) rename event/hook/windows/{input_helper.h => input.h} (100%) rename event/hook/windows/{input_helper_c.h => input_c.h} (99%) rename event/hook/windows/{system_properties_c.h => properties_c.h} (99%) rename event/hook/x11/{post_event_c.h => event_c.h} (99%) rename event/hook/x11/{input_hook_c.h => hook_c.h} (99%) rename event/hook/x11/{input_helper.h => input.h} (100%) rename event/hook/x11/{input_helper_c.h => input_c.h} (100%) rename event/hook/x11/{system_properties_c.h => properties_c.h} (99%) diff --git a/event/goEvent.h b/event/goEvent.h index ff6dedf..ecd90de 100644 --- a/event/goEvent.h +++ b/event/goEvent.h @@ -15,21 +15,21 @@ #include "../base/os.h" #if defined(IS_MACOSX) - #include "hook/darwin/input_helper_c.h" - #include "hook/darwin/input_hook_c.h" - #include "hook/darwin/post_event_c.h" - #include "hook/darwin/system_properties_c.h" + #include "hook/darwin/input_c.h" + #include "hook/darwin/hook_c.h" + #include "hook/darwin/event_c.h" + #include "hook/darwin/properties_c.h" #elif defined(USE_X11) //#define USE_XKBCOMMON 0 - #include "hook/x11/input_helper_c.h" - #include "hook/x11/input_hook_c.h" - #include "hook/x11/post_event_c.h" - #include "hook/x11/system_properties_c.h" + #include "hook/x11/input_c.h" + #include "hook/x11/hook_c.h" + #include "hook/x11/event_c.h" + #include "hook/x11/properties_c.h" #elif defined(IS_WINDOWS) - #include "hook/windows/input_helper_c.h" - #include "hook/windows/input_hook_c.h" - #include "hook/windows/post_event_c.h" - #include "hook/windows/system_properties_c.h" + #include "hook/windows/input_c.h" + #include "hook/windows/hook_c.h" + #include "hook/windows/event_c.h" + #include "hook/windows/properties_c.h" #endif #include @@ -37,7 +37,6 @@ #include #include #include -// #include #include "hook/uiohook.h" int aStop(); @@ -69,11 +68,8 @@ bool logger_proc(unsigned int level, const char *format, ...) { } // NOTE: The following callback executes on the same thread that hook_run() is called -// from. This is important because hook_run() attaches to the operating systems -// event dispatcher and may delay event delivery to the target application. -// Furthermore, some operating systems may choose to disable your hook if it -// takes to long to process. If you need to do any extended processing, please -// do so by copying the event to your own queued dispatch thread. +// from. + struct _MEvent { uint8_t id; size_t mask; diff --git a/event/hook/darwin/post_event_c.h b/event/hook/darwin/event_c.h similarity index 99% rename from event/hook/darwin/post_event_c.h rename to event/hook/darwin/event_c.h index 75427f2..03ee62b 100644 --- a/event/hook/darwin/post_event_c.h +++ b/event/hook/darwin/event_c.h @@ -7,10 +7,9 @@ #include #include #include -// #include #include "../uiohook.h" -#include "input_helper.h" +#include "input.h" // #include "../logger_c.h" // TODO Possibly relocate to input helper. diff --git a/event/hook/darwin/input_hook_c.h b/event/hook/darwin/hook_c.h similarity index 99% rename from event/hook/darwin/input_hook_c.h rename to event/hook/darwin/hook_c.h index 15d8221..73b8517 100644 --- a/event/hook/darwin/input_hook_c.h +++ b/event/hook/darwin/hook_c.h @@ -14,10 +14,9 @@ #include #include #include -// #include #include "../uiohook.h" -#include "input_helper.h" +#include "input.h" // #include "../logger_c.h" typedef struct _hook_info { diff --git a/event/hook/darwin/input_helper.h b/event/hook/darwin/input.h similarity index 100% rename from event/hook/darwin/input_helper.h rename to event/hook/darwin/input.h diff --git a/event/hook/darwin/input_helper_c.h b/event/hook/darwin/input_c.h similarity index 99% rename from event/hook/darwin/input_helper_c.h rename to event/hook/darwin/input_c.h index f87507f..5a76d4f 100644 --- a/event/hook/darwin/input_helper_c.h +++ b/event/hook/darwin/input_c.h @@ -10,10 +10,10 @@ #include #endif #include -// #include + #include "../uiohook.h" -#include "input_helper.h" +#include "input.h" #include "../logger_c.h" // Current dead key state. diff --git a/event/hook/darwin/system_properties_c.h b/event/hook/darwin/properties_c.h similarity index 99% rename from event/hook/darwin/system_properties_c.h rename to event/hook/darwin/properties_c.h index 01b5402..7bf6c07 100644 --- a/event/hook/darwin/system_properties_c.h +++ b/event/hook/darwin/properties_c.h @@ -14,11 +14,10 @@ #include #endif #include -// #include #include "../uiohook.h" // #include "../logger_c.h" -#include "input_helper.h" +#include "input.h" UIOHOOK_API screen_data* hook_create_screen_info(unsigned char *count) { CGError status = kCGErrorFailure; diff --git a/event/hook/windows/post_event_c.h b/event/hook/windows/event_c.h similarity index 99% rename from event/hook/windows/post_event_c.h rename to event/hook/windows/event_c.h index ed1d113..84cf925 100644 --- a/event/hook/windows/post_event_c.h +++ b/event/hook/windows/event_c.h @@ -4,11 +4,10 @@ #endif #include -// #include #include "../uiohook.h" #include -#include "input_helper.h" +#include "input.h" // #include "logger.h" // Some buggy versions of MinGW and MSys do not include these constants in winuser.h. diff --git a/event/hook/windows/input_hook_c.h b/event/hook/windows/hook_c.h similarity index 99% rename from event/hook/windows/input_hook_c.h rename to event/hook/windows/hook_c.h index 53d1546..756308b 100644 --- a/event/hook/windows/input_hook_c.h +++ b/event/hook/windows/hook_c.h @@ -4,11 +4,10 @@ #endif #include -// #include #include "../uiohook.h" #include -#include "input_helper.h" +#include "input.h" // #include "logger.h" // Thread and hook handles. @@ -98,7 +97,7 @@ static void initialize_modifiers() { /* Retrieves the mouse wheel scroll type. This function cannot be included as - * part of the input_helper.h due to platform specific calling restrictions. + * part of the input.h due to platform specific calling restrictions. */ static unsigned short int get_scroll_wheel_type() { unsigned short int value; @@ -116,7 +115,7 @@ static unsigned short int get_scroll_wheel_type() { } /* Retrieves the mouse wheel scroll amount. This function cannot be included as - * part of the input_helper.h due to platform specific calling restrictions. + * part of the input.h due to platform specific calling restrictions. */ static unsigned short int get_scroll_wheel_amount() { unsigned short int value; diff --git a/event/hook/windows/input_helper.h b/event/hook/windows/input.h similarity index 100% rename from event/hook/windows/input_helper.h rename to event/hook/windows/input.h diff --git a/event/hook/windows/input_helper_c.h b/event/hook/windows/input_c.h similarity index 99% rename from event/hook/windows/input_helper_c.h rename to event/hook/windows/input_c.h index 372433c..f30463a 100644 --- a/event/hook/windows/input_helper_c.h +++ b/event/hook/windows/input_c.h @@ -8,12 +8,11 @@ #include #include #include -// #include #include "../uiohook.h" #include #include "../logger_c.h" -#include "input_helper.h" +#include "input.h" static const uint16_t keycode_scancode_table[][2] = { /* idx { vk_code, scancode }, */ diff --git a/event/hook/windows/system_properties_c.h b/event/hook/windows/properties_c.h similarity index 99% rename from event/hook/windows/system_properties_c.h rename to event/hook/windows/properties_c.h index 9c6beb8..28d92b7 100644 --- a/event/hook/windows/system_properties_c.h +++ b/event/hook/windows/properties_c.h @@ -3,12 +3,11 @@ #include #endif -// #include #include "../uiohook.h" #include // #include "logger.h" -#include "input_helper.h" +#include "input.h" // The handle to the DLL module pulled in DllMain on DLL_PROCESS_ATTACH. HINSTANCE hInst; diff --git a/event/hook/x11/post_event_c.h b/event/hook/x11/event_c.h similarity index 99% rename from event/hook/x11/post_event_c.h rename to event/hook/x11/event_c.h index f94056a..c2ff364 100644 --- a/event/hook/x11/post_event_c.h +++ b/event/hook/x11/event_c.h @@ -6,7 +6,6 @@ #include #include #include -// #include #include "../uiohook.h" #include #include @@ -14,7 +13,7 @@ #include #endif -#include "input_helper.h" +#include "input.h" // #include "../logger.h" extern Display *properties_disp; diff --git a/event/hook/x11/input_hook_c.h b/event/hook/x11/hook_c.h similarity index 99% rename from event/hook/x11/input_hook_c.h rename to event/hook/x11/hook_c.h index 9d22b0b..228863a 100644 --- a/event/hook/x11/input_hook_c.h +++ b/event/hook/x11/hook_c.h @@ -11,7 +11,6 @@ #include #endif #include -// #include #include "../uiohook.h" #include @@ -33,7 +32,7 @@ #endif // #include "../logger.h" -#include "input_helper.h" +#include "input.h" // Thread and hook handles. #ifdef USE_XRECORD_ASYNC diff --git a/event/hook/x11/input_helper.h b/event/hook/x11/input.h similarity index 100% rename from event/hook/x11/input_helper.h rename to event/hook/x11/input.h diff --git a/event/hook/x11/input_helper_c.h b/event/hook/x11/input_c.h similarity index 100% rename from event/hook/x11/input_helper_c.h rename to event/hook/x11/input_c.h diff --git a/event/hook/x11/system_properties_c.h b/event/hook/x11/properties_c.h similarity index 99% rename from event/hook/x11/system_properties_c.h rename to event/hook/x11/properties_c.h index f1a7f37..cbd8a67 100644 --- a/event/hook/x11/system_properties_c.h +++ b/event/hook/x11/properties_c.h @@ -6,7 +6,6 @@ #include #include #include -// #include #include "../uiohook.h" #include #ifdef USE_XKB @@ -29,7 +28,7 @@ static XtAppContext xt_context; static Display *xt_disp; #endif -#include "input_helper.h" +#include "input.h" // #include "../logger.h" Display *properties_disp; diff --git a/mouse/goMouse.h b/mouse/goMouse.h index 143cbf9..67a3021 100644 --- a/mouse/goMouse.h +++ b/mouse/goMouse.h @@ -81,9 +81,9 @@ MMPoint aGetMousePos(){ return pos; } -int aMouseClick(){ - MMMouseButton button = LEFT_BUTTON; - bool doubleC = false; +int aMouseClick(MMMouseButton button,bool doubleC){ + // MMMouseButton button = LEFT_BUTTON; + // bool doubleC = false; if (!doubleC){ clickMouse(button); diff --git a/robotgo.go b/robotgo.go index 806d92c..71d8a07 100644 --- a/robotgo.go +++ b/robotgo.go @@ -168,8 +168,18 @@ func GetMousePos() (int, int) { return x, y } -func MouseClick() { - C.aMouseClick() +func MouseClick(args ...interface{}) { + var button C.MMMouseButton + var double C.bool + Try(func() { + button = args[0].(C.MMMouseButton) + double = C.bool(args[1].(bool)) + }, func(e interface{}) { + // Println("err:::", e) + button = C.LEFT_BUTTON + double = false + }) + C.aMouseClick(button, double) } func MouseToggle(args ...interface{}) { @@ -382,6 +392,13 @@ func Convert(args ...interface{}) { ************ **** ************ **** **** **** */ +func AddEvent(aeve string) int { + cs := C.CString(aeve) + eve := C.aEvent(cs) + // Println("event@@", eve) + geve := int(eve) + return geve +} func LEvent(aeve string) int { cs := C.CString(aeve)