Remote Mousing

Control a mouse remotely with YUI 3 and Custom Events

The gray box commands the red box. Try and click the links with the virtual mouse.

Link 1 Link 2 Link 3

How it works

The first step is calculating where the target regions are this may vary and for this example I've taken the easy way and done it with 2 boxes. Once that's done I take all of the links in the target area and push them into an array along with their regions a.k.a. their pixel real estate. In this case there are only 3 links. Once that is instantiated I'm free to move my virtual mouse in that relative space and check to see whether the center of that virtual mouse is over any part of any of those target regions. Though heavy it's not too bad considering it only happens on the click event. If they intersect then I trap the targets' HREF and do with it as I will.

This is all accomplished using YUI3's Event Simulation and the mouseup, mousedown and mousemove events. They are captured in the gray box and simulated in the red box.

Tested in FF3, Safari 4, IE7