Skip to content

Instantly share code, notes, and snippets.

@ncronquist
Last active March 10, 2023 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ncronquist/8de841dbefa9f21e1a50854d2f48d1c9 to your computer and use it in GitHub Desktop.
Save ncronquist/8de841dbefa9f21e1a50854d2f48d1c9 to your computer and use it in GitHub Desktop.
AutoHotKey Script to Support Em Dash and Moving Windows Across Virtual Desktops
;#SETUP START
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance force
ListLines Off
SetBatchLines -1
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#KeyHistory 0
#WinActivateForce
Process, Priority,, H
SetWinDelay -1
SetControlDelay -1
;include the library
#Include VD.ahk
; VD.init() ;COMMENT OUT `static dummyStatic1 := VD.init()` if you don't want to init at start of script
;you should WinHide invisible programs that have a window.
WinHide, % "Malwarebytes Tray Application"
;#SETUP END
!-::
Send, —
return
VD.createUntil(3) ;create until we have at least 3 VD
return
^#+Left::
n := VD.getCurrentDesktopNum()
if n = 1
{
Return
}
n -= 1
VD.MoveWindowToDesktopNum("A",n), VD.goToDesktopNum(n)
Return
^#+Right::
n := VD.getCurrentDesktopNum()
if n = % VD.getCount()
{
Return
}
n += 1
VD.MoveWindowToDesktopNum("A",n), VD.goToDesktopNum(n)
Return
@ncronquist
Copy link
Author

When installing AutoHotKey, you will get the option to select ANSI or Unicode — make sure to select Unicode.

@ncronquist
Copy link
Author

Shortcuts from this Script

  • Em Dash - alt + -
  • Win+Ctrl+Shift+: Move current window to the next desktop
  • Win+Ctrl+Shift+: Move current window to the previous desktop

Setup

Instructions pulled from https://superuser.com/a/1728476/706553

  1. Download and install AutoHotKey
    • When installing AutoHotKey, you will get the option to select ANSI or Unicode — make sure to select Unicode.
  2. Clone the VD.ahk repository (it is an AutoHotkey library adding several script functions for managing virtual desktops)
  3. Inside the cloned directory, create a new file (arbitrary name, ending with .ahk) and paste the content from this gist into it.
  4. Double-click the script to run it. The shortcuts noted above should now work.
  5. To make sure the script runs on every Windows startup, create a shortcut to it and put it into the folder for your Startup programs. Open that folder by typing shell:startup in the window that pops up after you hit Win + R.

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