tmandry / Swindler

macOS window management library for Swift
https://tmandry.github.io/Swindler/docs/main/
MIT License
690 stars 65 forks source link

Mouse over active window title bar event #63

Open renebrandel opened 4 years ago

renebrandel commented 4 years ago

I’d like to have an event that is raised when my mouse hovers over the title bar of the active window. I’m trying to build a window management app that can use vim like commands “jkl;” to snap the window to the right places. I don’t see an existing event that can help with that. Any advice?

tmandry commented 4 years ago

You can subscribe to global mouse events through some of the normal system APIs (I can’t remember them off the top of my head), and match up their coordinates to window coordinates that you get from Swindler.

If you need to know the coordinates of the title bar specifically, you’ll probably want to get the raw AXUIElement from Swindler and look for child elements with that role (look through the enum AXRole in my AXSwift library).

On Tue, Jul 9, 2019 at 12:56 PM Rene Brandel notifications@github.com wrote:

I’d like to have an event that is raised when my mouse hovers over the title bar of the active window. I’m trying to build a window management app that can use vim like commands “jkl;” to snap the window to the right places. I don’t see an existing event that can help with that. Any advice?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/tmandry/Swindler/issues/63?email_source=notifications&email_token=AARMYYDSJIPXTETMKIRP7XLP6TUO5A5CNFSM4H7IZ3QKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G6F6UIQ, or mute the thread https://github.com/notifications/unsubscribe-auth/AARMYYGBN7GNWRCL4MC627DP6TUO5ANCNFSM4H7IZ3QA .

-- Tyler Mandry

renebrandel commented 4 years ago

Thanks Tyler for the quick response.

you’ll probably want to get the raw AXUIElement from Swindler and look for child elements with that role

Is there a way to easily get the raw AXElement through the Swindler window. Just looking at the Window definition, I wasn’t able to access the raw AXElement.