Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Array.au3>
- #include <File.au3>
- #include <WinAPIProc.au3>
- Opt("WinTextMatchMode", 2)
- Opt("MustDeclareVars", 1)
- Opt("TrayIconDebug", 1)
- Opt("TrayIconHide", 0)
- Opt("SendKeyDelay", 30)
- Dim $dir_loc = "Z:\reading"
- find_files($dir_loc)
- Func find_files($dir_loc)
- Local $sLatestFileCreated = "-", $sLatestFileCreatedCheck = "-"
- Local $wPos, $hWnd, $counter, $act_title
- While 1
- $sLatestFileCreated = _FileVersion($dir_loc, "*|~$*;*.crdownload", 1, False)
- If IsString($sLatestFileCreated) And $sLatestFileCreated <> $sLatestFileCreatedCheck Then
- $sLatestFileCreatedCheck = $sLatestFileCreated
- ShellExecute(@ProgramFilesDir & "\Microsoft Office\Office14\WINWORD.EXE", '"' & $sLatestFileCreated & '"')
- ; setup office window
- Sleep(5000)
- $counter = 0
- While 1
- $counter = $counter + 1
- Sleep(1000)
- $hWnd = WinGetHandle("[ACTIVE]")
- $act_title = WinGetTitle($hWnd)
- If StringInStr($act_title, "Problems During Load") Then
- Send("{ENTER}")
- Sleep(1000)
- ExitLoop
- EndIf
- If StringInStr($act_title, "File Conversion") Then
- Send("{ENTER}")
- Sleep(1000)
- ExitLoop
- EndIf
- If StringInStr($act_title, " - Microsoft Word") Then
- ExitLoop
- EndIf
- If $counter > 20 Then ExitLoop
- WEnd
- Sleep(5000)
- $hWnd = WinGetHandle("[ACTIVE]")
- WinSetState($hWnd, "", @SW_MAXIMIZE)
- $wPos = WinGetPos($hWnd)
- MouseMove($wPos[0] + 746, $wPos[1] + 47, 0)
- MouseClick("primary")
- EndIf
- ;~ ConsoleWrite($sLatestFileCreated & " " & $sLatestFileCreatedCheck & @CRLF )
- Sleep(1000)
- WEnd
- EndFunc
- ; #FUNCTION# ====================================================================================================================
- ; Name ..........: _FileVersion
- ; Description ...:
- ; Syntax ........: _FileVersion($sFilePath[, $sMask = "*.*"[, $iFlag = 0[, $bFormat = True]]])
- ; Parameters ....: $sFilePath - Folder Path to Search
- ; $sMask - [optional] File Mask. Default is "*.*".
- ; $iFlag - [optional] Flag to indicate which timestamp
- ; - $FT_MODIFIED (0) = Last modified (default)
- ; - $FT_CREATED (1) = Created
- ; - $FT_ACCESSED (2) = Last accessed
- ; $bFormat - [optional] To specify type of return
- ; - True = Retrun an Array (default)
- ; - False = Return latest Filename for iFlag Type
- ; Return values .: An array or string
- ; Author ........: Subz
- ; Modified ......:
- ; Remarks .......:
- ; Related .......:
- ; Link ..........:
- ; Example .......: No
- ; ===============================================================================================================================
- Func _FileVersion($sFilePath, $sMask = "*.*", $iFlag = 0, $bFormat = True)
- Local $aFileList = _FileListToArrayRec($sFilePath, $sMask, 1, 0, 0, 2)
- If @error Then Return 0
- Local $aFileVersion[0][4]
- _ArrayAdd($aFileVersion, UBound($aFileList) - 1 & "|Modified|Created|Accessed")
- For $i = 1 to $aFileList[0]
- _ArrayAdd($aFileVersion, $aFileList[$i] & "|" & FileGetTime($aFileList[$i], 0, 1) & "|" & FileGetTime($aFileList[$i], 1, 1) & "|" & FileGetTime($aFileList[$i], 2, 1))
- Next
- Switch $iFlag
- Case 1
- _ArraySort($aFileVersion, 1, 1, 0, 2)
- Case 2
- _ArraySort($aFileVersion, 1, 1, 0, 3)
- Case Else
- _ArraySort($aFileVersion, 1, 1, 0, 1)
- EndSwitch
- Return $bFormat = True ? $aFileVersion : $aFileVersion[1][0]
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement