Jump to content
Sign in to follow this  
VADemon

File not returning a valid time/date

Recommended Posts

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

Share this post


Link to post
Share on other sites

Try FileGetTime.

Other than that, the file is in use by some program that locks it or something, or is in read mode.

Dont see other options. Maybe a bug.


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites

I don't know it help help for you or not:

#include <WinAPIFiles.au3>
#include <WinAPIHObj.au3>
#include <Date.au3>
#include <FileConstants.au3>

Global $iFileToWork = @ScriptFullPath

FileSetTime($iFileToWork, @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC, $FT_CREATED)
FileSetTime($iFileToWork, @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC, $FT_MODIFIED)
FileSetTime($iFileToWork, @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC, $FT_ACCESSED)

_FileGetTime($iFileToWork)


Func _FileGetTime($sFilePath)

    Local $Created_ArrayFileTime = FileGetTime($sFilePath, $FT_CREATED) ;  $FT_CREATED (1) = Created
    Local $Created_iYear = $Created_ArrayFileTime[0] ; = year (four digits)
    Local $Created_iMonth = $Created_ArrayFileTime[1] ; = month (range 01 - 12)
    Local $Created_iDay = $Created_ArrayFileTime[2] ; = day (range 01 - 31)
    Local $Created_iHour = $Created_ArrayFileTime[3] ; = hour (range 00 - 23)
    Local $Created_iMin = $Created_ArrayFileTime[4] ; = min (range 00 - 59)
    Local $Created_iSec = $Created_ArrayFileTime[5] ; = sec (range 00 - 59)
    Local $Created_iDayOfWeek = _DateToDayOfWeek($Created_iYear, $Created_iMonth, $Created_iDay)
    Local $Created_iDayName = _DateDayOfWeek($Created_iDayOfWeek)
    Local $Created_iMonthName = _DateToMonth($Created_iMonth)
    Local $Created_iShortTime = $Created_iYear & $Created_iMonth & $Created_iDay & $Created_iHour & $Created_iMin & $Created_iSec
    Local $Created_iLongTime = $Created_iYear & "/" & $Created_iMonth & "/" & $Created_iDay & " - " & $Created_iHour & ":" & $Created_iMin & ":" & $Created_iSec
    Local $Created_iLongTimeName = $Created_iDayName & "," & $Created_iMonthName & " " & $Created_iDay & "," & $Created_iYear
    ConsoleWrite("! File   : " & $sFilePath & @CRLF)
    ConsoleWrite("-DATE Created  : " & $Created_iLongTimeName & @CRLF)
    ConsoleWrite(">DATE Created S: " & $Created_iLongTime & @CRLF)
    ConsoleWrite("+DATE Created L: " & $Created_iShortTime & @CRLF)
    ConsoleWrite("-Year     : " & $Created_iYear & @CRLF)
    ConsoleWrite("-Mont     : " & $Created_iMonth & @CRLF)
    ConsoleWrite("-Day      : " & $Created_iDay & @CRLF)
    ConsoleWrite("-Hour     : " & $Created_iHour & @CRLF)
    ConsoleWrite("-Min      : " & $Created_iMin & @CRLF)
    ConsoleWrite("-Sec      : " & $Created_iSec & @CRLF)
    ConsoleWrite("-DayOfWeek: " & $Created_iDayOfWeek & @CRLF)
    ConsoleWrite("-DayName  : " & $Created_iDayName & @CRLF)
    ConsoleWrite("-MonthName: " & $Created_iMonthName & @CRLF)

    Local $Modified_ArrayFileTime = FileGetTime($sFilePath, $FT_MODIFIED) ;$FT_MODIFIED (0) = Last modified
    Local $Modified_iYear = $Modified_ArrayFileTime[0] ; = year (four digits)
    Local $Modified_iMonth = $Modified_ArrayFileTime[1] ; = month (range 01 - 12)
    Local $Modified_iDay = $Modified_ArrayFileTime[2] ; = day (range 01 - 31)
    Local $Modified_iHour = $Modified_ArrayFileTime[3] ; = hour (range 00 - 23)
    Local $Modified_iMin = $Modified_ArrayFileTime[4] ; = min (range 00 - 59)
    Local $Modified_iSec = $Modified_ArrayFileTime[5] ; = sec (range 00 - 59)
    Local $Modified_iDayOfWeek = _DateToDayOfWeek($Modified_iYear, $Modified_iMonth, $Modified_iDay)
    Local $Modified_iDayName = _DateDayOfWeek($Modified_iDayOfWeek)
    Local $Modified_iMonthName = _DateToMonth($Modified_iMonth)
    Local $Modified_iShortTime = $Modified_iYear & $Modified_iMonth & $Modified_iDay & $Modified_iHour & $Modified_iMin & $Modified_iSec
    Local $Modified_iLongTime = $Modified_iYear & "/" & $Modified_iMonth & "/" & $Modified_iDay & " - " & $Modified_iHour & ":" & $Modified_iMin & ":" & $Modified_iSec
    Local $Modified_iLongTimeName = $Modified_iDayName & "," & $Modified_iMonthName & " " & $Modified_iDay & "," & $Modified_iYear
    ConsoleWrite("! File   : " & $sFilePath & @CRLF)
    ConsoleWrite("-DATE Modified  : " & $Modified_iLongTimeName & @CRLF)
    ConsoleWrite(">DATE Modified S: " & $Modified_iLongTime & @CRLF)
    ConsoleWrite("+DATE Modified L: " & $Modified_iShortTime & @CRLF)
    ConsoleWrite("-Year     : " & $Modified_iYear & @CRLF)
    ConsoleWrite("-Mont     : " & $Modified_iMonth & @CRLF)
    ConsoleWrite("-Day      : " & $Modified_iDay & @CRLF)
    ConsoleWrite("-Hour     : " & $Modified_iHour & @CRLF)
    ConsoleWrite("-Min      : " & $Modified_iMin & @CRLF)
    ConsoleWrite("-Sec      : " & $Modified_iSec & @CRLF)
    ConsoleWrite("-DayOfWeek: " & $Modified_iDayOfWeek & @CRLF)
    ConsoleWrite("-DayName  : " & $Modified_iDayName & @CRLF)
    ConsoleWrite("-MonthName: " & $Modified_iMonthName & @CRLF)

    Local $Accessed_ArrayFileTime = FileGetTime($sFilePath, $FT_ACCESSED) ; $FT_ACCESSED (2) = Last accessed
    Local $Accessed_iYear = $Accessed_ArrayFileTime[0] ; = year (four digits)
    Local $Accessed_iMonth = $Accessed_ArrayFileTime[1] ; = month (range 01 - 12)
    Local $Accessed_iDay = $Accessed_ArrayFileTime[2] ; = day (range 01 - 31)
    Local $Accessed_iHour = $Accessed_ArrayFileTime[3] ; = hour (range 00 - 23)
    Local $Accessed_iMin = $Accessed_ArrayFileTime[4] ; = min (range 00 - 59)
    Local $Accessed_iSec = $Accessed_ArrayFileTime[5] ; = sec (range 00 - 59)
    Local $Accessed_iDayOfWeek = _DateToDayOfWeek($Accessed_iYear, $Accessed_iMonth, $Accessed_iDay)
    Local $Accessed_iDayName = _DateDayOfWeek($Accessed_iDayOfWeek)
    Local $Accessed_iMonthName = _DateToMonth($Accessed_iMonth)
    Local $Accessed_iShortTime = $Accessed_iYear & $Accessed_iMonth & $Accessed_iDay & $Accessed_iHour & $Accessed_iMin & $Accessed_iSec
    Local $Accessed_iLongTime = $Accessed_iYear & "/" & $Accessed_iMonth & "/" & $Accessed_iDay & " - " & $Accessed_iHour & ":" & $Accessed_iMin & ":" & $Accessed_iSec
    Local $Accessed_iLongTimeName = $Accessed_iDayName & "," & $Accessed_iMonthName & " " & $Accessed_iDay & "," & $Accessed_iYear
    ConsoleWrite("! File   : " & $sFilePath & @CRLF)
    ConsoleWrite("-DATE Accessed  : " & $Accessed_iLongTimeName & @CRLF)
    ConsoleWrite(">DATE Accessed S: " & $Accessed_iLongTime & @CRLF)
    ConsoleWrite("+DATE Accessed L: " & $Accessed_iShortTime & @CRLF)
    ConsoleWrite("-Year     : " & $Accessed_iYear & @CRLF)
    ConsoleWrite("-Mont     : " & $Accessed_iMonth & @CRLF)
    ConsoleWrite("-Day      : " & $Accessed_iDay & @CRLF)
    ConsoleWrite("-Hour     : " & $Accessed_iHour & @CRLF)
    ConsoleWrite("-Min      : " & $Accessed_iMin & @CRLF)
    ConsoleWrite("-Sec      : " & $Accessed_iSec & @CRLF)
    ConsoleWrite("-DayOfWeek: " & $Accessed_iDayOfWeek & @CRLF)
    ConsoleWrite("-DayName  : " & $Accessed_iDayName & @CRLF)
    ConsoleWrite("-MonthName: " & $Accessed_iMonthName & @CRLF)

    
