On my own computers at home, I have been running Linux since about 1999. One of the things that I really liked directly from the beginning of using Linux was that under X, I could move any window by holding the ALT button on the keyboard and then click anywhere in the window and drag it to the position I wanted.

This unlike Windows, where I have to always drag a window by clicking somewhere in the title bar. When I started working at Paragon Decision Technology (makers of AIMMS), I had to start working with a Windows laptop as our software is windows only for a big part (at least developing projects requires a windows version of AIMMS).

I did some searching and did find a couple of programs/plugins that were able to achieve the move-window-by-dragging-anywhere in-the-window, but none of them were exactly what I needed. After some time, I ran into the program AutoHotkey.

AutoHotkeyThis is an extremely powerful piece of software that allows you to do all kinds of cool things.

Currently I use it basically for two things:

  • Startup/Activate programs. E.g. if I press the keyboard shortcut Win-o, the Outlook window will be activated if Outlook was running, or Outlook is started otherwise. This can be achieved with the following piece of AutoHotkey script:
    #o:: SetTitleMatchMode 2 IfWinExist - Microsoft Outlook WinActivate else { Run outlook } SetTitleMatchMode 1 return
    - The earlier mentioned move-window-by-dragging-anywhere in-the-window feature. This can be achieved with the following AutoHotkey script:
    ; Note: From now on whenever you run AutoHotkey directly, this script ; will be loaded. So feel free to customize it to suit your needs.   ; Please read the QUICK-START TUTORIAL near the top of the help file. ; It explains how to perform common automation tasks such as sending ; keystrokes and mouse clicks. It also explains more about hotkeys.   !LButton:: CoordMode, Mouse ; Switch to screen/absolute coordinates. MouseGetPos, EWD_MouseStartX, EWD_MouseStartY, EWD_MouseWin WinGetPos, EWD_OriginalPosX, EWD_OriginalPosY,,, ahk_id %EWD_MouseWin% WinGet, EWD_WinState, MinMax, ahk_id %EWD_MouseWin% if EWD_WinState = 0 ; Only if the window isn't maximized SetTimer, EWD_WatchMouse, 10 ; Track the mouse as the user drags it. return   EWD_WatchMouse: GetKeyState, EWD_LButtonState, LButton, P if EWD_LButtonState = U ; Button has been released, so drag is complete. { SetTimer, EWD_WatchMouse, off return } GetKeyState, EWD_EscapeState, Escape, P if EWD_EscapeState = D ; Escape has been pressed, so drag is cancelled. { SetTimer, EWD_WatchMouse, off WinMove, ahk_id %EWD_MouseWin%,, %EWD_OriginalPosX%, %EWD_OriginalPosY% return } ; Otherwise, reposition the window to match the change in mouse coordinates ; caused by the user having dragged the mouse: CoordMode, Mouse MouseGetPos, EWD_MouseX, EWD_MouseY WinGetPos, EWD_WinX, EWD_WinY,,, ahk_id %EWD_MouseWin% SetWinDelay, -1 ; Makes the below move faster/smoother. WinMove, ahk_id %EWD_MouseWin%,, EWD_WinX + EWD_MouseX - EWD_MouseStartX, EWD_WinY + EWD_MouseY - EWD_MouseStartY EWD_MouseStartX := EWD_MouseX ; Update for the next timer-call to this subroutine. EWD_MouseStartY := EWD_MouseY return

    The best part about the window movement part is that it even works on windows that are partially behind modal dialogs. Normally, when an application is showing a modal dialog, you cannot move the underlying window because you must first close the modal dialog. With the above script, this restriction does not apply anymore.

    These two examples are just scratching the possibilities of AutoHotkey, but they have made my life a lot easier!

    If you have any great AutoHotkey scripts that made your life easier, please share them via a comment!