Skip to content

Instantly share code, notes, and snippets.

@bestK
Last active May 24, 2022 06:28
Show Gist options
  • Save bestK/38ee8a9a40f73e26fd25d7c7b1dba203 to your computer and use it in GitHub Desktop.
Save bestK/38ee8a9a40f73e26fd25d7c7b1dba203 to your computer and use it in GitHub Desktop.
; AltTabMenu-replacement for Windows 8:
AltTabMenu(){
list := ""
_IDEA_ :="idea" ;只显示IDEA
Menu, windows, Add
Menu, windows, deleteAll
WinGet, id, list
Loop, %id%
{
this_ID := id%A_Index%
WinGetTitle, title, ahk_id %this_ID%
If (title = "")
continue
If (!IsWindow(WinExist("ahk_id" . this_ID)))
continue
WinGet, Path, ProcessPath, ahk_id %this_ID%
if(!inStr(Path,_IDEA_))
continue
Menu, windows, Add, %title%, ActivateTitle
Try
Menu, windows, Icon, %title%, %Path%, , 0
Catch
Menu, windows, Icon, %title%, %A_WinDir%\System32\SHELL32.dll, 3, 0
}
CoordMode, Mouse, Screen
MouseMove, (0.4*A_ScreenWidth), (0.35*A_ScreenHeight)
CoordMode, Menu, Screen
Xm := (0.25*A_ScreenWidth)
Ym := (0.25*A_ScreenHeight)
Menu, windows, Show, %Xm%, %Ym%
}
ActivateTitle:
SetTitleMatchMode 3
WinActivate, %A_ThisMenuItem%
return
;-----------------------------------------------------------------
; Check whether the target window is activation target
;-----------------------------------------------------------------
IsWindow(hWnd){
WinGet, dwStyle, Style, ahk_id %hWnd%
if ((dwStyle&0x08000000) || !(dwStyle&0x10000000)) {
return false
}
WinGet, dwExStyle, ExStyle, ahk_id %hWnd%
if (dwExStyle & 0x00000080) {
return false
}
WinGetClass, szClass, ahk_id %hWnd%
if (szClass = "TApplication") {
return false
}
return true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment