How-To Geek

Get the Linux Alt+Window Drag Functionality in Windows

One of my favorite features from Linux is the Alt + Window drag that allows you to move any window by holding down the Alt key and then just left-click dragging the window anywhere you’d like.

I set about to duplicate this functionality in Windows using my favorite automation tool, AutoHotkey. A short amount of browsing time later and I’d come up with a workable solution modified from this script.

An animation would work better here, but you can see that the mouse pointer is in the middle of the window:


By holding down the Alt key and dragging, I can move the window without having to click on the title bar:


Once you get used to this, you’ll never want to go back, and because it’s an AutoHotkey script I can bundle it together with all my other enhancements, such as assigning hotkeys to windows or the Hide Others script.

I’ve bundled a download together with the autohotkey script that you can use if you already have AutoHotkey installed, and also an executable file that you can use on any computer.

Download AltWindowDrag AutoHotkey Script & Executable

Lowell Heddings, better known online as the How-To Geek, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on if you'd like.

  • Published 11/24/07

Comments (50)

  1. Peter Blanked

    Not really a computer issue just a stupid question.

    How can I run more than one script without having my system-tray full of hotscript icons?

    I also tried to put all the scripts in one file but only the first script in that file will work.

  2. Noah Coad

    Awesome script!! Thanks! I added a “Send {alt}” after the button is released so focus doesn’t stay on the menu bar. I love it. Keep the AutoHotKey scripts coming.

  3. Jon

    Dude, you rock. I love that feature from X-Window managers, I’ve used it for years together with other neat customisations. Once I spent entirely too much time customising my fvwm manager. I have been able to get this functionality on my Mac (with various extensions), and it’s just super awesome to have it so easily with Windows Vista too. Cheers, Jon Dell’Oro

  4. Crash

    Very nice. I like it. However, I would like to see it embedded into the OS via the registry so there isnt any icon in the system tray.

    Other than that, I like it.

  5. Bojan K.

    Another great script that showcases the power and versatility of AutoHotkey, but this particular modification interferes with the function of Alt key in some Windows applications and renders it useless (for instance, setting the right loop locator in Propellerhead’s Reason). My workaround for this problem is to assign this script’s keystroke to left Win key by changing the line “Alt & LButton::” to “LWin & LButton::”.

  6. The Geek


    I noticed it was interfering with Photoshop for me… so I made the same change you did. =)

  7. starpause

    is something like this possible in winXP?

  8. jj rotane

    Oh my god, this is EXACTLY what I was looking for! (And I was only looking for 2 minutes and I found this page.) Been using Autohotkey for years, but there’s so few good sites with sample scripts around. So again, thanks!

    PS: to starpause: Yes, you can use right this script in XP – I just had to update my Autohotkey to the latest version. Alternatively, the .exe file in the zip archive runs on XP anyway.

  9. jj rotane

    PPS: I just remapped “Alt & LButton::” to “~LButton & RButton::” so now you have to click left + right to move the window. Handy if you wanna use only one hand ;)

  10. islisis

    If you have performance problems, see also this standalone program linked from the virtuawin homepage

  11. imnotquitejack

    YES! You are awesome; this is exactly what I was looking for. Thanks!

  12. mon


  13. Dafin

    Thanks, eeePC701 uesrs love you!

  14. juln

    As a long time Linux user, I am shocked at the critical features I use all the time in Linux that are simnply missing in Windows… as if MS never thought of this? Not being able to move windows except when you can grab the title bar is absurd. Especially the windows that open with the bar underneath your task bar…

  15. Anthony

    I know it’s not related, but I really want that desktop wallpaper, anyone know where I can get it?

  16. Tijmen

    Hey, how can I put a window on top of all the others while dragging? I tend to move the window I drag behind another window which has a higher ‘z-index’

  17. Quattro

    Maybe the window should be raised using the same script. if i’m not very much mistaken windows window-manager should be able to do that.

  18. AdamG

    Just FYI: I don’t know if this is a bug in the script, AHK, or Synergy, but this doesn’t work with Synergy on Vista. Vista is the client; the Synergy server is on Ubuntu. Using a directly connected mouse, the moving works; using a cursor controlled by Synergy, it doesn’t.

  19. Stefan

    I just want to tell everyone that I have made a native windows program that does exactly this.
    Check it out at:

  20. Alikas


  21. Tuvi

    I just wanted to say, thank you for this!! I was having a horrible problem with some windows opening almost completely off-screen and I couldn’t move them at all. This let me fix everything! Thank you!

  22. Chad

    Cool. Has anyone written ALT+Middle Mouse for resizing windows like ubuntu has?

  23. Stefan Sundin

    There’s a few programs that do that, check out the programs listed here:
    My program, AltDrag, will have the resizing feature in the next version.

  24. Josh

    Very nice! Now if I can just figure out how to do edge resistance in Vista, I’ll be in good shape.


  25. fonzcar

    I love you !!

  26. Misc

    ALT+SPACE+M then use the mouse keys to move the window.

  27. Misc

    …arrow keys, sorry.

  28. hzqtc

    This is what I’m looking for serveral years. AHK is really a fantastic script tool.
    Thanks to your great work.

  29. Fixup

    Misc, Alt+Space+M can move the window up to the title bar only. Some dialog boxes are so tall, you have to move up more to be able to click on the OK, Cancel, Next and Previous buttons at the bottom.

    I was looking for such an utility for a long time, it turns out so simple, great job. I too am an AHK fan.

  30. James Healy

    Awesome! A friend has a very sweet “Micro-Vaio”, and this was driving me NUTS. Thanks for the quick and easy fix.

  31. nikhil


  32. Chronosome

    This is great — I especially like it with Rotane’s little tweak. Thanks for sharing!

  33. Mike K

    Nice. I remapped it to CapsLock to avoid issues mentioned in comments. A question: I love how it works, but I’d also like to launch command line to a default directory even if I’m not currently in an explorer window. Could it be modified so that if explorer’s not active, the script just runs “cmd”?


  34. Xavier

    I have a request..

    Sometimes windows jump to the next monitor or go beyond the edge of the screen where there is no access to them. This forces me to close the window from the taskbar.

    Can someone tweak it so the window can be dragged from anywhere in the screen? Unless there’s another workaround.


  35. supermamon

    Great Script!
    I modified a bit so that it activates the window before dragging. Helpful specially for those using multiple monitors where there might be a maximized window on the target monitor.

    @jj rotane: Good tip!

  36. Mike K

    Oops, posted my earlier comment to the wrong window! Sorry for the non-sequitor.

  37. ben

    your the man!!! XD

  38. Darron

    Great script, I would hate to think linux becoming like windows, but windows behaving like linux brilliant.

  39. Michael Gartner

    As much as I hate using Windows, I still do sometimes.

    This is an AMAZING tool.

    You are my new hero and I’m about to read every post you’ve ever made.

  40. beriukay

    I really like this script when it works, which it usually does. Has anyone else noticed that the script stops responding sometimes and needs to be reloaded? Even with having to reload it at unpredictable times (though I have noticed a trend with coming out of sleep mode in windows 7) it is still quite worthwhile. I would, however, love to get rid of this problem.

  41. joe

    Careful! Holding ALT and clicking on the desktop will move it on XP. How can you make this conditional?

    If you add this code, it will fix this. There a better way to do this?

    Alt & LButton::
    SetMouseDelay, -1
    MouseGetPos,,,hovwin ; Get window under mouse
    WinGetClass, hovclass, ahk_id %hovwin%
    IfNotEqual, hovclass, Progman
    IfNotEqual, hovclass, WorkerW


  42. joe

    This is a much better implementation than my previous post. It uses directives instead of the IfNotEqual function, so when you ALT+Click on the desktop, no mapping takes place (meaning, the desktop will get the mouse click since it wasn’t intercepted by AHK.)

    Add these two lines to the top of the script (before the ‘Alt & LButton::’ line):

    #If MouseIsNotOver(“ahk_class Progman”)
    #If MouseIsNotOver(“ahk_class WorkerW”)

    And add this function to the bottom of the script:

    MouseIsNotOver(WinTitle) {
    MouseGetPos,,, Win
    return !WinExist(WinTitle . ” ahk_id ” . Win)

    There you go, the desktop will no longer accidentally be moved! Although, you could always run the script without this change on a friends machine and really throw them off =)

  43. John

    Dude, awesome script.

  44. Jan

    I like your wallpaper, could you post it?

  45. suzunami

    hey thanks for this! i’ve been looking for a solution and this is the only app that solved my HP netbook screen limit.thanks

  46. Khan

    Dude, thank you.

    It speaks volumes that a few guys working on their own, for free, can remove these annoying oversights from Windows even after MS have had 7 tries to get it right.

  47. Hamid

    Kaspersky says it’s a malware.

  48. Me

    Yeah, ThreatFire does too, actually. So, who you gonna believe?
    (Hint: I run AHK.)

    “MS can’t get it right.”
    Ahhh, but you’re running what they DID get right, and paying them for the privilege. (What manager in Microsoft is going to spend all the time and effort and brownie points to change a basic function when it’s not on the list of items that they ARE responsible for?)

  49. Robi

    thanks much for taking the time to post this solution.

  50. Timo

    The only thing this is missing is ctrl+right click to resize the active window.

More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!