Mouse Movements Toolkit
I originally developed this as part of a silly social experiment which allowed anyone to control my computer's mouse from a public web page. You can imagine the havok that ensued ;D
There's no real practical need for the remote itself, but the core functionality took a bit of thinking to work out and I'm putting it here for use in your own remotes. Use whatever you like to save some time- think of it as a sort of jQuery for UR mouse movements!
For some reason libs.mouse.moveby is acting like libs.moveto, so that may be a bug. I made this at the start of the year so things may have changed since then.
local ms = require("mouse"); local timer = require("timer"); local screen = require("screen"); local width,height = screen.size(); local mX = 0; local mY = -1; local deltaX = mX; local deltaY = mY; [email protected] Move mouse to top-left corner actions.top_left = function() ms.moveto(0, 0); end [email protected] Move mouse to top-right corner actions.top_right = function() ms.moveto(width, 0); end [email protected] Move mouse slightly towards right actions.move_right = function() ms.moveby(width/75, 0); end [email protected] Move mouse towards bottom left actions.move_bottom_left = function() ms.moveby(-width/4, height/4); end [email protected] Move mouse to monitor on left (doesn't actually work) actions.left_monitor = function() ms.moveby(-width*1.5, 0); end [email protected] Executes random_process every 200 milliseconds for 5 seconds actions.random = function() local tid = timer.interval(actions.random_process, 200); local tid_2 = timer.timeout( function() timer.cancel(tid); print("Okay, enough for now"); end , 5000); end [email protected] Move mouse pointer by a random distance and direction actions.random_process = function() ms.moveraw(math.random(-500, 500), math.random(-500, 500)); end [email protected] Executes spiral_process every 50 milliseconds for 5 seconds actions.spin = function() local tid = timer.interval(actions.spiral_process, 50); local tid_2 = timer.timeout( function() timer.cancel(tid); deltaX, mX = 0; deltaY, mY = -1; print("Okay, that's a wrap"); end , 5000); end [email protected] Move mouse pointer in a spiral actions.spiral_process = function() deltaX = mX; deltaY = mY; if mX == 0 then deltaX = mY*(-1); else deltaX = 0; end if mY == 0 then if mX > 0 then deltaY = mX + 1; else deltaY = mX - 1; end else deltaY = 0; end mX = deltaX; mY = deltaY; ms.moveraw(mX, mY); end
Felipe Sousa 70
I was trying to find out how to do periodic repetition, you've used this in some of lines.
I'll test the spiral move here :D
Yes! The trick is to have 2 timers: one in charge of intervals (frequency/repetition) and one in charge of duration/periods.
I've added a zip for the full remote in case it helps: Mouse Movements v3
Be mindful that as stated, moveby is acting like moveto, so expect some funny behaviour.