Is it possible to move the mouse so that it is positioned inside a text input using JavaScript?
You cannot move the actual mouse pointer in Javascript. You can, however move a pointer shaped image and pretend that you can. :-) Better yet, you can move a cat image around, following the mouse cursor, and try to use it to chase the cursor into the position you want.
To move the mouse on windows, you'd need to call the SetCursorPos function from the user32. dll like this: var ffi = require("ffi"); var user32 = ffi.
The clientX property returns the horizontal coordinate (according to the client area) of the mouse pointer when a mouse event was triggered. The client area is the current window. Tip: To get the vertical coordinate (according to the client area) of the mouse pointer, use the clientY property.
I don't know about moving the actual rendered mouse pointer, but could you just set the focus on the element?
document.getElementById('the_text_input_id').focus()
Please see this question:
Mouse move on element
Besides that, I think you are committing major design mistake by taking control of any of the users input in any way (maybe besides setting the focus of a form element)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With