Advertisement
Guest User

html-txt monitor

a guest
Sep 10th, 2024
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 3.70 KB | Software | 0 0
  1. #include <Array.au3>
  2. #include <File.au3>
  3. #include <WinAPIProc.au3>
  4.  
  5. Opt("WinTextMatchMode", 2)
  6. Opt("MustDeclareVars", 1)
  7. Opt("TrayIconDebug", 1)
  8. Opt("TrayIconHide", 0)
  9. Opt("SendKeyDelay", 30)
  10.  
  11.  
  12. Dim $dir_loc = "Z:\reading"
  13.  
  14.  
  15. find_files($dir_loc)
  16.  
  17.  
  18. Func find_files($dir_loc)
  19.    Local $sLatestFileCreated = "-", $sLatestFileCreatedCheck = "-"
  20.    Local $wPos, $hWnd, $counter, $act_title
  21.    While 1
  22.       $sLatestFileCreated = _FileVersion($dir_loc, "*|~$*;*.crdownload", 1, False)
  23.       If IsString($sLatestFileCreated) And $sLatestFileCreated <> $sLatestFileCreatedCheck Then
  24.          $sLatestFileCreatedCheck = $sLatestFileCreated
  25.          ShellExecute(@ProgramFilesDir & "\Microsoft Office\Office14\WINWORD.EXE", '"' & $sLatestFileCreated & '"')
  26.          ; setup office window
  27.          Sleep(5000)
  28.          $counter = 0
  29.          While 1
  30.             $counter = $counter + 1
  31.             Sleep(1000)
  32.             $hWnd = WinGetHandle("[ACTIVE]")
  33.             $act_title = WinGetTitle($hWnd)
  34.             If StringInStr($act_title, "Problems During Load") Then
  35.                Send("{ENTER}")
  36.                Sleep(1000)
  37.                ExitLoop
  38.             EndIf
  39.             If StringInStr($act_title, "File Conversion") Then
  40.                Send("{ENTER}")
  41.                Sleep(1000)
  42.                ExitLoop
  43.             EndIf
  44.             If StringInStr($act_title, " - Microsoft Word") Then
  45.                ExitLoop
  46.             EndIf
  47.             If $counter > 20 Then ExitLoop
  48.          WEnd
  49.          Sleep(5000)
  50.          $hWnd = WinGetHandle("[ACTIVE]")
  51.          WinSetState($hWnd, "", @SW_MAXIMIZE)
  52.          $wPos = WinGetPos($hWnd)
  53.          MouseMove($wPos[0] + 746, $wPos[1] + 47, 0)
  54.          MouseClick("primary")
  55.       EndIf
  56. ;~    ConsoleWrite($sLatestFileCreated & " " & $sLatestFileCreatedCheck & @CRLF )
  57.       Sleep(1000)
  58.    WEnd
  59. EndFunc
  60.  
  61.  
  62. ; #FUNCTION# ====================================================================================================================
  63. ; Name ..........: _FileVersion
  64. ; Description ...:
  65. ; Syntax ........: _FileVersion($sFilePath[, $sMask = "*.*"[, $iFlag = 0[, $bFormat = True]]])
  66. ; Parameters ....: $sFilePath           - Folder Path to Search
  67. ;                  $sMask               - [optional] File Mask. Default is "*.*".
  68. ;                  $iFlag               - [optional] Flag to indicate which timestamp
  69. ;                                       -     $FT_MODIFIED (0) = Last modified (default)
  70. ;                                       -     $FT_CREATED (1) = Created
  71. ;                                       -     $FT_ACCESSED (2) = Last accessed
  72. ;                  $bFormat             - [optional] To specify type of return
  73. ;                                       -     True = Retrun an Array (default)
  74. ;                                       -     False = Return latest Filename for iFlag Type
  75. ; Return values .: An array or string
  76. ; Author ........: Subz
  77. ; Modified ......:
  78. ; Remarks .......:
  79. ; Related .......:
  80. ; Link ..........:
  81. ; Example .......: No
  82. ; ===============================================================================================================================
  83. Func _FileVersion($sFilePath, $sMask = "*.*", $iFlag = 0, $bFormat = True)
  84.     Local $aFileList = _FileListToArrayRec($sFilePath, $sMask, 1, 0, 0, 2)
  85.         If @error Then Return 0
  86.     Local $aFileVersion[0][4]
  87.         _ArrayAdd($aFileVersion, UBound($aFileList) - 1 & "|Modified|Created|Accessed")
  88.     For $i = 1 to $aFileList[0]
  89.         _ArrayAdd($aFileVersion, $aFileList[$i] & "|" & FileGetTime($aFileList[$i], 0, 1) & "|" & FileGetTime($aFileList[$i], 1, 1) & "|" & FileGetTime($aFileList[$i], 2, 1))
  90.     Next
  91.     Switch $iFlag
  92.         Case 1
  93.             _ArraySort($aFileVersion, 1, 1, 0, 2)
  94.         Case 2
  95.             _ArraySort($aFileVersion, 1, 1, 0, 3)
  96.         Case Else
  97.             _ArraySort($aFileVersion, 1, 1, 0, 1)
  98.     EndSwitch
  99.     Return $bFormat = True ? $aFileVersion : $aFileVersion[1][0]
  100. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement