How to distinguis apps/windows? Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
User avatar
WizardM
Posts: 43
Joined: 18 Mar 2023, 23:08

How to distinguis apps/windows?

Post by WizardM » 24 Mar 2023, 22:15

Can someone pls advise how to make the following script distinguish between the app in script row 4 (Sniper Fury) and the app in script row 22 (WhatsApp).

Code: Select all

#Requires AutoHotkey v2.0

; Sniper Fury Arena keyboard layout
		#HotIf WinActive("ahk_exe ApplicationFrameHost.exe")
		$f::Send("{f down}"), Sleep(10), Send("{f up}"), Sleep(10), Send("{r down}"), Sleep(10), Send("{r up}") ; macro
		t::1
		g::2
		d::3
		e::4
		$F12::SendText("This is an F12 test of SendText for Sniper Fury")

; Text processing keyboard layout
	GroupAdd "MyTextGroup", "ahk_class Notepad" ; Notepad
	GroupAdd "MyTextGroup", "ahk_class WordPadClass" ; Wordpad
	GroupAdd "MyTextGroup", "ahk_exe WinWord.exe" ; MS Office Word
		#HotIf WinActive("ahk_group MyTextGroup")
		$F12::SendText("This is an F12 test of SendText for text processing (MyTextGroup)")

; Soocial Communication keyboard layout
	GroupAdd "MySocialGroup", "ahk_exe Discord.exe" ; Discord
	GroupAdd "MySocialGroup", "ahk_exe Messenger.exe" ; Fb Messenger
	GroupAdd "MySocialGroup", "ahk_class ApplicationFrameWindow" ; WhatsApp
	GroupAdd "MySocialGroup", "ahk_exe Viber.exe" ; Viber
	GroupAdd "MySocialGroup", "ahk_exe Telegram.exe" ; Telegram
	GroupAdd "MySocialGroup", "ahk_exe Signal.exe" ; Signal
		#HotIf WinActive("ahk_group MySocialGroup")
		$F12::SendText("This is an F12 test of SendText for Social Communication (MySocialGroup)")
This is the Window Spy result for the app in row 4. (Sniper Fury downloaded from MS Store)
https://photos.app.goo.gl/M3m6BD6Tqen5dmz29

This is the Window Spy result for the app in row 21. (I suspect I probably downloaded this from the MS Store as well)
https://photos.app.goo.gl/heQhNc9FgLdPSY6q6

ntepa
Posts: 406
Joined: 19 Oct 2022, 20:52

Re: How to distinguis apps/windows?  Topic is solved

Post by ntepa » 24 Mar 2023, 23:03

You can specify the title along with the ahk_criteria:

Code: Select all

#HotIf WinActive("Sniper Fury ahk_exe ApplicationFrameHost.exe")

Code: Select all

GroupAdd "MySocialGroup", "WhatsApp ahk_class ApplicationFrameWindow"

User avatar
WizardM
Posts: 43
Joined: 18 Mar 2023, 23:08

Re: How to distinguis apps/windows?

Post by WizardM » 25 Mar 2023, 00:20

@ntepa
Perfect, thank you very much.

Post Reply

Return to “Ask for Help (v2)”