mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-31 06:13:55 +00:00
Update Mouse
This commit is contained in:
parent
686b47548b
commit
760c6af302
@ -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 <inttypes.h>
|
||||
@ -37,7 +37,6 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
// #include <uiohook.h>
|
||||
#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;
|
||||
|
@ -7,10 +7,9 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
// #include <uiohook.h>
|
||||
#include "../uiohook.h"
|
||||
|
||||
#include "input_helper.h"
|
||||
#include "input.h"
|
||||
// #include "../logger_c.h"
|
||||
|
||||
// TODO Possibly relocate to input helper.
|
@ -14,10 +14,9 @@
|
||||
#include <pthread.h>
|
||||
#include <stdbool.h>
|
||||
#include <sys/time.h>
|
||||
// #include <uiohook.h>
|
||||
#include "../uiohook.h"
|
||||
|
||||
#include "input_helper.h"
|
||||
#include "input.h"
|
||||
// #include "../logger_c.h"
|
||||
|
||||
typedef struct _hook_info {
|
@ -10,10 +10,10 @@
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
#include <stdbool.h>
|
||||
// #include <uiohook.h>
|
||||
|
||||
#include "../uiohook.h"
|
||||
|
||||
#include "input_helper.h"
|
||||
#include "input.h"
|
||||
#include "../logger_c.h"
|
||||
|
||||
// Current dead key state.
|
@ -14,11 +14,10 @@
|
||||
#include <IOKit/hidsystem/IOHIDParameter.h>
|
||||
#endif
|
||||
#include <stdbool.h>
|
||||
// #include <uiohook.h>
|
||||
#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;
|
@ -4,11 +4,10 @@
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
// #include <uiohook.h>
|
||||
#include "../uiohook.h"
|
||||
#include <windows.h>
|
||||
|
||||
#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.
|
@ -4,11 +4,10 @@
|
||||
#endif
|
||||
|
||||
#include <inttypes.h>
|
||||
// #include <uiohook.h>
|
||||
#include "../uiohook.h"
|
||||
#include <windows.h>
|
||||
|
||||
#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;
|
@ -8,12 +8,11 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
// #include <uiohook.h>
|
||||
#include "../uiohook.h"
|
||||
#include <windows.h>
|
||||
|
||||
#include "../logger_c.h"
|
||||
#include "input_helper.h"
|
||||
#include "input.h"
|
||||
|
||||
static const uint16_t keycode_scancode_table[][2] = {
|
||||
/* idx { vk_code, scancode }, */
|
@ -3,12 +3,11 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
// #include <uiohook.h>
|
||||
#include "../uiohook.h"
|
||||
#include <windows.h>
|
||||
|
||||
// #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;
|
@ -6,7 +6,6 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
// #include <uiohook.h>
|
||||
#include "../uiohook.h"
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
@ -14,7 +13,7 @@
|
||||
#include <X11/extensions/XTest.h>
|
||||
#endif
|
||||
|
||||
#include "input_helper.h"
|
||||
#include "input.h"
|
||||
// #include "../logger.h"
|
||||
|
||||
extern Display *properties_disp;
|
@ -11,7 +11,6 @@
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
// #include <uiohook.h>
|
||||
#include "../uiohook.h"
|
||||
|
||||
#include <X11/keysym.h>
|
||||
@ -33,7 +32,7 @@
|
||||
#endif
|
||||
|
||||
// #include "../logger.h"
|
||||
#include "input_helper.h"
|
||||
#include "input.h"
|
||||
|
||||
// Thread and hook handles.
|
||||
#ifdef USE_XRECORD_ASYNC
|
@ -6,7 +6,6 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
// #include <uiohook.h>
|
||||
#include "../uiohook.h"
|
||||
#include <X11/Xlib.h>
|
||||
#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;
|
@ -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);
|
||||
|
21
robotgo.go
21
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)
|
||||
|
Loading…
Reference in New Issue
Block a user