How do I use 'or's in AutoHotKey scripts?
autohotkey, conditional-statements
Solution
You could also try the following, I tested and it was working for me (AutoHotkey v1.1.14.01):
SetTitleMatchMode, REGEX
#IfWinActive (cygwin)|(mintty)
This uses the built-in OR mechanism of regular expressions. I couldn't get groups to work for some reason.
Problem
I have been browsing the AutoHotKey documentation, and I don't see a clear use of how to use 'or' in context specific hot keys. On my setup, Cygwin will either launch with ahk_class cygwin (when I use the context menu) or mintty (when I use the .bat or exe directly). Currently, I duplicate the hotkeys into two separate blocks, ``` #IfWinActive ahk_class cygwin ... #IfWinActive #IfWinActive ahk_class mintty ... #IfWinActive ``` Is there a way to combine them? I've tried: ``` #IfWinActive ahk_class cygwin ahk_class mintty #IfWinActive ahk_class || cygwin ahk_class mintty #IfWinActive ahk_class or cygwin ahk_class mintty #IfWinActive ahk_class cygwin || #IfWinActive ahk_class mintty #IfWinActive ahk_class cygwin or #IfWinActive ahk_class mintty #IfWinActive (ahk_class cygwin or ahk_class mintty) #IfWinActive (ahk_class cygwin || ahk_class mintty) #IfWinActive ahk_class cygwin|mintty #IfWinActive ahk_class cygwin||mintty ``` ...and none of these seem to work. This post states this can be accomplished with groups, but I'm looking for a way to combine them in a single statement.