kasper / phoenix

A lightweight macOS window and app manager scriptable with JavaScript
https://kasper.github.io/phoenix/
Other
4.39k stars 128 forks source link

Is it possible to get window created time? #344

Closed gutenye closed 9 months ago

gutenye commented 9 months ago

app.windows(), Window.all(), Window.recent() all return windows in recent order. But I want to get the windows in fixed order. If there's a window created time, then I can sort the windows.

kasper commented 9 months ago

@gutenye Hey! At the moment, there is nothing in the API that would give this to you directly. You could use events for this, something like the following.

Event.on('windowDidOpen', (window) => {
  window.createdAt = new Date(); // Or save the timestamp somewhere else in the scope to retain it
});
gutenye commented 9 months ago

Thank you!