Can anyone please verify and fix this script?
It works except that the ESC button cannot close the Menu and its background
Thanks for the tips, Michael
-------------
WinGetActiveTitle, activeWindowTitle
WinGetPos, X, Y, Width, Height, A
windowsList := []
WinGet, list, List
Menu, MyMenu, Add
Menu, MyMenu, DeleteAll
Loop, %list%
{
hwnd := list%A_Index%
WinGetTitle, title, ahk_id %hwnd%
WinGetClass, class, ahk_id %hwnd%
WinGet, ProcessName, ProcessName, ahk_id %hwnd%
WinGet, Style, Style, ahk_id %hwnd%
if (title = "") || (title ~= "i)Rainmeter") || (title ~= "i)Start") || (title ~= "i)frmFloatBas") || (ProcessName = "explorer.exe") || (ProcessName = "TextInputHost.exe")
continue
if !(Style & 0x10000000)
continue
if (ProcessName = "msedge.exe" && (title ~= "i)Seznam oken" || title ~= "i)New Tab"))
continue
StringUpper, ProcessName, ProcessName
StringReplace, ProcessName, ProcessName, .exe, , All
fullTitle := ProcessName . " - " . title
windowsList.Push({"title": fullTitle, "id": hwnd})
Menu, MyMenu, Add, %fullTitle%, ActivateWindow
}
MouseGetPos, xpos, ypos
SysGet, MonitorCount, MonitorCount
Loop, %MonitorCount%
{
SysGet, Monitor, Monitor, %A_Index%
if (xpos >= MonitorLeft and xpos <= MonitorRight and ypos >= MonitorTop and ypos <= MonitorBottom)
{
centerX := MonitorLeft + ((MonitorRight - MonitorLeft) // 2)
centerY := MonitorTop + ((MonitorBottom - MonitorTop) // 2)
Gui, +AlwaysOnTop -Caption +ToolWindow +E0x20
Gui, Color, 000000
Gui, Show, x%MonitorLeft% y%MonitorTop% w%MonitorRight% h%MonitorBottom%, Overlay
WinSet, Transparent, 150, Overlay
break
}
}
SetTimer, ShowMenu, -10
return
ShowMenu:
Menu, MyMenu, Show, %centerX%, %centerY%, Selection of open windows
return
Esc::
Gui, Destroy
Send, {Esc}
Return
return
ActivateWindow:
selectedTitle := A_ThisMenuItem
for index, window in windowsList
{
if (window.title = selectedTitle)
{
windowID := window.id
break
}
}
if windowID
{
Gui, Destroy
Send, {Esc}
WinActivate, ahk_id %windowID%
WinWaitActive, ahk_id %windowID%, , 2
if !WinActive("ahk_id " . windowID)
MsgBox, Failed to activate the window!
}
return
GuiClose:
Gui, Destroy
Send, {Esc}
Return
return