/* * Generate a click using an arbitrary mouse button (down and up events) * * Numbers are used to map the mouse buttons. At the time of writing, * the documented values are: * * - `kCGMouseButtonLeft = 0` * - `kCGMouseButtonRight = 1` * - `kCGMouseButtonCenter = 2` * * And the rest are not documented! Though they should be easy enough * to figure out. See the `CGMouseButton` enum in the reference * documentation for the most up to date list. * * You can optionally specify a point to click; the mouse cursor will * instantly jump to the given point; otherwise the click event happens * at the current cursor position. * * @overload arbitrary_click(button) * @param button [Number,#to_i] * @return [CGPoint] * @overload arbitrary_click(button, point) * @param button [Number,#to_i] * @param point [CGPoint] * @return [CGPoint] */ static VALUE rb_mouse_arbitrary_click(const int argc, VALUE* const argv, UNUSED const VALUE self) { if (argc == 0) { rb_raise(rb_eArgError, "arbitrary_click requires at least one arg"); return Qnil; } const uint_t button = NUM2UINT(argv[0]); switch (argc) { case 1: mouse_arbitrary_click(button); break; case 2: default: mouse_arbitrary_click2(button, rb_mouse_unwrap_point(argv[1])); } return CURRENT_POSITION; }
void mouse_middle_click2(CGPoint point) { mouse_arbitrary_click2(kCGMouseButtonCenter, point); }