Code: Select all
#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.
SetBatchLines -1
#Persistent
desktopSwitched := false
Return
*F12::
; Wait for F12 to be released
While GetKeyState("F12", "P")
Sleep, 10
; Toggle desktops
ToggleDesktop()
Return
ToggleDesktop()
{
if (desktopSwitched)
{
; Switch back to the previous desktop
Send {Ctrl Down}{LWin Down}{Left}{LWin Up}{Ctrl Up}
}
else
{
; Switch to the next desktop
Send {Ctrl Down}{LWin Down}{Right}{LWin Up}{Ctrl Up}
}
; Toggle the desktopSwitched variable
desktopSwitched := !desktopSwitched
}