Coder Social home page Coder Social logo

Comments (7)

tobx avatar tobx commented on June 2, 2024 1

@Rhys-T Thank you a lot already. I am pretty sure that I did not always use the same app when the issue occurred, but I will double check that and note which apps I used when the issue occurs again. 50% of me using that script is moving the terminal position, but I only use Alacritty. Input Monitoring only shows two apps that I hardly ever use. I tried with both apps open and had no issue with my script. I added the isSecureInputEnabled and report back if there is more information.

from hammerspoon.

tobx avatar tobx commented on June 2, 2024

Today Hammerspoon did not react again and I noticed something more:

  1. Even if I completely quit the Hammerspoon process and start it again, the problem does not get resolved. I have to take the whole MacBook to sleep and wake it up again to resolve the problem.

  2. Hammerspoon does not really hang when I start hyper mode. I can still use the arrow keys to move my windows around, but I cannot use any of the "letter"-keys to quick-launch applications. I can also not use option+W to exit hyper mode.

  3. That might be important. When I am in hyper mode and press the arrow keys, they are captured by Hammerspoon and used to move windows, but the rest of the keys ("letter"-keys) are not captured and are entered in the currently active application as if they were not bound to Hammerspoon. Again, I use this extensively for days without an issue and suddenly this happens. I have not yet found any special behavior that I do different when this happens.

from hammerspoon.

Rhys-T avatar Rhys-T commented on June 2, 2024

Are there specific apps that you're usually in when you have this problem? I'm wondering if it could be an app enabling secure input mode (a.k.a. "secure keyboard input").

Basically, an app can put the system into a mode where no other apps (like, for instance, Hammerspoon) can watch what's being typed. This normally gets turned on when you're in a password field. Some terminal apps turn it on by default too (at least iTerm2 and Apple's Terminal, though possibly not Alacritty?). And sometimes certain apps can forget to turn it off again afterwards.

I think this originally just affected hs.eventtaps, but at some point started blocking hs.hotkeys as well - see #2880. Some people in that thread can still get hs.hotkeys that involve modifier keys to work, but others can't. I wonder if it's something like "ignore any hotkeys that were created after secure input was turned on (e.g. by a modal being entered)".

Try changing your hyper.entered() function to look like this:

function hyper:entered()
  if hs.eventtap.isSecureInputEnabled() then
    hs.alert("⚠️ Secure Input is on. Hyper Mode commands might not work.")
  end

  -- The rest of this is the code you already had here:
  hyperAlerts = {}
  for i, screen in pairs(hs.screen.allScreens()) do
    alert = hs.alert("Hyper Mode ✈", hyperStyle, screen, "")
    hyperAlerts[i] = alert
  end
end

If the modal only gets stuck after showing that warning message, then it's definitely secure input mode that's causing the problem. You might also want to bind Escape in the modal to an exit command, so you can at least get out of hyper mode when this happens - it sounds like Escape hotkeys still work while SIM is on.1 (Or maybe just add hyper:exit(); return after the warning message, to immediately kick you back out of hyper mode before it gets stuck.)

If the app that's responsible still turns SIM off when it's done, you might be able to work around it by creating and focusing an invisible hs.webview2 in hyper:entered() (thus taking you out of the password field or whatever), then restoring focus to the correct window in hyper:exited(). (Of course, all the other commands that look at hs.window.focusedWindow() would need to be changed to work on whatever window was saved by hyper:entered().)

See also: #2897, #2858

Footnotes

  1. I'm stuck on an older system at the moment, so I'm afraid I can't test this yet.

  2. Edit 11/17/2023: I originally said to use an empty hs.canvas, because it's probably more lightweight than a webview, but Hammerspoon doesn't seem to give you a way to focus an hs.canvas. hs.webviews don't directly have a focus method either, but you can at least do someWebview:hswindow():focus().

from hammerspoon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.