Jump to content

VADemon

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by VADemon

  1. Thanks to you both for a very simple example and question. I had the exact same issue, _GetText and other like ControlTreeView did not return a text. Updating from AutoIt 3.3.16.0 to 3.3.16.1 solved the issue for me. No reboot was required.
  2. Solved the mystery: As careca said, THE FILE WAS LOCKED. Although I opened the file in READ-ONLY in my code and the file was also opened READ-ONLY by MediaPlayerClassic - apparently it was enough for Windows to deny file access to my AutoIt script... Damn! I also found out why: The _WinAPI_CreateFile() doc states: _WinAPI_CreateFile ( $sFileName, $iCreation [, $iAccess = 4 [, $iShare = 0 [, $iAttributes = 0 [, $tSecurity = 0]]]] ) Local $fHandle = _WinAPI_CreateFile($sFilePath, 2, 2) ; read-only Do you see it? Although I opened the file as read-only, the DEFAULT $iShare access in Au3 is set to NOT SHARE (==0). So if you open the file in really read-only, to get it's metadata, you want to allow ANY kind of access. Be it another read-only, write or delete: Local $fHandle = _WinAPI_CreateFile($sFilePath, 2, 2, 7) ; read-only and share any Now the file can be opened by my media player and I can retrieve its metadata in background! I didn't know a read-only access had to be allowed in the API call, I just assumed it by default.
  3. Thanks guys for the answers, took me too long to notice because I was supposed to be notified by email. I was going to test VIP's code to debug, but the problem has somehow resolved itself. The exact same code of mine now returns the correct date and parses it without problems... A very strange edge-case. I don't think it was a lock problem like careca said, because these files shouldn't have been accessed by any programs and my tool opened them in read-mode anyway (to fetch the date). In any way, I developed the code above in one go without reboots, maybe that fixed it. Windows 7 SP1 64-bit, NTFS. /thread
  4. I've encountered a problem with a single file where I cannot retrieve it's Date-time. So far my code has worked well for over 30 files, but this one is a mystery I cannot debug myself due to insufficient Au3 knowledge. In line 11 "_Date_Time_FileTimeToArray" is called and for this particular file it sets the @error to 10. I don't know what that error code means, but it's not set by the _Date functions themselves I think. Overall, it could be a problem caused by any of the functions below, how can I properly debug this? / Does anybody know a what's causing this? _WinAPI_CreateFile() / _Date_Time_GetFileTime() / _Date_Time_FileTimeToArray() Func _SetFileTimes($sFilePath) Local $monthNumber[13] = ["", "January", "February", "March", "April", "May", "Juny", "July", "August", "September", "October", "November", "December"] Local $dayNumber[7] = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] Local $fHandle = _WinAPI_CreateFile($sFilePath, 2, 2) ; read-only ; may NOT return a valid date for some reason! TODO Local $fTagFILETIME = _Date_Time_GetFileTime($fHandle) _WinAPI_CloseHandle($fHandle) ; This will return an empty array if theres no valid date $fModTime = _Date_Time_FileTimeToArray($fTagFILETIME[2]) ; last Modified if @error <> 10 then Local $year = $fModTime[2] Local $month = $fModTime[0] Local $day = $fModTime[1] Local $hour = $fModTime[3] Local $min = $fModTime[4] Local $sec = $fModTime[5] Local $ms = $fModTime[6] Local $weekday = $fModTime[7] Global $prettyTimestamp = StringFormat("%s, %s %d, %04d %02d:%02d:%02d", $dayNumber[$weekday], $monthNumber[$month], $day, $year, $hour, $min, $sec) Global $uploadDate = StringFormat("%04d-%02d-%02d", $year, $month, $day) $fModTime = _Date_Time_FileTimeToArray(_Date_Time_FileTimeToLocalFileTime($fTagFILETIME[2])) ; last Modified Local $year = $fModTime[2] Local $month = $fModTime[0] Local $day = $fModTime[1] Local $hour = $fModTime[3] Local $min = $fModTime[4] Local $sec = $fModTime[5] Local $ms = $fModTime[6] Local $weekday = $fModTime[7] ; GetUnixTime accounts for Local time, hence feed it local time Global $unixTimestamp = _GetUnixTime($year &"/"& $month &"/"& $day &" "& $hour&":"& $min &":"& $sec) else Global $prettyTimestamp = "N/A" Global $uploadDate = "" Global $unixTimestamp = "N/A" endif endfunc _GetUnixTime returned the year 1601 start date, showing that $fModTime is probably equal 0. (But Why?) The file reports these dates in Explorer, it's on local NTFS drive: Created: ‎‎Wednesday, ‎31. ‎Januar ‎2018, ‏‎18:55:02 Modified: ‎Wednesday, ‎10. ‎Januar ‎2018, ‏‎12:39:23 Accessed: ‎Wednesday, ‎10. ‎Januar ‎2018, ‏‎12:39:23
×
×
  • Create New...