robotgo icon indicating copy to clipboard operation
robotgo copied to clipboard

how to hold key

Open mxyue opened this issue 5 years ago • 2 comments

how to hold the key and click mouse

like hold cmd and left click mouse

mxyue avatar Jan 16 '20 03:01 mxyue

on mac os, the code like this.

void ClickWithModify(CGEventFlags type) {
    CGEventRef click1_down = CGEventCreateMouseEvent(
      NULL, kCGEventLeftMouseDown,
      CGPointMake(250, 250),
      kCGMouseButtonLeft
    );
    // Left button up at 250x250
    CGEventRef click1_up = CGEventCreateMouseEvent(
      NULL, kCGEventLeftMouseUp,
      CGPointMake(250, 250),
      kCGMouseButtonLeft
    );

    CGEventSetFlags(click1_down, type);
    CGEventSetFlags(click1_up, type);

    CGEventPost(kCGHIDEventTap, click1_down);
    CGEventPost(kCGHIDEventTap, click1_up);

    CFRelease(click1_down);
    CFRelease(click1_up);
}

I found robotgo do this need change function, like: MouseToggle("left", "down", "cmd") Maybe

void toggleMouse(bool down, MMMouseButton button, CGEventFlags type){
	#if defined(IS_MACOSX)
		const CGPoint currentPos = CGPointFromMMPoint(getMousePos());
		const CGEventType mouseType = MMMouseToCGEventType(down, button);
		CGEventRef event = CGEventCreateMouseEvent(NULL,
							mouseType, currentPos, (CGMouseButton)button);
                CGEventSetFlags(event, type);
		CGEventPost(kCGSessionEventTap, event);
		CFRelease(event);
 ....

mxyue avatar Feb 08 '20 11:02 mxyue

is there any way to detect mleft mouse up ?

steelx avatar Mar 03 '20 08:03 steelx