Skip to content

Instantly share code, notes, and snippets.

@aschmelyun
Last active December 16, 2025 02:22
Show Gist options
  • Select an option

  • Save aschmelyun/296ce38449aca705ead68ac76cdaa316 to your computer and use it in GitHub Desktop.

Select an option

Save aschmelyun/296ce38449aca705ead68ac76cdaa316 to your computer and use it in GitHub Desktop.
AutoHotKey script for enabling alt-tab on a Windows system after switching the Alt and Ctrl keys
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
LCtrl & Tab:: AltTab
!Tab:: Send ^{Tab}
!+Tab:: Send ^+{Tab}
^Space:: Send ^{Esc}
^Left::
Send {Home}
Return
^Right::
Send {End}
Return
^+Left::
Send +{Home}
Return
^+Right::
Send +{End}
Return
^Up::
Send ^{Home}
Return
^Down::
Send ^{End}
Return
^+Up::
Send ^+{Home}
Return
^+Down::
Send ^+{End}
Return
@prabowomurti
Copy link

prabowomurti commented Dec 15, 2025

Hi, I made version 2.0 ahk based on your work.

#Requires AutoHotkey v2.0
#SingleInstance Force

; as a flag for Switching Apps process status
global isAltTabbing := false

;  Switching Apps
LCtrl & Tab::
{
    global isAltTabbing
    if (!isAltTabbing) {
        isAltTabbing := true
        Send "{Alt Down}{Tab}"
    } else {
        Send "{Tab}"
    }
}

~LCtrl Up::
{
    global isAltTabbing
    if (isAltTabbing) {
        Send "{Alt Up}"
        isAltTabbing := false
    }
}

; Exception for multitasking view frame
#HotIf isAltTabbing
    ; while in the state of choosing the window, send Arrow as it is
    ^Left::Send "{Left}"
    ^Right::Send "{Right}"
    ^Up::Send "{Up}"
    ^Down::Send "{Down}"
    
    Enter::
    {
        global isAltTabbing
        Send "{Alt Up}"
        isAltTabbing := false
    }
#HotIf

; --- Browser/App Tab Switching ---
; Alt + Tab triggers Ctrl + Tab (Next Tab)
!Tab::Send "^{Tab}"
; Alt + Shift + Tab sends Ctrl + Shift + Tab (Previous Tab)
!+Tab::Send "^+{Tab}"

; --- Start Menu or Copilot overlay / Spotlight wannabe ---
; Ctrl + Space sends Ctrl + Esc
;^Space::Send "^{Esc}"
^Space::Send "!{Space}"

; --- Navigation Shortcuts (Mac Style) ---
; Command + Left (Home)
^Left::Send "{Home}"

; Command + Right (End)
^Right::Send "{End}"

; Command + Shift + Left (Select to Home)
^+Left::Send "+{Home}"

; Command + Shift + Right (Select to End)
^+Right::Send "+{End}"

; Command + Up (Top of Document)
^Up::Send "^{Home}"

; Command + Down (Bottom of Document)
^Down::Send "^{End}"

; Command + Shift + Up (Select to Top)
^+Up::Send "^+{Home}"

; Command + Shift + Down (Select to Bottom)
^+Down::Send "^+{End}"

; --- Custom Page Up/Down ---
; Windows + Up Arrow turns to Page Up
#Up::Send "{PgUp}"

; Windows + Down Arrow turns to Page Down
#Down::Send "{PgDn}"

; Windows + Left = Jumps one word (Ctrl + Left)
#Left::Send "^{Left}"

; Windows + Right = Jumps one word (Ctrl + Right)
#Right::Send "^{Right}"

; Windows + Shift + Left = (Ctrl + Shift + Left)
#+Left::Send "^+{Left}"

; Windows + Shift + Right = (Ctrl + Shift + Right)
#+Right::Send "^+{Right}"

; Delete per word
#Backspace::Send "^{Backspace}"

; Delete one line
$^Backspace::Send "+{Home}{Backspace}"
;^Backspace::Send "+{Home}{Backspace}"

; Optional: Windows (Option) + Delete = Delete Word to Right
#Delete::Send "^{Delete}"

; Sniping Tool (partial)
^+4::Send "#+s"

; Sniping Tool (full screen)
^+3::Send "{PrintScreen}"

; Cmd (Ctrl) + Opt (Win) + Left = Previous Tab
^#Left::Send "^{PgUp}"

; Cmd (Ctrl) + Opt (Win) + Right = Next Tab
^#Right::Send "^{PgDn}"

; Quit Application
^q::Send "!{F4}"

; Custom script to mimic cycle through different windows but in the same app
^`::
{
    try {
        ; try to get active windows
        activeExe := WinGetProcessName("A")
        ; get the most bottom stack
        WinActivateBottom "ahk_exe " activeExe
    }
}

!Left::Send "^#{Left}"
!Right::Send "^#{Right}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment