Node.JS: Wakeup screensaver? - node.js

How do I get node.js to wake up my screensaver and return to my desktop after it goes off?
I've tried the following:
const robot = require("robotjs");
...
//Simulate an "enter" keypress
robot.keyTap("enter");
console.log("enter simulate");
..
//Move the mouse a certain distance
robot.moveMouse(10,10);
console.log("mouse move simulate");
..
//Simulate a mouse left click
robot.mouseClick();
console.log("mouse left click simulate");
Basically I have a timer where one of these functions gets executed after the timer goes off, but the screen saver still stays on (Windows 11).
It works if I preview the screensaver, but when the screensaver automatically comes on and I execute one of these functions after the timer goes off, it remains on...

Related

Disable mouse hover event on Windows globally without blocking mousemove

I've made a Node/AutoHotKey script to control two computers with one mouse. I've made the cursor disappear on the first computer when using the second computer (https://www.autohotkey.com/boards/viewtopic.php?t=6167), but the mouseover event is still firing of course.
What I mean is simply if you hover over some icons on the desktop you will see tooltips, and so on.
I'm using a graphics tablet (absolute positioning), the cursor position gets captured and sent to the second computer.
I've found this method:
Found it here: https://www.autohotkey.com/boards/viewtopic.php?t=33128 (Also from the documentation: https://www.autohotkey.com/docs/commands/BlockInput.htm)
BlockInput, MouseMove ;to disable mouse interaction
BlockInPut, MouseMoveOff ;to enable mouse interaction
But it blocks mousemove completely, so that the cursor stops moving at all.
Is there any way to programmatically disable/enable mouseover (so that buttons don't change their color and tooltips don't appear, but AutoHotKey could still capture cursor position) event globally on Windows without blocking mousemove?

Mouse gets stuck in "drag and drop mode" when I break into the debugger during a drag and drop operation

I have this weird problem. I'm writing a GUI app in Qt and I have a crash during a drag and drop operation. If I run this app in a debugger, then when this crash occurs and the app breaks into the debugger, the mouse cursor gets stuck in "drag and drop mode" and I can't click on anything until the app is killed. How can i get around that?
Your app crashes in a GUI thread. Try to move the operations you are doing there to a new thread.
On your DragDrop event:
start a new thread doing your job
return from your event without waiting for results
I have the same issue.
I found that when a breakpoint was hit when mouse is dragging or mouseDown, GUI will get stuck and mouse will become unable to response.
For example:
A. Drag&Drop
1) Eclipse SWT: create Drag and Drop for a control
2) set breakpoint within dragging
B. Mouse Down & Mouse Up
1) use mouse down / mouse up to implement behavior of Drag&Drop
2) set breakpoint to dragging action/mouse moving
The mouse will stuck when breakpoint occurred, no matter which DnD happened.
To get mouse back, I'll need to use CTRL+ALT+F1 and use command to kill my process.
Perhaps working in VM or remote desktop can get rid of it.

Xtst and usleep

I'm using the Xtst extentsion to type and do stuff using the mouse
I have not encoutnered any problems untill I started using xtst to move and click the mouse.
for example, here's a set of action:
move 359,216 & click (XTestFakeMotionEvent(display,-1,359,216,0);)
move 378,213 & click
move 376,391 & click
type amousa1990#gmail.com, adel_ahmed#something.com (the string is broken down into characters and then XTestFakeKeyEvent(display, keycode, True, 0); this code has been working fine for the past couple of months, til I started using mouse movements and clicks
move 438,727 & click
plenty of other clicks
what happens is all mouse movements work fine, the typing events are not sent/synced
unless I use usleep of:
100 before each letter typed
500 before each click
700000 before each mouse movements
mouse movement usleeps are slowing down the app severely
the code is as follows for mouse movement:
XFlush(display);
usleep(700000);
XTestFakeMotionEvent(display,-1,x_coordinate,y_coordinate,0);
XFlush(display);
XCloseDisplay(display);
should I keep the display open and use a pointer instead(I'm calling these functions within a function)
should I flush more/less often
thanks
I think keyboard Auto repeat settings in your desktop environment, may have an impact on the behaviour of the program

Three.js First Person Controls moves the camera all the time

The game I'm designing currently requires a first person controller and luckily Three.js offers that class as well.
However I can't stop the camera from flying around. I know that the mouse movement causes the fly because it happens as soon as I move the mouse. But reading the js code,I cant find the attribue which causes this movement. Here is how I initiate the controls:
controls = new THREE.FirstPersonControls(camera);
controls.movementSpeed = 0.1;
controls.lookSpeed = 0.001;
controls.lookVertical = true;
I do not want the view direction to change when I am not moving the mouse.
any idea ?
Keep in mind that the FPS style mouse movement in webGL is usable rather only in a full screen mode. If an application runs in a standard windowed mode, the cursor is visible, and the application can not detect cursor movements that cross the edge of the window. This makes it impossible to look around in the FPS style (look movement stops when the cursors reaches the window edge).
This is probably the main reason why a PointerLockControls demo asks you to switch to the full screen mode.
With FirstPersonControls the look movement continues when the mouse reaches the edge. Such approach works well in the windowed mode.
You might want to use the PointerLockControls instead
See an example here:
https://github.com/mrdoob/three.js/blob/master/examples/misc_controls_pointerlock.html

how does gmail detect mouse movement?

if you are inactive on gmail, by not moving your mouse for a while, it changes your chat status to orange which means idle. but when you start moving the mouse again it turns it back to green meaning active. how does it know when you are moving your mouse?
without checking, I'd say this is done with an onmousemove event handler attached to the whole document.
You can attach an "onmousemove" event to the Javascript "document" object, which is triggered every time the mouse moves across the browser window. It's a simple task to reset a timer whenever this happens, and if the timer goes off without any movement detected, it will set your status to "idle". When the onmousemove function is next called, it will set your status back to "available".
Example with full code: http://www.codeguru.com/forum/archive/index.php/t-433956.html

Resources