As two separate scripts the hotkeys work as expected. Combining into one file the #^l and #^h hotkeys stop working. Is it a glitch or am I doing something wrong?

#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.

LAlt::LWin
LWin::LAlt
CapsLock::LCtrl

#^l::#^Right
#^h::#^Left
up vote 0 down vote accepted
#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.

LAlt::LWin
LWin::LAlt
CapsLock::LCtrl

; LAlt+CapsLock+l ; switch to next virtual desktop
#^l:: SendEvent {LWin down}{LCtrl down}{Right down}{LWin up}{LCtrl up}{Right up}
; LAlt+CapsLock+h ; switch to previous virtual desktop
#^h:: SendEvent {LWin down}{LCtrl down}{Left down}{LWin up}{LCtrl up}{Left up}

https://autohotkey.com/docs/commands/Send.htm#SendEvent

Tested on Win10.

Try this :

LAlt::
Send, {LWin down}
Send, {LWin up}
return

LWin::
Send, {Alt down}
Send, {Alt up}
return
  • Thanks for the reply, with this solution the Windows Tab function no longer works, and it does not resolve the previous issue. – OrigamiEye Nov 3 at 18:00
  • I just corrected these two problems, and the others can be solved similarly: You cannot map these because they are not real characters that can be replaced but events. You need to emulate the functionality of the keys by sending the up&down events. – harrymc Nov 3 at 18:03

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.