Sign in to follow this  
Followers 0
emendelson

Create Folder Watcher with AutoIt?

9 posts in this topic

Is it possible to create a "folder watcher" program in AutoIt? What I'm trying to is this: write a script that will

(1) launch an application (specifically DOSbox),

(2) remain running in the background, where it checks a specified folder every ten seconds to see if a file with a specified name has been written to that folder,

(3) when the file has been written, send it to another program for processing.

I want to be able to put the script on a USB stick, so it shouldn't require any writing to the registry.

Does this seem like something that's possible in AutoIt? If so, I'd be grateful if any expert user could point in the right direction so that I can get started. I'm fairly experienced in AutoIt, and would only need to know what functions to use to perform the folder-watcher feature.

Thanks!

Share this post


Link to post
Share on other sites



_FileListToArray() could help if the file is of variable name.

That's the one that will really get me started - thank you for that. I think it should be fairly easy from here on in.

Thanks again...

Share this post


Link to post
Share on other sites

In C# I would use the System.IO.FileSystemWatcher class to do this.

There is an equivalent in the Windows API which might be possible to implement i AutoIt. It would require some nice API ninja moves though ;)

Share this post


Link to post
Share on other sites

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Nice, whatever functionality you may seek... There's an UDF for it ;)

Share this post


Link to post
Share on other sites

Is there a straightforward way to find out if a file is in use? In the script I'm writing, I want to detect that a file has been written to disk, and then send the file to Ghostscript to be printed - but I need to know if the file is still being written, so I can wait until it's complete.

I could presumably test the file size, and then test the size again two seconds later, and if the two sizes match, I could assume that the file is no longer in use. But is there a more straightforward and reliable way to do this?

Thanks again for everyone's help in this thread.

Share this post


Link to post
Share on other sites

To answer my own question about whether a file is in use, I just found this:

http://www.autoitscript.com/forum/index.php?showtopic=53994

Apologies for wasting bandwidth, but maybe the link will be useful to others.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0