Triggering an Action for Multiple ahk_class

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
DiMM
Posts: 2
Joined: 23 May 2018, 21:49

Triggering an Action for Multiple ahk_class

23 May 2018, 22:15

Hello there,
I'm trying to figure out how I can set one hotstring to trigger for only two specific ahk_class.

For the long way, I guess it goes something like this:

Code: Select all

#IfWinActive ahk_class Notepad
:*:hi::
    SendInput Hello there.
Return

#IfWinActive ahk_class MozillaWindowClass
:*:hi::
    SendInput Hello there.
Return
But is there any way to write it so it could save space, something like this?

Code: Select all

(#IfWinActive ahk_class Notepad) || (#IfWinActive ahk_class PuTTY)
:*:hi::
    SendInput Hello there.
Return
Any help is appreciated! Thank you very much! :D
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Triggering an Action for Multiple ahk_class

23 May 2018, 22:29

Try this:

Code: Select all

#If WinActive("ahk_class Notepad") || WinActive("ahk_class PuTTY")
:*:hi::
    SendInput Hello there.
Return
I hope that helps.
User avatar
BriHecato
Posts: 124
Joined: 18 Jul 2017, 07:17

Re: Triggering an Action for Multiple ahk_class

23 May 2018, 23:17

Or you can create group of those two classes with
GroupAdd
DiMM
Posts: 2
Joined: 23 May 2018, 21:49

Re: Triggering an Action for Multiple ahk_class

24 May 2018, 04:21

Thank you very much for both of your answers! It really helps a lot :)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: aitaixy, Anput, dangoscrub, Google [Bot], joedf, Nerafius and 159 guests