I have spent the past couple of days searching for the answer to this question, and I have not found one that really works.
What I am trying to do, is have the following code always run and when ever notepad is open and idle for more then 2 seconds close it. It works but only when their is one instance of Notepad, if there are more then one it does not close all of them at the same time.
Can someone help me, using this code, to have all windows with the title Notepad close?
Thanks
Grimm
What I am trying to do, is have the following code always run and when ever notepad is open and idle for more then 2 seconds close it. It works but only when their is one instance of Notepad, if there are more then one it does not close all of them at the same time.
Can someone help me, using this code, to have all windows with the title Notepad close?
[ autoit ]
#include <Timers.au3> ;Declare the Timer: ; Global $TIMER = TimerInit() Opt("TrayOnEventMode",1) Opt("TrayMenuMode",1) HotKeySet("#{F4}", "_exit") ; Ctrl-Shift-Alt-X to exit While 1 ;If this application is active then reset the timer: If WinExists("Notepad") And _Timer_GetIdleTime() >= 2 * 1000 Then MsgBox (0, "Time reached", "You have been idle for more than 2 seconds.") WinClose("Notepad") EndIf ;Sleep for 1 seconds before looping again: ; Sleep(1000) WEnd Func _exit() Exit EndFunc
Thanks
Grimm