| View previous topic :: View next topic |
| Author |
Message |
Noobee Guest
|
Posted: Tue Nov 13, 2007 5:26 am Post subject: Run script when file added to a directory |
|
|
I need a script that will watch a certain directory and then run a script when a file is added to the directory. Can this be accomplished? Can ahk scripts run other ahk scripts in this manner?
Thanks in advanced! |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6772 Location: Pacific Northwest, US
|
|
| Back to top |
|
 |
NooBee Guest
|
Posted: Tue Nov 13, 2007 2:04 pm Post subject: re: Run script when file added to a directory |
|
|
I was able to run the referenced script but I am not yet proficent enough to modify the script to suit my needs. I get lost in the loops.
Does anyone else have a simpler example? |
|
| Back to top |
|
 |
Xander
Joined: 23 Sep 2007 Posts: 142
|
Posted: Tue Nov 13, 2007 6:48 pm Post subject: |
|
|
I don't know if there is a way to be notified when a file is added to a directory, but you could create your own monitoring of the directory.
| Code: | #NoEnv
PreviousFiles := GetFiles()
SetTimer, CheckFiles, 1000
return
CheckFiles:
Files := GetFiles()
if (Files != PreviousFiles)
Run, Script.ahk
PreviousFiles := Files
return
GetFiles() {
files := ""
Loop, C:\
files .= A_LoopFileName
return files
} |
|
|
| Back to top |
|
 |
NooBee Guest
|
Posted: Wed Nov 14, 2007 4:24 am Post subject: |
|
|
I still don't get it I have added a beep to the GetFiles check so I know the code enters this point but files do not appear to be concatenated to the files="" because I don't get a beep when Files != PreviousFiles
Thanks for your patience
| Code: |
#NoEnv
#Persistent
PreviousFiles := GetFiles()
SetTimer, CheckFiles, 2000
return
CheckFiles:
Files := GetFiles()
if (Files != PreviousFiles)
{
SoundBeep, 750, 500
;Run, C:\ok.ahk
}
PreviousFiles := Files
return
GetFiles() {
files := ""
Loop, C:\WatchFolder
files .= A_LoopFileName
return files
}
|  |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6772 Location: Pacific Northwest, US
|
Posted: Wed Nov 14, 2007 4:35 am Post subject: |
|
|
time to learn some debugging tools such as msgbox, listvars, listlines, pause, OutputDebug, etc. _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
|