Code : Tout sélectionner
#include <IE.au3>
$internet=_IECreate("www.google.com")
WinSetState($internet,"",@SW_MAXIMIZE)
Code : Tout sélectionner
#include <IE.au3>
$internet=_IECreate("www.google.com")
WinSetState($internet,"",@SW_MAXIMIZE)
Code : Tout sélectionner
#Include <Array.au3> Local $timer = TimerInit() Local $sFile = @Scriptdir & "\myFile.txt" Local $iret = _FileDeleteLine($sFile, 0) ; Deletes the first line in the file ConsoleWrite ( (TimerDiff($timer) / 1000) & "secondes pour _FileDeleteLine" & @CRLF) Local $timer = TimerInit() Local $sFile = @Scriptdir & "\myFile.txt" Local $iret = _FileDeleteLine2($sFile, 0) ; Deletes the first line in the file ConsoleWrite ( (TimerDiff($timer) / 1000) & "secondes pour _FileDeleteLine2" & @CRLF) ; #FUNCTION# ==================================================================================================================== ; Name ..........: _FileDeleteLine ; Description ...: Deletes a line in a file, from the line number ; Syntax ........: _FileDeleteLine($sFilename, $iLineNumber) ; Parameters ....: $sFilename - Path and filename of the file to be delete line in. ; $iLineNumber - Line number to delete (starts to 1). ; Return values .: Success : retuns 1 ; Failure : return 0 and sets @error to : ; - 1 : Error opening specified file ; - 2 : File could not be written to ; Author ........: JGUINCH ; =============================================================================================================================== Func _FileDeleteLine($sFilename, $iLineNumber) If NOT FileExists($sFilename) Then Return SetError(1, 0, 0) Local $aContent = FileReadToArray ($sFilename) Local $hFile = FileOpen($sFilename, 2) If $hFile = -1 Then Return SetError(2, 0, 0) For $i = 0 To UBound($aContent) - 1 If $i = $iLineNumber - 1 Then ContinueLoop FileWriteLine($hFile, $aContent[$i]) Next FileClose($hFile) Return 1 EndFunc ; #FUNCTION# ==================================================================================================================== ; Name ..........: _FileDeleteLine2 ; Description ...: Deletes a line in a file, from the line number ; Syntax ........: _FileDeleteLine2($sFilename, $iLineNumber) ; Parameters ....: $sFilename - Path and filename of the file to be delete line in. ; $iLineNumber - Line number to delete (starts to 1). ; Return values .: Success : retuns 1 ; Failure : return 0 and sets @error to : ; - 1 : Error opening specified file ; - 2 : File could not be written to ; Author ........: JGUINCH ; =============================================================================================================================== Func _FileDeleteLine2($sFilename, $iLineNumber) If NOT FileExists($sFilename) Then Return SetError(1, 0, 0) Local $aContent = FileReadToArray ($sFilename) Local $sNewContent Local $hFile = FileOpen($sFilename, 2) If $hFile = -1 Then Return SetError(2, 0, 0) For $i = 0 To UBound($aContent) - 1 If $i = $iLineNumber - 1 Then ContinueLoop $sNewContent &= $aContent[$i] & @CRLF Next $sNewContent = StringRegExpReplace($sNewContent, "\R$", "") FileWrite($hFile, $sNewContent) FileClose($hFile) Return 1 EndFunc
