#j::
IfWinActive, ahk_class CabinetWClass
{
SetTitleMatchMode, 3
WinGetTitle, active_title, A
for window in ComObjCreate("Shell.Application").Windows
try address := % window.Document.Folder.Self.Path ; http://ahkscript.org/boards/viewtopic.php?p=28751#p28751
; MsgBox, "%address%"
SetTimer, FileAdded, 500
}
return
FileAdded:
Loop, %address%\*.*
{
now := %A_Now%
EnvSub, now, %A_LoopFileTimeCreated%, seconds
If now < 2 ; newer as 2 seconds
{
SetTimer, FileAdded, off
; MsgBox a new file `n%A_LoopFileFullPath% `nis added in %address%
; Run, %address% ; if the explorer window has been closed in the meantime
WinWait, %active_title%
WinActivate, %active_title%
WinWaitActive, %active_title%
; Send, your keys
; Sleep some time
; SetTimer, FileAdded, on
}
}
return