Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for double click #24

Closed
navFooh opened this issue Apr 23, 2015 · 9 comments
Closed

Support for double click #24

navFooh opened this issue Apr 23, 2015 · 9 comments
Assignees
Milestone

Comments

@navFooh
Copy link

navFooh commented Apr 23, 2015

Hi Jason,

Is there any (plan for) support of double click in robotjs?
You'd say executing two sequential clicks should do it, but that doesn't work for me.
Also doing mouseToggle with "down", "up" twice just functions as a click.

Any experience with this? Double click would be quite nice.

Cheers, Thijs

@octalmage
Copy link
Owner

Hello,

I believe every OS has a limit to how fast it can receive events, and this is probably what you're running into.

Have you tried putting a delay between the two clicks?

I will probably add some support for a built in configurable delay at some point to help with this.

@octalmage
Copy link
Owner

#14 is related, I'll try to do some testing today.

@navFooh
Copy link
Author

navFooh commented Apr 28, 2015

I haven't had any luck putting a delay between the clicks unfortunately.
I'm triggering the events over a websocket server but I doubt that has anything to do with it
Hope you have more luck!

Cheers, Thijs

@octalmage
Copy link
Owner

I've done some testing and you're right, setting a delay doesn't work! It looks like some additional code is needed to double click on Mac, I'll work on getting this implemented now!

@navFooh
Copy link
Author

navFooh commented Apr 28, 2015

Thanks man, I'll be happy to help testing after!

@octalmage
Copy link
Owner

Using the code from here:

http://stackoverflow.com/questions/1483657/performing-a-double-click-using-cgeventcreatemouseevent/1483666#1483666

Specifically CGEventSetIntegerValueField I was able to get double click working in at least one app, but it doesn't work in Finder or Google Chrome. It's very strange. If you'd like to test, check out the doubleclick branch.

I've added a second parameter to mouseClick, so robot.mouseClick("left", true); does a double click. I'll keep working on it.

@navFooh
Copy link
Author

navFooh commented Apr 29, 2015

Sorry I've moved on to another project now and don't have much time at the moment.

Just thinking that with this implementation you'd have to set some kind timer after a click to wait for a possible double-click before triggering the mouse click event. This would make a normal click less responsive (in my case where I'm controlling the mouse from another machine).

If there's no other way to go about this, so be it. just a same that to sequential clicks don't register as a double click like normally in the OS.

@octalmage
Copy link
Owner

No worries.

Good point! I don't understand why there's a separate event for double clicks on Mac, that makes this difficult. I'm sure I'll find a better solution though.

@octalmage
Copy link
Owner

I got double click working in all apps on Mac, but unfortunately it will require a separate function, at least for now.

On Windows the double click delay is customizable, which would be an issue, but using GetDoubleClickTime we can accurately send a double click.

I'll submit a PR for this soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants