找回密码
 加入
搜索
查看: 689|回复: 5

[网络通信] 如何对某个文件夹的修改时间进行多次对比【已解决】

[复制链接]
发表于 2022-8-15 03:20:21 | 显示全部楼层 |阅读模式
本帖最后由 a000000 于 2022-8-15 15:44 编辑

求助各位老师
   我想每隔10分钟对某个文件夹的修改时间对比一次,如果修改时间有变动则不作任何处理,如果最近5次没变化运行123.exe
由于水平有限,获取到当前修改时间后后面的无法实现了,请老师帮忙。



$t =  FileGetTime("C:\0", 0)
If Not @error Then
    $YYYYMMDDHHMMSS = $t[0] & "/" & $t[1] & "/" & $t[2]& "/" & $t[3]& "/" & $t[4]& "/" & $t[5]
    MsgBox(0, "notepad.exe 创建日期:", $YYYYMMDDHHMMSS)
EndIf
FileSetTime ( "C:\0","",0)


多谢各位老师。


发表于 2022-8-15 08:31:40 | 显示全部楼层
要用个循环检测,比如while或者用AdlibRegister
不然如何30分钟来一次呢
发表于 2022-8-15 14:07:24 | 显示全部楼层
#Region AutoIt3Wrapper 预编译参数(常用参数)
#AutoIt3Wrapper_Icon=                                                                                 ;图标,支持EXE,DLL,ICO
#AutoIt3Wrapper_OutFile=                                                                        ;输出文件名
#AutoIt3Wrapper_OutFile_Type=exe                                                        ;文件类型
#AutoIt3Wrapper_Compression=4                                                                ;压缩等级
#AutoIt3Wrapper_UseUpx=y                                                                         ;使用压缩
#AutoIt3Wrapper_Res_Comment=                                                                 ;注释
#AutoIt3Wrapper_Res_Description=                                                        ;详细信息
#AutoIt3Wrapper_Res_Fileversion=                                                        ;文件版本
#AutoIt3Wrapper_Res_FileVersion_AutoIncrement=p                                ;自动更新版本  
#AutoIt3Wrapper_Res_LegalCopyright=                                                 ;版权
#AutoIt3Wrapper_Change2CUI=N                                                   ;修改输出的程序为CUI(控制台程序)
;#AutoIt3Wrapper_Res_Field=AutoIt Version|%AutoItVer%                ;自定义资源段
;#AutoIt3Wrapper_Run_Tidy=                                                   ;脚本整理
;#AutoIt3Wrapper_Run_Obfuscator=                                                      ;代码迷惑
;#AutoIt3Wrapper_Run_AU3Check=                                                                 ;语法检查
;#AutoIt3Wrapper_Run_Before=                                                                 ;运行前
;#AutoIt3Wrapper_Run_After=                                                                        ;运行后
#EndRegion AutoIt3Wrapper 预编译参数设置完成
#cs ____________________________________

 Au3 版本:
 脚本作者: 
        Email: 
        QQ/TM: 
 脚本版本: 
 脚本功能: 

#ce _______________脚本开始_________________
#include <Date.au3>
$t =  FileGetTime("C:\Users\Administrator\Desktop\234", 0);;;要判断的文件夹
Global $var1,$var2,$var3,$var4,$var5,$var6,$var7,$var8,$var9,$var10
If Not @error Then
$yyyymd = $t[0] & "/" & $t[1] & "/" & $t[2] & " " & $t[3] & ":" & $t[4] & ":" & $t[5]
$len = StringLen($yyyymd)
$var1 = StringMid($yyyymd,1,4)
$var2 = StringMid($yyyymd,6,2)
$var3 = StringMid($yyyymd,9,2)
$var4 = StringMid($yyyymd,12,2)
$var5 = StringMid($yyyymd,15,2)
EndIf
Global $pctime=_NowCalc()
$var6 = StringMid($pctime,1,4)
$var7 = StringMid($pctime,6,2)
$var8 = StringMid($pctime,9,2)
$var9 = StringMid($pctime,12,2)
$var10 = StringMid($pctime,15,2)
if $var1-$var6=0 And $var2-$var7=0 And $var3-$var8=0 And $var4-$var9=0 And $var10-$var5<=2        Then 
MsgBox(0,"","有输出数据",3)
Else
MsgBox(0,"","没有输出数据啦",3)
EndIf        
_test1()
;~ _test2()        
Func _test1()
MsgBox(0,"","字符长度为:"&$len&@LF&""&@LF&"写入时间为:"&$yyyymd&@LF&""&@LF&"当前时间为:"&$pctime&@LF&""&@LF&"年:   "&$var6&"-"&$var1&"="&$var6-$var1&@LF&""&@LF&"月:           "&$var7&"-"&$var2&"="&$var7-$var2&@LF&""&@LF& "日:           "&$var8&"-"&$var3&"="&$var8-$var3&@LF&""&@LF& "时:           "&$var9&"-"&$var4&"="&$var9-$var4&@LF&""&@LF& "分:           "&$var10&"-"&$var5&"="&$var10-$var5)
EndFunc
Func _test2()
MsgBox(0,"","字符串长度为:"&$len)
MsgBox(0,"","文件写入时间:"&$yyyymd)
MsgBox(0,"","当前系统时间:"&$pctime)
MsgBox(0,"","分解后字符为:"&$var1)
MsgBox(0,"","分解后字符为:"&$var2)
MsgBox(0,"","分解后字符为:"&$var3)
MsgBox(0,"","分解后字符为:"&$var4)
MsgBox(0,"","分解后字符为:"&$var5)
MsgBox(0,"","分解后字符为:"&$var6)
MsgBox(0,"","分解后字符为:"&$var7)
MsgBox(0,"","分解后字符为:"&$var8)
MsgBox(0,"","分解后字符为:"&$var9)
MsgBox(0,"","分解后字符为:"&$var10)
EndFunc
 楼主| 发表于 2022-8-15 15:43:51 | 显示全部楼层

虽然跟我需求不一样,但是仍然十分感谢
发表于 2022-8-15 15:50:59 | 显示全部楼层
Local $sDir = "C:\0" ;检测目录 
Local $iCkIntervals = 10 * 60 * 1000        ;间隔时间 10 分钟

HotKeySet('{Esc}', '_Exit')
AdlibRegister('_CkTime', 1000)
While 1
        Sleep(1000)
WEnd
Func _CkTime()
        Local Static $iTs, $sInitialTime, $iCount
        If Not $iTs Then
                $iTs = TimerInit()
                $sInitialTime = FileGetTime($sDir, 0, 1)
                $iCount = 0
                Return
        EndIf
        If TimerDiff($iTs) >= $iCkIntervals Then
                $iTs = TimerInit()
                Local $sNow = FileGetTime($sDir, 0, 1)
                If $sNow <> $sInitialTime Then
                        $iCount = 0
                        $sInitialTime = $sNow
                Else
                        $iCount += 1
                        If $iCount = 5 Then
                                MsgBox(0, '', 'Run("123.exe")')
                                $iTs = 0
                        EndIf
                EndIf
        EndIf
EndFunc   ;==>_CkTime
Func _Exit()
        Exit
EndFunc   ;==>_Exit
 楼主| 发表于 2022-8-15 16:29:06 | 显示全部楼层

十分感谢afan超版,运行精准,代码精炼,获益良多,学习了。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-27 16:25 , Processed in 0.073918 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表