Applying an action only when a Control Panel window is active

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Quisquose
Posts: 74
Joined: 24 Jun 2016, 04:16

Applying an action only when a Control Panel window is active

17 Nov 2018, 09:08

I'm trying to set up two separate actions:

1. action that happens only when a Control Panel window is open and active (with the action only affecting that currently active Control Panel window)

2. action that only happens when a standard Windows Explorer file manager window is open and active (again, with the action only affecting that currently active Explorer window).

Seeing as the title of Control Panel windows will vary depending in which control panel section is being viewed at the time, I thought I would use text match rather than title match.

I set title match mode to 2 so that the words 'Control Panel' could be anywhere, but I can't even get it to work on its own, never mind in conjunction with my second rule that only affects Explorer windows.

Code: Select all

SetTitleMatchMode, 2
if WinExist("ahk_class CabinetWClass, , , Control Panel")

Any Idea how I could get these two rule sets to co-exist without affecting each other?
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Applying an action only when a Control Panel window is active

17 Nov 2018, 09:19

I would try something like this. Cheers.

Code: Select all

q:: ;check if active window is Control Panel
ControlGetText, vText, ToolbarWindow322, A
MsgBox, % vText
if InStr(vText, "Address: Control Panel")
	MsgBox, % "control panel: y"
else
	MsgBox, % "control panel: n"
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 217 guests