enigo icon indicating copy to clipboard operation
enigo copied to clipboard

Double click

Open gcstr opened this issue 6 years ago • 2 comments

Is there a way to trigger double clicks? I tried sequencing enigo.mouse_click(MouseButton::Left) twice but with no results.

I only tested on macOS so far. Should it work on other platforms?

gcstr avatar Dec 16 '19 21:12 gcstr

I also ran into this

indianakernick avatar Jan 23 '21 06:01 indianakernick

Click events on macOS have a click count. A double click has a click count of 2. To create a double click, you need to emit a mouse-down and mouse-up with a click count of 1, then a mouse-down and mouse-up with a click count of 2. This SO answer describes how to do it in Objective-C.

This could be exposed on MouseControllable as a mouse_double_click function. Although that might not work in all cases. For example, if you're getting click events from somewhere, you would need to wait for the second click to arrive before you can decide whether it's a single or double click. Perhaps mouse_second_click would be better. It would send a mouse-down and mouse-up with a click count of 2. When you get a click event, you can send a mouse_click. If another click arrives within some time frame, send a mouse_second_click. It could be generalized to mouse_nth_click that would set the click count to whatever is given. That would make it possible to do triple clicks. On other platforms, this function would be the same as mouse_click.

indianakernick avatar Jan 24 '21 09:01 indianakernick

There is no need to do anything special anymore on macOS to trigger a double click. You just have to emit a second mouse click within the time to trigger double clicks. The default is 500ms.

pentamassiv avatar Mar 06 '23 17:03 pentamassiv