Skip to content

Instant drag mouse #374

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

Closed
ricardopolo opened this issue Feb 18, 2022 · 6 comments
Closed

Instant drag mouse #374

ricardopolo opened this issue Feb 18, 2022 · 6 comments

Comments

@ricardopolo
Copy link

Any way to instant drag the mouse?
Like setPosition but whit button held?

In robotjs: http://robotjs.io/docs/syntax#dragmousex-y

@s1hofmann
Copy link
Member

Hi @ricardopolo 👋

no, at the moment this is not possible with nut.js

@s1hofmann s1hofmann mentioned this issue Feb 22, 2022
@s1hofmann
Copy link
Member

Hi @ricardopolo 👋

I just had a look at your mentioned example and tested it on macOS, where it actually does not work.
Could you please give an example of your usage + the OS you're on?

Otherwise I'll close this issue soonish.

@ricardopolo
Copy link
Author

It works in my case in windows. Basically I created a Remote Desktop like solution and move the remote computer using RobotJs. Would love to do it with Nut.js.

The instant drag is useful, as example, when dragging a file in windows explorer

@github-actions
Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label May 25, 2022
@s1hofmann
Copy link
Member

I’ll have a look on Windows specifically

@github-actions github-actions bot removed the stale label May 28, 2022
@s1hofmann
Copy link
Member

@ricardopolo I just did a double check on Windows, it works just fine.
The only difference is that mouse.drag in nut.js actually performs a smooth drag, so the right way to do it is:

  • Press and hold the correct mouse button
  • Set mouse position
  • Release the mouse button

See the following snippet:

const {mouse, Button, sleep} = require("@nut-tree/nut-js");

(async () => {
        await sleep(3000);
        const current = await mouse.getPosition();
        await mouse.pressButton(Button.LEFT);
        await mouse.setPosition({x: current.x + 500, y: current.y});
        await mouse.releaseButton(Button.LEFT);
})();

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

No branches or pull requests

2 participants