Aw4lly Posted December 6, 2010 Share Posted December 6, 2010 Hey guys,I'm new to Autoit and I've just written a file which opens the newest image in the directory. When I run the AU3 in AutoIt or the exe directly it works perfectly, if I run C:/ftp/file.au3 or C:/ftp/file.exe while in the directory it works perfectly however if I run C:/ftp/file.au3 while not in the correct directory it doesn't find my any files. All the references are absolute but it just doesn't seem to work.Has anyone else had the same problem or know how to fix it?Cheers, Link to comment Share on other sites More sharing options...
Realm Posted December 6, 2010 Share Posted December 6, 2010 Hello Aw4lly, First, Welcome to the AutoIt Forums Secondly, When asking for help you should do at least 3 things: 1) Include a complete description of What results you expect of your script. Check 2) Include a complete description of the problem/errors your encountering. Check 3) Include your code, or at least an example of it. Missing. Without seeing your code, it is very difficult to pinpoint the problem is on line 21,352. However, I would guess it needs other files to run, in which you are probably using something like @ScriptDir as a path address to your file. at which moving the application to a different directory while keeping the needed files in the old directory would definately break an @ScriptDir address. If this is not the case, I would suggest showing an example of your code in order for anyone to help you find what is wrong. Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. Link to comment Share on other sites More sharing options...
Aw4lly Posted December 7, 2010 Author Share Posted December 7, 2010 (edited) Hello, Sorry, I mustn't have attatched the code properly. Hopefully this works now. This script just needs to display the most recent image in whatever is default on the system, Windows Picture Viewer probably. display_image.au3 Cheers, *Edit* I should note that if the script is run from anywhere from within AutoIt it works correctly as well. Its just command line which seems to not work. Edited December 7, 2010 by Aw4lly Link to comment Share on other sites More sharing options...
Realm Posted December 7, 2010 Share Posted December 7, 2010 (edited) Aw4lly, FileFindNextFile() returns the next file name and extension, but not the full path, when you check for the file time, you need to use the full path. #include <Process.au3> Local $latestFile ;This needs to be declared before use $search = FileFindFirstFile("C:\ftp\*.jpg") ;~ $file = "string" $modified_dt = 0 If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop If FileGetTime("C:\ftp\" & $file,0,1) > $modified_dt Then ;needed full path to get the file time. $modified_dt = FileGetTime($file,0,1) $latestFile = $file EndIf WEnd FileClose($search) _RunDOS("Start C:\ftp\" & $latestFile) Realm Edit: Your original app was only working in the ftp directory, cause without the path it would attempt to get the filetime of the file called in the same directory of your application. Edited December 7, 2010 by Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. Link to comment Share on other sites More sharing options...
Aw4lly Posted December 7, 2010 Author Share Posted December 7, 2010 Hey, Thanks heaps for the help, I've been looking over it for ages but haven't been able to see what the problem was, I assumed it was something little and stupid like that though. Cheers, Link to comment Share on other sites More sharing options...
Realm Posted December 7, 2010 Share Posted December 7, 2010 Thanks heaps for the helpMy Pleasure, I had the time.Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. Link to comment Share on other sites More sharing options...
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