tmandry / Swindler

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

Please add windowNumber #97

Open gerasimsergey opened 6 months ago

gerasimsergey commented 6 months ago

kCGWindowNumber

tmandry commented 6 months ago

See https://github.com/tmandry/x3/issues/1#issuecomment-437231522. I'd accept a PR for a change that adds windowNumber as an optional property, because we cannot guarantee in a stable way that it will always be available. It would be fine to use the undocumented _AXUIElementGetWindow for this.

gerasimsergey commented 6 months ago

@tmandry Hello, thank you very much for your answer, I didn’t expect you to answer. I really like Swindler and I'm trying to use this library in a small project.

But some things are missing, or rather there is no way to extend them, because many properties and methods are internal let delegate: WindowDelegate If it were available then I could implement the methods I need...

If you use AXSwift then as I understand it there is AXUIElementRef almost everywhere why not just make them readable in the Window and Application classes?

Then everyone could make the necessary extensions

For example, CGWindowID from AXUIElement or implement raize for a window

https://github.com/zenangst/AXEssibility/blob/main/Sources/AXEssibility/Classes/WindowAccessibilityElement.swift

tmandry commented 6 months ago

A public API could be added that returned the AXUIElement for a given Window/Application. I actually thought I'd added one already. It would again have to be optional, to support testing use cases where there isn't a real UIElement to return.

gerasimsergey commented 6 months ago

I don’t quite understand, but if you implement this, I’m ready to actively test it on a real project

gerasimsergey commented 2 months ago

Any update for this?