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
Fyrebase
  • 163
  • 6
  • Why are you sending the keystroke for each window? Why not send a single keystroke to the app itself? – Oliver Taylor Dec 16 '22 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. – Fyrebase Dec 17 '22 at 00:44
  • can you explain what you mean with "keeps firing"? what is the keystroke you assigned to `toggleMute()`? is it the same keystroke? – muescha Jun 10 '23 at 20:02

0 Answers0