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}"
}