📅  最后修改于: 2023-12-03 14:39:05.203000             🧑  作者: Mango
Alt Tab AHK is a simple script written in AutoHotkey (AHK) that enhances the default Windows Alt+Tab functionality. It allows you to easily switch between windows by pressing a keyboard shortcut.
Alternatively, you can compile the script into an executable file that can be run on any Windows machine without the need for AutoHotkey. To do so, simply right-click on the script file and select Compile Script.
Simply hold down the Alt key and press Tab to bring up the Alt Tab menu. You can then use the arrow keys or mouse to select a window from the menu. Press Enter to switch to the selected window, or press Esc to close the menu without switching.
The script is fully customizable and can be modified to suit your personal preferences. Simply open the script in a text editor and make the desired changes.
For example, you can change the hotkey used to bring up the Alt Tab menu by modifying the following line:
~$*Tab::
Similarly, you can change the appearance of the Alt Tab menu by modifying the following lines:
Menu, Color , %MenuColor%
Menu, Font , %MenuFont%
Menu, Style , %MenuStyle%
Alt Tab AHK is a simple but powerful tool that can greatly enhance your workflow. With its customizable features and intuitive interface, it is a must-have for any programmer who wants to work more efficiently. Give it a try and see how it can improve your productivity today!
~$*Tab::
WinGet, winlist, List
WinGetTitle, active, A
Loop, % winlist.MaxIndex()
{
win := winlist%A_Index%
If (win != "Program Manager") && (win != "Start Menu") && (win != "Microsoft Text Input Application") && (win != "Settings") && (win != "Microsoft Store") && (win != "Microsoft Edge") && (win != "Alt Tab Menu") && (win != "Task View")
{
If (win = active)
{
activeIndex := A_Index
}
}
}
Gui AltTab:New
{
Border := 10 ; Change this value to adjust the border size
Width := A_ScreenWidth - Border * 2
Height := A_ScreenHeight - Border * 2
X := Border
Y := Border
Color := "0x" . menuColor
Font := menuFont
Style := menuStyle
Count := 0
Loop, % winlist.MaxIndex()
{
win := winlist%A_Index%
If (win != "Program Manager") && (win != "Start Menu") && (win != "Microsoft Text Input Application") && (win != "Settings") && (win != "Microsoft Store") && (win != "Microsoft Edge") && (win != "Alt Tab Menu") && (win != "Task View")
{
Count++
If (A_Index = activeIndex)
{
Icon := getIcon(win)
}
Gui, +LastFound +AlwaysOnTop
Gui, Add, Picture, hwndIcon%A_Index%, % Icon, Icon
Gui, +OwnDialogs +ToolWindow -Caption
Gui, Add, Text, x5 y5 hwndTitle%A_Index% vTitle%A_Index% cWhite, % win
}
}
GuiControl, Move, Icon1, w44 h44
GuiControl, Font, Title1, s16 bold cWhite, %menuFont%
Gui, Show, x%X% y%Y% w%Width% h%Height% BackgroundTrans %Style% %Color%
}
Gui AltTab:Default
Gui AltTab:+LastFound +AlwaysOnTop
Gui AltTab:Margin, 0, 0
Gui AltTab:Color, 0x000000
Gui AltTab:+LabelClose
Gui AltTab:+Resize
Gui AltTab: -Caption +AlwaysOnTop +ToolWindow +E0x20
Gui AltTab:Font, %menuFont%
Gui AltTab:GuiControl, +LastFound +AlwaysOnTop, Text1, Alt Tab
Gui AltTab:GuiControl, Font, Text1, s16 bold cWhite
Gui AltTab:GuiControl, Move, Text1, w%Width% h40 x5 y5
Gui AltTab:GuiControl, +LastFound +AlwaysOnTop, Text2, Use arrow keys to navigate. Press enter to switch windows. Press ESC to close.
Gui AltTab:GuiControl, +LastFound +AlwaysOnTop, Font2, s12 cWhite
Gui AltTab:GuiControl, Move, Text2, x5 y%Height%-35 w%Width% h30
Gui AltTab:GuiControl, +LastFound +AlwaysOnTop, Picture1, w44 h44 hwndIcon1 vIcon1, %Windir%\System32\shell32.dll,12,4
Gui AltTab:GuiControl, Move, Picture1, w44 h44 x5 y%Height%-50
Gui AltTab:GuiControl, +LastFound +WantTab, Picture1, Icon1
Gui AltTab:GuiControl, Font, Title1, s16 bold cWhite, %menuFont%
Gui AltTab:GuiControl, Move, Title1, w%Width% h40 x60 y15
WinSet, TransColor, 0x000000
return
Gui AltTab:Escape:
Gui AltTab:Cancel:
Gui AltTab:GuiClose:
Gui AltTab:Process, Cancel
{
Gui AltTab:Destroy
return
}
Gui AltTab:Tab::
activeIndex := (activeIndex < Count) ? activeIndex + 1 : 1
changeSelection(activeIndex)
return
Gui AltTab:Tab, Shift::
activeIndex := (activeIndex > 1) ? activeIndex - 1 : Count
changeSelection(activeIndex)
return
Gui AltTab:WheelDown::
activeIndex := (activeIndex < Count) ? activeIndex + 1 : 1
changeSelection(activeIndex)
return
Gui AltTab:WheelUp::
activeIndex := (activeIndex > 1) ? activeIndex - 1 : Count
changeSelection(activeIndex)
return
Gui AltTab:Return:
{
hwnd := WinExist("ahk_id " . hwndTitle . activeIndex)
WinActivate, ahk_id %hwnd%
Gui AltTab:Destroy
return
}
changeSelection(index)
{
hwnd := WinExist("ahk_id " . hwndTitle . activeIndex)
GuiControl, +LastFound +AlwaysOnTop, Picture1, w44 h44 hwndIcon%A_Index% vIcon%A_Index%, % getIcon(winlist%A_Index%)
activeIndex := A_Index
}