for i, window in ipairs(allWindows) do
if window:title() and window:title() ~= "" then
local app = window:application()
local appName = app and app:name() or "Unknown"
table.insert(windowChoices, {
text = appName .. " - " .. window:title(),
subText = "Window " .. i,
window = window,
id = i
})
end
end
local chooser = hs.chooser.new(function(choice)
if choice and choice.window then
choice.window:focus()
local frame = choice.window:frame()
hs.mouse.absolutePosition({ x = frame.x + frame.w / 2, y = frame.y + frame.h / 2 })
end
end)
chooser:choices(windowChoices)
chooser:searchSubText(true)
chooser:show()
end