0

I'm trying to write a fairly simple script for Hammerspoon where I am looping through a table of app windows. The problem is for some reason when I call hs.eventtap inside the loop it keeps firing.

Any help much appreciated 🙏

function toggleMute() local teams = hs.application.find("com.microsoft.teams"):allWindows() if not (teams == null) then for i, v in pairs(teams) do hs.eventtap.keyStroke({"cmd", "shift"}, "m", 0, v) end end hs.alert.show('Mute Toggled') end 
3
  • Why are you sending the keystroke for each window? Why not send a single keystroke to the app itself? Commented Dec 16, 2022 at 17:05
  • Because Microsoft Teams has multiple windows and not all of them are capable of receiving the key sequence. And, there is no easy way of identifying the window that can receive the sequence. I have tried sending the sequence to the app itself and if you have multiple windows open and you are focused on one the can not receive the sequence the function fails. Commented Dec 17, 2022 at 0:44
  • can you explain what you mean with "keeps firing"? what is the keystroke you assigned to toggleMute()? is it the same keystroke? Commented Jun 10, 2023 at 20:02

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.