sidorares / node-x11

X11 node.js network protocol client
MIT License
518 stars 72 forks source link

Sending Button Events #199

Closed damodaranr closed 3 years ago

damodaranr commented 3 years ago

Can I please get an example of how to send button click events using X.SendEvent? It is quite confusing how to send the data through a node buffer through the node-x11 api for this method.

x11.eventMask.ButtonPress

Also, I tried to use the XTestFakeButtonEvent but that doesn't seem to be supported by this library.

https://linux.die.net/man/3/xtestfakebuttonevent

sidorares commented 3 years ago

XTest example here - https://github.com/sidorares/node-x11/blob/97e3600467279bf16f41e8fccf7b3250804f1eec/examples/smoketest/xtesttest.js#L9

damodaranr commented 3 years ago

Thanks for getting back quickly with that useful information. Was able to achieve mouse click at a desired location using the following snippet: var X = display.client; var root = display.screen[0].root; X.require('xtest', function(err, Test) { X.WarpPointer(0, root,0, 0, 0, 0, 1831, 38); Test.FakeInput(Test.ButtonPress, 1, 0, root, 0, 0); // space 65 Test.FakeInput(Test.ButtonRelease, 1, 0, root, 0,0); // space console.log('click'); });