Open .cpl item, wait for window, close it

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
AniRayn
Posts: 2
Joined: 30 Sep 2017, 06:00

Open .cpl item, wait for window, close it

Post by AniRayn » 04 Feb 2023, 05:15

Hello,

Sorry if this is too much of a noob question.
I want to just open a .cpl item, wait for its window to appear, and immediately close it.
Problem is that sometimes the window stays closed. Can't tell if it's due to wrong focus or Esc being sent too early.
Could you suggest another way for waiting on the window and then closing it?

Code: Select all

OpenCplAndClose(item_name)
{
	ProcessPid := 0
	Run "rundll32.exe shell32.dll, Control_RunDLL " item_name ",,",,,&ProcessPid
	WinWait "ahk_pid" ProcessPid
	WinActivate  "ahk_pid" ProcessPid
	Send "{Esc}"
}


Post Reply

Return to “Ask for Help (v2)”