А если таких слов несколько?Мне нужно что бы при IputBox автоматически находил это слово и удалял его.
$String = InputBox('Test', 'Введите слово для удаление:', '', '', 200, 100)
$Read = FileRead(@ScriptDir & '\1.txt')
$Split = StringSplit($Read, ' ')
For $i = 1 To $Split[0]
If $Split[$i] = $String Then
FileDelete(@ScriptDir & '\1.txt')
$RegExpRep = StringRegExpReplace($Read, $String, '')
FileWrite(@ScriptDir & '\1.txt', $RegExpRep)
EndIf
Next
$Gui = GUICreate("Form1", 315, 238, 192, 124)
$Button = GUICtrlCreateButton("Замена", 10, 10, 60, 25)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Button
$String = InputBox('Test', 'Удалить указанный текст', 'привет', '', 200, 130, Default, Default, Default, $Gui)
$Read = FileRead(@ScriptDir & '\artikl.txt')
$Read = StringReplace($Read, $String, '')
$file = FileOpen(@ScriptDir&'\artikl.txt',2)
FileWrite($file, $Read)
FileClose($file)
EndSwitch
WEnd
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
$sFile = @ScriptDir & '\Test.txt'
If Not FileExists($sFile) Then
MsgBox(16, 'Error', 'No ' & $sFile)
Exit
EndIf
$sText = FileRead($sFile)
$aText = StringSplit(StringStripCR($sText), @LF)
Dim $aTextItem[$aText[0]][1]
For $i = 1 To $aText[0]
$aTextItem[$i - 1][0] = $aText[$i]
Next
$sText = ''
$aText = 0
GUICreate('Test', 300, 300)
$nButtonDel = GUICtrlCreateButton('Delete', 200, 20, 80, 30)
$nButtonSave = GUICtrlCreateButton('Save', 200, 70, 80, 30)
$nListView = GUICtrlCreateListView('', 2, 2, 180, 268, $LVS_REPORT, $LVS_EX_GRIDLINES)
$hListView = GUICtrlGetHandle($nListView)
_GUICtrlListView_AddColumn($hListView, 'Test', 150)
_GUICtrlListView_AddArray($hListView, $aTextItem)
$aTextItem = 0
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $nButtonDel
GUICtrlSetState($nButtonDel, $GUI_DISABLE)
GUICtrlSetState($nButtonSave, $GUI_DISABLE)
$aDel = _GUICtrlListView_GetSelectedIndices($hListView, True)
If $aDel[0] Then
For $i = $aDel[0] To 1 Step -1
_GUICtrlListView_DeleteItem($hListView, $aDel[$i])
Next
EndIf
$aDel = 0
_GUICtrlListView_SetItemSelected($hListView, -1, False)
GUICtrlSetState($nButtonDel, $GUI_ENABLE)
GUICtrlSetState($nButtonSave, $GUI_ENABLE)
Case $nButtonSave
GUICtrlSetState($nButtonDel, $GUI_DISABLE)
GUICtrlSetState($nButtonSave, $GUI_DISABLE)
$iCount = _GUICtrlListView_GetItemCount($hListView)
For $i = 0 To $iCount - 1
$sText &= _GUICtrlListView_GetItemText($hListView, $i) & @CRLF
Next
$hFile = FileOpen($sFile, 2)
FileWrite($hFile, StringTrimRight($sText, 2))
FileClose($hFile)
$sText = ''
$iCount = 0
$hFile = 0
GUICtrlSetState($nButtonDel, $GUI_ENABLE)
GUICtrlSetState($nButtonSave, $GUI_ENABLE)
EndSwitch
WEnd