EndFunc   ;==>_FileGetTime

 


Regards,
 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
On 11/11/2018 at 7:19 PM, careca said:

Other than that, the file is in use by some program that locks it or something, or is in read mode.

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).

Quote
$iShare [optional] Sharing mode of an object:
    1 - Delete
    2 - Read
    4 - Write

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.

Edited by VADemon

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By UEZ
      Here another approach to check if a script was already started using atoms and semaphores.
       
      Atom:
      #include <MsgBoxConstants.au3> Global $iSingleton = Singleton() If Not $iSingleton Then Exit MsgBox($MB_TOPMOST, "Singleton Test", "Process is already running!") EndIf MsgBox($MB_TOPMOST, "Singleton Test", "Singleton atom initialized: " & $iSingleton) Singleton_Delete($iSingleton) ; #FUNCTION# ==================================================================================================================== ; Name ..........: Singleton ; Description ...: Checks if the script has been started already. ; Syntax ........: Singleton([$sOccurrenceName = @ScriptFullPath]) ; Parameters ....: $sOccurrenceName - [optional] a string value. Default is @ScriptFullPath. ; Return values .: If the function succeeds, the return value is the newly created atom or 0 else error is set and false is returned. ; Author ........: UEZ ; Modified ......: ; Remarks .......: If Singleton finds the atom it will return 0 and the atom token will be set to extended macro. It can be used to get the atom string using _WinAPI_AtomGlobalGetName. ; Related .......: ; Link ..........: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-globalfindatomw ; https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-globaladdatomw ; Example .......: No ; =============================================================================================================================== Func Singleton($sOccurrenceName = @ScriptFullPath) Local $iFind = _WinAPI_AtomGlobalFind($sOccurrenceName) If @error Then Return SetError(1, 0, False) If $iFind Then Return SetExtended($iFind, 0) Local $iAtom = _WinAPI_AtomGlobalAdd($sOccurrenceName) If @error Then Return SetError(2, 0, False) Return $iAtom EndFunc ;==>Singleton ; #FUNCTION# ==================================================================================================================== ; Name ..........: Singleton_Delete ; Description ...: Deletes the atom generated by the first started script. ; Syntax ........: Singleton_Delete($iAtom) ; Parameters ....: $iAtom - an integer value which was generated by Singleton ; Return values .: True if successful else false. ; Author ........: UEZ ; Modified ......: ; Remarks .......: Don't forget to call Singleton_Delete before first started script ends. ; Related .......: ; Link ..........: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-globaldeleteatom ; Example .......: No ; =============================================================================================================================== Func Singleton_Delete($iAtom) _WinAPI_AtomGlobalDelete($iAtom) If @error Then Return SetError(1, 0, False) Return True EndFunc ;==>Singleton_Delete ;internal functions Func _WinAPI_AtomGlobalFind($sAtomString) Local $aReturn = DllCall("kernel32.dll", "short", "GlobalFindAtomW", "wstr", $sAtomString) If @error Then Return SetError(1, 0, -1) Return $aReturn[0] EndFunc ;==>_WinAPI_AtomGlobalFind Func _WinAPI_AtomGlobalAdd($sAtomString) Local $aReturn = DllCall("kernel32.dll", "short", "GlobalAddAtomW", "wstr", $sAtomString) If @error Then Return SetError(1, 0, -1) Return $aReturn[0] EndFunc ;==>_WinAPI_AtomGlobalAdd Func _WinAPI_AtomGlobalDelete($nAtom) Local $aReturn = DllCall("kernel32.dll", "short", "GlobalDeleteAtom", "short", $nAtom) If @error Then Return SetError(1, 0, -1) Return $aReturn[0] = 0 EndFunc ;==>_WinAPI_AtomGlobalDelete Func _WinAPI_AtomGlobalGetName($nAtom, $iBufferSize = 512) Local $tBufferAtom = DllStructCreate("wchar name[" & $iBufferSize & "]") Local $aReturn = DllCall("kernel32.dll", "uint", "GlobalGetAtomNameW", "short", $nAtom, "struct*", $tBufferAtom, "int", $iBufferSize) If @error Or Not $aReturn[0] Then Return SetError(1, 0, -1) Return $tBufferAtom.name EndFunc ;==>_WinAPI_AtomGlobalGetName  
      Semaphore:
      #include <MsgBoxConstants.au3> #include <WinAPIError.au3> Global $iSingleton = Singleton("&]8h/x87</htFV4-K*&.b.w~") If Not $iSingleton Then Exit MsgBox($MB_TOPMOST, "Singleton Test", "Process is already running!") EndIf MsgBox($MB_TOPMOST, "Singleton Test", "Singleton Semaphore initialized: " & $iSingleton) ; #FUNCTION# ==================================================================================================================== ; Name ..........: Singleton ; Description ...: Checks if the script has been started already. ; Syntax ........: Singleton($sOccurrenceName) ; Parameters ....: $sOccurrenceName - a string value which will be used to create the semaphore handle. ; Return values .: True if Singleton started the first time. False if script was already started ; Author ........: UEZ ; Modified ......: ; Remarks .......: The system closes the handle automatically when the process terminates. The semaphore object is destroyed when its last handle has been closed. ; Related .......: ; Link ..........: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createsemaphorea ; Example .......: No ; =============================================================================================================================== Func Singleton($sOccurrenceName) If StringLen($sOccurrenceName) > 260 Then $sOccurrenceName = StringLeft($sOccurrenceName, 260) Local $aReturn = DllCall("kernel32.dll", "handle", "CreateSemaphoreA", "ptr", Null, "long", 0, "long", 1, "str", $sOccurrenceName) If @error Or Not $aReturn[0] Then Return SetError(1, 0, -1) Return SetExtended($aReturn[0], $aReturn[0] And _WinAPI_GetLastErrorMessage() = "The operation completed successfully.") EndFunc ;==>Singleton  
      Just start the script twice to see if it works.
       
      Thanks to jj2007 and SARG.
    • By BlueSkyMemory
      Hello guys! I'm a rookie in AutoIt lol.
      I've tried to looking up in MSDN and the UDFs, but it can only get the GUID of a usual partition and with the GUID to control it. Now I have no ways😥.
      Thanks a lot for your help!
    • By emendelson
      Using some very ingenious scripts that I found on this forum, I've put together a special-purpose folder watcher that watches a specified folder for printer output files and then either send them to a printer or converts them to a PDF and prints or opens the PDF. The page about this utility is here:
      http://www.columbia.edu/~em36/printfileprinter.html
      The one serious problem that it has is that it seems not to detect a new file if there are more than two or three files already in the watched folder. I can't figure out what I'm doing wrong, and will be grateful for any help. Here is the relevant part of the script. I've left out the functions that test whether the file is in use or not, and that send the raw data to the printer or create a PDF, etc. I hope there's enough code here to make sense of it, and will be very grateful for any help. Again, the problem is that the script doesn't detect newly-created files in watched folders with more than a very few files already in it.
      My totally ignorant guess is that the problem is in the line $iID = _WinAPI_WaitForMultipleObjects(2, $paObj, 0, 0) - but I don't know how to change it and of course I'm only guessing whether it's relevant or not. Many thanks
       
      Global $g_ahObj[2] $g_ahObj[0] = _WinAPI_FindFirstChangeNotification($watchPath, $FILE_NOTIFY_CHANGE_FILE_NAME) $g_ahObj[1] = _WinAPI_FindFirstChangeNotification($watchPath, $FILE_NOTIFY_CHANGE_DIR_NAME) If (Not $g_ahObj[0]) Or (Not $g_ahObj[1]) Then MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create change notification.') Exit EndIf Local $tObjs = DllStructCreate('ptr;ptr') Local $paObj = DllStructGetPtr($tObjs) For $i = 0 To 1 DllStructSetData($tObjs, $i + 1, $g_ahObj[$i]) Next Local $iID While 1 Sleep(100) $select = 0 $print = 0 $format = "" Local $tempPDF $tempPDF = 0 $iID = _WinAPI_WaitForMultipleObjects(2, $paObj, 0, 0) Switch $iID Case 0 ; WAIT_OBJECT_0 ; ConsoleWrite('A file was created, renamed, or deleted in the directory.' & @CRLF) Local $hSearch = FileFindFirstFile($watchPath & "\*") Local $sFileName = "", $iResult = 0 Local $sFilePath = "" While 1 $sFileName = FileFindNextFile($hSearch) ; If there is no more file matching the search. If @error Then ExitLoop $sFilePath = $watchPath & "\" & $sFileName Local $fileUsed $fileUsed = 0 $fileUsed = _FileIsUsed($sFilePath) If $fileUsed = 1 Then While 1 Sleep(100) $fileUsed = _FileIsUsed($sFilePath) If $fileUsed = 0 Then ExitLoop WEnd EndIf If StringInStr($sFileName, "raw") Then If StringInStr($sFileName, "select") Then $select = 1 PrintRawFile($sFilePath, $select) Else If StringInStr($sFileName, "lg.") Then $pageSize = "legal" ElseIf StringInStr($sFileName, "a4.") Then $pageSize = "a4" ElseIf StringInStr($sFileName, "us.") Then $pageSize = "letter" EndIf $pdfTemp = 0 If StringLower(StringLeft($sFileName, 7) = "pdftemp") Then $pdfTemp = 1 If StringInStr($sFileName, ".pcl") Then $format = "pcl" $print = 1 If StringLeft($sFileName, 6) = "select" Then $select = 1 $print = 1 ElseIf StringLeft($sFileName, 3) = "pdf" Then $select = 0 $print = 0 EndIf MakePDF($sFilePath, $format, $print, $select, $pageSize, $pdfTemp) ElseIf StringInStr($sFileName, ".ps") Then $format = "ps" $print = 1 If StringLeft($sFileName, 6) = "select" Then $select = 1 $print = 1 ElseIf StringLeft($sFileName, 3) = "pdf" Then $select = 0 $print = 0 EndIf MakePDF($sFilePath, $format, $print, $select, $pageSize, $pdfTemp) ElseIf StringInStr($sFileName, ".esc") Then Sleep(200) $format = "epson" $print = 1 If StringLeft($sFileName, 6) = "select" Then $select = 1 $print = 1 ElseIf StringLeft($sFileName, 3) = "pdf" Then $select = 0 $print = 0 EndIf MakePDF($sFilePath, $format, $print, $select, $pageSize, $pdfTemp) ElseIf StringInStr($sFileName, ".prn") Then $format = GetFileFormat($sFilePath) $print = 1 If StringLeft($sFileName, 6) = "select" Then $select = 1 $print = 1 ElseIf StringLeft($sFileName, 3) = "pdf" Then $select = 0 $print = 0 EndIf ConsoleWrite("PRN test format: " & $format & @CRLF) MakePDF($sFilePath, $format, $print, $select, $pageSize, $pdfTemp) EndIf EndIf ; Display the file name. ; $iResult = MsgBox(BitOR($MB_SYSTEMMODAL, $MB_OKCANCEL), "", $watchPath & "\" & $sFileName) ;~ RunWait(@ComSpec & " /c notepad.exe " & $watchPath & "\" & $sFileName) ;~ FileDelete($watchPath & "\" & $sFileName) If $iResult <> $IDOK Then ExitLoop ; If the user clicks on the cancel/close button. WEnd ; Close the search handle. FileClose($hSearch) Case 1 ; WAIT_OBJECT_0 + 1 ; ConsoleWrite('A directory was created, renamed, or deleted.' & @CRLF) Case Else ContinueLoop EndSwitch If Not _WinAPI_FindNextChangeNotification($g_ahObj[$iID]) Then MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unexpected error.') Exit EndIf WEnd  
    • By xYuri
      This simple dllcall gives me error 5, access denied,
      Func _WinAPI_VkKeyScan($__key) _WinAPI_SetLastError(0) $res = DllCall('User32.dll', 'SHORT', 'VkKeyScan', 'CHAR', $__key) _xConsole('res: '&$res) $_LastErr = _WinAPI_GetLastError() If $_LastErr <> 0 Then _xConsole('Err: {' & $_LastErr & '}> ' & _WinAPI_GetLastErrorMessage()) Return $res EndFunc Am i doing something wrong?
      Also tried VkKeyScanA and W
      Edit:
      I want to send `:` via PostMessage() WM_KEYDOWN
    • By Scriptmaster
      <NEWBIE ALERT>
      Is it possible to unzip a zip file in Autoit without using a dll!
      My script downloads a zip file to a temporary directory (successfully) and it must be unzipped to (Or moved to after unzip) another a folder which just happens to be
      @scriptdir & "file.exe" Thanks in advance
×
×
  • Create New...