thanks very much, lanux128.
i've commented out the tooltip in the loop as it wouldn't stop floating around my cursor when it appeared.
is it a complicate addition to make the loop perform different actions depending on which window is activated?
currently it works fine for me - as the "Yes" button is always the one to click in the dialogs used. but i expect this will not always be the case.
here's the current script.
#Persistent
#SingleInstance force
#NoEnv
;#NoTrayIcon
SetBatchLines, -1
SetTitleMatchMode, 2 ; partial title match
SetWorkingDir, %A_ScriptDir%
DetectHiddenWindows, Off ; they are hidden for a reason..
Gosub, Get_INI ; go to INI section
IfExist, %TrayIcon% ;TrayMenu Customisation
Menu, Tray, Icon, %TrayIcon%
Menu, Tray, Tip, Activate the specified window/dialog whenever it appears.
SetTimer, ActivateMe, 500 ; timer starts - increase or decrease the value as necessary
Return
ActivateMe:
;parse and auto-activate
Loop, Parse, WatchThese, |
{
;Tooltip, %A_LoopField%
IfWinExist %A_LoopField%
{
WinActivate ;do something here like press the ok button
ControlClick, Yes
;sleep for a while - good for cpu cycle
Sleep, 2000
}
}
Return
Get_INI:
If (!FileExist("ActivateDialogs.ini")) ;if the ini file doesn't exist, create it with the info below
{
FileAppend, [Settings]`nWatchThese=File has changed ahk_class #32770|Delete Shortcut ahk_class #32770`nTrayIcon=Application-warn.ico, ActivateDialogs.ini
}
IniRead,WatchThese,ActivateDialogs.ini,Settings,WatchThese
IniRead,TrayIcon,ActivateDialogs.ini,Settings,TrayIcon
Return