Search code examples
windowsautomationwindows-10keyboard-shortcutsautohotkey

How to reassign the "Sign out" shortcut using AutoHotkey?


I often find myself mistyping the "Sleep" shortcut as "Sign out". So I want to disable the shortcut for it, i.e. Win+XUI:

enter image description here

And reassign it to Win+XUO, how to achieve this using AutoHotkey?


Solution

  • If you want to use AutoHotkey (and not the Group Policy Editor in Windows or another tool) try this:

    #NoEnv
    #InstallMouseHook
    
    ~#x::Return ; The tilde prefix (~) prevents AHK from blocking the key-down/up events (#x passes through)
    
    ; A_PriorHotKey is the most recently executed hotkey
    ; A_PriorKey is the last key pressed
    ; Using the #If-directive you can create context-sensitive hotkeys and hotstrings
    
    #If (A_PriorHotkey == "~#x" && A_PriorKey = "u")
      i::Return ; Do nothing
      o::Send i
    #If