Questions tagged [hammerspoon]

This tag should be used for questions related to lua automation tool for OSX

should be used for questions related to automation tool for

Sample

Pressing ctrl+G will display a Sample Alert! notification on your screen.

hs.hotkey.bind({"cmd"}, "S", function()
  hs.alert.show("Sample Alert!")
end)

References

70 questions
3
votes
2 answers

In Hammerspoon, how to open an app and pass in startup params

I'm trying to make a Hammerspoon hotkey to open and start a daily meeting in Google Meet. Since I have more than 1 google profile, I need to pass the desired profile in to Chrome at invoke time, using Chrome command-line parameters. The normal…
randulfir
  • 71
  • 8
3
votes
1 answer

hammerspoon: how to disable hotkey in certain application?

Firefox's CMD+Shift+P (on Mac) for new Private Window conflicts the "Move" page keyboard shortcut in Notion. Looks like there's no way to remap keys within Firefox, OSX Keyboard shortcuts, or even 3rd party Fixefox Adds like Shortkeys. Good & up to…
snowbound
  • 1,692
  • 2
  • 21
  • 29
3
votes
2 answers

Hammerspoon Window management does not work as expected on secondary monitor

I'm new to Lua and hammerspoon and can not for the life of me figure out why the below code works fine on my primary screen, but the cycling though positions does not work on my secondary monitor. hitting the shortcut on windows on the secondary…
markus
  • 33
  • 3
3
votes
1 answer

Hammerspoon - how to paste text?

I can't find it in the docs - how do i paste text with Hammerspoon on OS X? I tried the following: hs.hotkey.bind({"ctrl", "pad1"}, "1", function() hs.eventtap.keyStrokes("this needs to be pasted!") end) but it does not work. I pressed…
louis
  • 71
  • 6
3
votes
1 answer

Paste text from hs.chooser in hammerspoon

I am trying to create a shortcut where I store a set of text templates by using hs.chooser. And, the user can paste this by clicking on the drop down from hs.chooser. I use the below code which displays my template but doesn't paste the text. Can…
moh17
  • 223
  • 1
  • 6
  • 25
3
votes
1 answer

How to call kill and yank function from Hammerspoon or Karabiner

OSX default kill(ctrl + k) and yank(ctrl + y) function doesn't work when using Thai or Korean input mode. Other key bindings for cursor movements are also disabled. So I'm trying to emulate the function by using Hammerspoon. But I couldn't find out…
ironsand
  • 14,329
  • 17
  • 83
  • 176
3
votes
1 answer

In Hammerspoon how do I get the currently focused application name on startup?

I can get the application name after the user switches focus with the following code: function applicationWatcher(appName, eventType, appObject) if (eventType == hs.application.watcher.activated) then print(appName) end end local appWatcher…
Justin Tanner
  • 14,062
  • 17
  • 82
  • 103
3
votes
1 answer

How to open a directory in Hammerspoon?

I would like to open a directory on Hammerspoon with a keyboard shortcut. In order to open any apps via shortcut, you use the following: hs.hotkey.bind({"ctrl"}, "n", function() hs.application.launchOrFocus("Safari") end ) However, this…
Blaszard
  • 30,954
  • 51
  • 153
  • 233
3
votes
1 answer

Data not appearing in log file after write operation

I have the following code: time = os.date("*t") data = io.open("test.txt", "a") function applicationWatcher(appName, eventType, appObject) if (eventType == hs.application.watcher.launched) then data:write("" .. appName .. " launched at…
FutureCake
  • 2,614
  • 3
  • 27
  • 70
2
votes
1 answer

How to use AppleScript or Lua to do an ALT + TAB after results on the Calculator.app

I use the Calculator.app, and after hitting the ENTER key, I would like it to automatically do an ALT + TAB to go to the previous App I was using: Excel or Firefox or Chrome, ... you name it. I have the same question for just .lua, but if it can't…
sebseb
  • 93
  • 1
  • 1
  • 8
2
votes
0 answers

On Monterey, while NSSecureTextField has focus, Hammerspoon can no longer bring another app into foreground

This is a slightly obscure issue, so I'll do my best to describe it as well as what I've already tried. I have just started using macOS Monterey, and I suspect that the new macOS version has broken my workflow. I have a hotkey bound in Hammerspoon,…
RogerTheDragon
  • 267
  • 1
  • 10
2
votes
1 answer

Is there a way to listen for any key press, and mute microphone?

I'm not familiar with LUA or hammerspoon, but I want to listen for any button on the keyboard being pressed. I believe I can use hs.eventtap.event.newKeyEvent for this, but I'm not sure how to catch any and all key press. I don't care what is…
JayTea
  • 21
  • 1
2
votes
0 answers

Hammerspoon Key Repeats

I am so glad I found hammerspoon. I am having issues coming from windows to mac os. I have been using autohotkey in the past and have this script that I cannot live without while playing world of warcraft. I suffered a hand injury and can't play…
2
votes
1 answer

Inserting text in table format using lua Hammerspoon

I'm trying to create a script using lua in hammpersppon. Where pressing "x" will give the user option to paste the kind of template that they want to paste into a text field in web. Unfortunately, I am not able to figure out how to format that text…
moh17
  • 223
  • 1
  • 6
  • 25
2
votes
0 answers

popUpMenuPositioningItem:atLocation:inView: fails on dual screens

SOLVED (4th AUGUST): After much mucking around, I eventually solved this with an undocumented API argument: // Adds undocumented "appearance" argument to "popUpMenuPositioningItem": @interface NSMenu (MISSINGOrder) -…
Chris Hocking
  • 21
  • 1
  • 7