emendelson Posted October 5, 2010 Posted October 5, 2010 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!
AdmiralAlkex Posted October 5, 2010 Posted October 5, 2010 Look in the helpfile for: Run() FileExist() That should get you started .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
JohnOne Posted October 5, 2010 Posted October 5, 2010 _FileListToArray() could help if the file is of variable name. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
emendelson Posted October 5, 2010 Author Posted October 5, 2010 _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...
Calistoga Posted October 5, 2010 Posted October 5, 2010 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
guinness Posted October 5, 2010 Posted October 5, 2010 Or FileSystemMonitor UDF? UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
Calistoga Posted October 5, 2010 Posted October 5, 2010 Nice, whatever functionality you may seek... There's an UDF for it
emendelson Posted October 6, 2010 Author Posted October 6, 2010 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.
emendelson Posted October 6, 2010 Author Posted October 6, 2010 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now