hammerspoon

How to click on a specific button


I'm new to Hammerspoon, but interested in automating some macOS workflows with it.

I know how to send keystrokes, but how do I simulate a mouse click on a specific button in a window or dialog? (I'm currently trying to close a dialog window that way)

Thanks in advance for any help!


Solution

  • You can use hs.eventtap.leftClick(point[, delay]) , where point is the {x, y} coordinates of the place you want to click. Official documentation: https://www.hammerspoon.org/docs/hs.eventtap.html#leftClick