Code : Tout sélectionner
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
#include <WinAPI.au3>
Opt("GUIOnEventMode",1)
Global $iMemo
Example()
Func Example()
GUICreate("Time", 400, 300,300,300,$GUI_SS_DEFAULT_GUI, $WS_EX_ACCEPTFILES)
GUISetOnEvent($GUI_EVENT_CLOSE,"quit")
GUISetOnEvent($GUI_EVENT_DROPPED,"_drop")
Local $iMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
GUISetState(@SW_SHOW)
While 1
Sleep(50)
WEnd
EndFunc
Func quit()
Exit
EndFunc
Func _drop()
_createSrt(@GUI_DragFile)
EndFunc
Func _createSrt($sPathSrc)
$sPathSrc = StringTrimRight($sPathSrc,2)
Local $sTimeCreated = _getTimeCreated($sPathSrc)
Local $sTxt = "1"&@CRLF&"00:00:00,000 --> 00:00:09,000"&@CRLF&$sTimeCreated&@CRLF
If Not @error Then
FileWrite($sPathSrc&" - "&$sTimeCreated&".srt",$sTxt)
Return SetError(0,0,"")
Else
Return SetError(1,1,"")
EndIf
EndFunc
Func _getTimeCreated($sPath)
Local $aTime = FileGetTime($sPath,1)
If @error Then Return SetError(1,1,"")
Local $day[7] = ["Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi","Dimanche"]
Local $month[12] =["Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Decembre"]
Local $annee = $aTime[0]
local $mois = $aTime[1]
Local $jour = $aTime[2]
Local $heure = $aTime[3] + _getDecal()
Local $min = $aTime[4]
Local $sec = $aTime[5]
Return SetError(0,0,$day[Mod($jour,7)]&" "&$jour&' '&$month[$mois-1]&' '&$annee&" "&$heure&"h"&$min&"min"&$sec&"s")
EndFunc
Func _getDecal()
$tSystem = _Date_Time_GetSystemTime()
$tLocal = StringRegExpReplace(_Date_Time_SystemTimeToTzSpecificLocalTime(DllStructGetPtr($tSystem)),"(.*) (\d{1,2})(.*)","$2")
$tLocal = _Date_Time_GetLocalTime()
$tSystem = StringRegExpReplace(_Date_Time_TzSpecificLocalTimeToSystemTime(DllStructGetPtr($tLocal)),"(.*) (\d{1,2})(.*)","$2")
Return (Int($tLocal) - Int($tSystem))
EndFunc