How to send "cmd + click "event to current mouse position?

890 views
Skip to first unread message

Brad Parks

unread,
Oct 24, 2015, 9:42:14 PM10/24/15
to Hammerspoon
Hey! I'm trying to see how to send a "cmd" + "click" event to the current mouse position.

It seems like it should be something like:

  hs.eventtap.keyStroke("cmd", "leftClick");

but i tried that and a few other variations, and it doesn't work. Is there some way to do this? 

Thanks,

Brad

Chris Jones

unread,
Oct 29, 2015, 11:53:24 PM10/29/15
to Brad Parks, Hammerspoon
Hey

See hs.eventtap.event.newMouseEvent():)

Cheers,
Chris

--
You received this message because you are subscribed to the Google Groups "Hammerspoon" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hammerspoon...@googlegroups.com.
To post to this group, send email to hamme...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/hammerspoon/f57b3a50-fee9-41e5-9848-cd7cc63dc6ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Cheers,

Chris

Brad Parks

unread,
Oct 30, 2015, 12:34:57 PM10/30/15
to Hammerspoon, brad...@gmail.com
ahh... great... i missed that... thanks! here's what I ended up with to do it:

function leftClickWithModifiers(keys)
  local ptMouse = hs.mouse.getAbsolutePosition()
  local types = hs.eventtap.event.types
  hs.eventtap.event.newMouseEvent(types.leftMouseDown, ptMouse, keys):post()
  hs.eventtap.event.newMouseEvent(types.leftMouseUp, ptMouse, keys):post()
end
Reply all
Reply to author
Forward
0 new messages