You can't use <If> in a command. It can only go in a hotkey. You can call a hotkey from a command with <DoHotkey> .