Search code examples
windowsemacsautohotkeyputtygnu-screen

Passing alt-tab to Emacs inside Screen inside Putty


I run terminal-mode Emacs (using the -nw option) inside Screen on my office Debian box. This way, I can log in my box with ssh from anywhere and work even with slow or intermittent connection.

When I log in from Windows using Putty, I miss the possibility of using the Alt-Tab key combination (M-TAB in Emacs parlance). I compensate using the two keys Esc and Tab, but that's two key presses, which is slower.

I just discovered that using Autohotkeys I can make Ctrl-Tab do the same as Alt-Tab with this rule:

LControl & Tab::AltTab

and I can disable Alt-Tab altogether with this other rule:

!Tab::Return

but this is not what I want. I need to copy the functionality of Alt-Tab on some other hot key (Ctrl-Tab is okay and the first rule does that) and additionally I want the Alt-Tab key to be passed to Putty when I am using it (which would pass it to Screen, which would pass it to Emacs). In other words, Alt-Tab should not be disabled, but its special meaning should be deleted.

Is this possible with Windows?


Solution

  • Working with the answers I got from several hepful users, I got to the final solution I have used for some time now. Here is the Autohotkeys script that I put on my desktop and that I double-click every time I have to restart Windows:

    File "alt-tab to ctrl-tab.ahk"

    #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.
    
    LControl & Tab::AltTab
    ; !Tab::Return
    ; #IfWinActive, putty
    !Tab::send {Esc}{Tab}