sathish 0 Posted April 20, 2012 HERE is the script expandcollapse popup#include <Misc.au3> #include <File.au3> #include <String.au3> #include <GUIEdit.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Dim $data, $original Global $file If $cmdLine[0] > 0 Then If $cmdLine[1] <> "" Then $file = $cmdLine[1] EndIf EndIf If $file <> "" Then FileOpen($file,0) If @error = -1 Then MsgBox(48,"Error","Could not open the file.") EndIf $data = FileRead($file) $original = $data If @error = 1 Then MsgBox(48,"Error","Could not read the file contents.") EndIf EndIf #EndRegion ### End Startup Checks ### HotKeySet("^o","_Open") #Region ### START Koda GUI section ### Form= $frmTextEditor = GUICreate("Sample Text Editor (STE)", 620, 435, -1, -1) $txtEdit = _GUICtrlEdit_Create($frmTextEditor,"", 0, 0, 620, 435, BitOr($ES_MULTILINE,$ES_WANTRETURN, $ES_AUTOVSCROLL)) GUICtrlSetResizing(-1,102) $mnuFile = GUICtrlCreateMenu("&File") $mnuOpen = GUICtrlCreateMenuItem("&Open", $mnuFile) $mnuSave = GUICtrlCreateMenuItem("&Save", $mnuFile) $mnuSaveAs = GUICtrlCreateMenuItem("Save As...", $mnuFile) $div = GUICtrlCreateMenuItem("",$mnuFile) $mnuExit = GUICtrlCreateMenuItem("&Exit", $mnuFile) #EndRegion ### END Koda GUI section ### _GUICtrlEdit_SetText($txtEdit,$data) GUISetState() #Region ### Main body of program ### While 1 If _IsPressed("11") = 1 And _IsPressed("53") = 1 Then _Save(_GUICtrlEdit_GetText($txtEdit)) EndIf If _IsPressed("11") = 1 And _IsPressed("41") = 1 Then _GUICtrlEdit_SetSel($txtEdit,0,-1) EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _Exit() Case $mnuOpen _Open() Case $mnuSave _Save(_GUICtrlEdit_GetText($txtEdit)) Case $mnuSaveAs $file = FileSaveDialog("Select file.",@WorkingDir,"text files (*.txt) | All files (*.*)",16) _Save(_GUICtrlEdit_GetText($txtEdit)) Case $mnuExit EndSwitch Sleep(20) WEnd #EndRegion ### End the main body ### #Region ### Custom Functions ### Func _Open() $file = FileOpenDialog("Open",@WorkingDir,"text (*.txt)| all (*.*)") If @error = 1 Then MsgBox(48,"Error", "Could not open file or no file selected.") Else $data = FileRead($file) _GUICtrlEdit_SetText($txtEdit,$data) EndIf EndFunc Func _Save($sData) FileClose($file) FileOpen($file,2) If @error = -1 Then MsgBox(48,"Error","File could not be written to.") EndIf FileWrite($file,$sData) If @error = 1 Then MsgBox(48,"Error","Could not write file contents.") EndIf $original = $sData EndFunc Func _Exit() If _GUICtrlEdit_GetText($txtEdit) <> $original Then $ask = MsgBox(35,"Save?","Save changes to file?") If $ask = 6 Then _Save(_GUICtrlEdit_GetText($txtEdit)) Exit ElseIf $ask = 7 Then Exit Else EndIf Else Exit EndIf EndFunc #EndRegion ### End Custom Functions ### I need to create a Custom FIND REPLACE button Thanks in advance Share this post Link to post Share on other sites
water 2,359 Posted April 20, 2012 Don't open a new thread! Stick with the you opened a few hours ago! My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki  Share this post Link to post Share on other sites
sathish 0 Posted April 20, 2012 Here is the attached text file My requirement is to open the ss.txt in the editor and FIND REPLACE the text Please check the attached image In "FIND REF" button the text <ref>(.*?)</ref> have to be founded one by one and In the "APPLY-STYLE" button <refss>(.*?)</refs> should be replaced It should be carried one by one If the user clicks FIND REF, it should find first <ref>(.*?)</ref> and if the user clicks "APPLY-STYLE" button <refss>(.*?)</refs> should be replaced, if the user clicks FIND REF, without clicking APPLY-STYLE, it should not replace, instead of replacing it should find the next <ref>(.*?)</ref> Sorry for my bad English, hope u guys understood my requirement Thanks in advancess.txt Share this post Link to post Share on other sites
sathish 0 Posted April 20, 2012 Don't open a new thread! Stick with the you opened a few hours ago!Sorry for the inconvenience Share this post Link to post Share on other sites
sathish 0 Posted April 20, 2012 Here is my updated code expandcollapse popup#include <Misc.au3> #include <File.au3> #include <String.au3> #include <GUIEdit.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Dim $data, $original Global $file If $cmdLine[0] > 0 Then If $cmdLine[1] <> "" Then $file = $cmdLine[1] EndIf EndIf If $file <> "" Then FileOpen($file,0) If @error = -1 Then MsgBox(48,"Error","Could not open the file.") EndIf $data = FileRead($file) $original = $data If @error = 1 Then MsgBox(48,"Error","Could not read the file contents.") EndIf EndIf #EndRegion ### End Startup Checks ### HotKeySet("^o","_Open") #Region ### START Koda GUI section ### Form= $frmTextEditor = GUICreate("Sample Text Editor (STE)", 720, 435, -1, -1) $txtEdit = _GUICtrlEdit_Create($frmTextEditor,"", 0, 0, 720, 435, BitOr($ES_MULTILINE,$ES_WANTRETURN, $ES_AUTOVSCROLL)) GUICtrlSetResizing(-1,102) $mnuFile = GUICtrlCreateMenu("&File") $mnuOpen = GUICtrlCreateMenuItem("&Open", $mnuFile) $mnuSave = GUICtrlCreateMenuItem("&Save", $mnuFile) $mnuSaveAs = GUICtrlCreateMenuItem("Save As...", $mnuFile) $div = GUICtrlCreateMenuItem("",$mnuFile) $mnuExit = GUICtrlCreateMenuItem("&Exit", $mnuFile) $mnuFile1 = GUICtrlCreateMenu("&Edit") $mnuOpen1 = GUICtrlCreateMenuItem("&REF- STYLE APPLY", $mnuFile1) $mnuSave1 = GUICtrlCreateMenuItem("&Save", $mnuFile1) $mnuSaveAs1 = GUICtrlCreateMenuItem("Save As...", $mnuFile1) $div1 = GUICtrlCreateMenuItem("",$mnuFile1) $mnuExit1 = GUICtrlCreateMenuItem("&Exit", $mnuFile1) #EndRegion ### END Koda GUI section ### _GUICtrlEdit_SetText($txtEdit,$data) GUISetState() #Region ### Main body of program ### While 1 If _IsPressed("11") = 1 And _IsPressed("53") = 1 Then _Save(_GUICtrlEdit_GetText($txtEdit)) EndIf If _IsPressed("11") = 1 And _IsPressed("41") = 1 Then _GUICtrlEdit_SetSel($txtEdit,0,-1) EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _Exit() Case $mnuOpen _Open() Case $mnuSave _Save(_GUICtrlEdit_GetText($txtEdit)) Case $mnuSaveAs $file = FileSaveDialog("Select file.",@WorkingDir,"text files (*.txt) | All files (*.*)",16) _Save(_GUICtrlEdit_GetText($txtEdit)) Case $mnuExit Case $mnuOpen1 #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("REF-STYLE APPLIER", 417, 76, 225, 287) $Button1 = GUICtrlCreateButton("FIND REF", 40, 16, 147, 49, 0) $Button2 = GUICtrlCreateButton("APPLY-STYLE", 232, 14, 147, 49, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $button1 EndSwitch WEnd EndSwitch Sleep(20) WEnd #EndRegion ### End the main body ### #Region ### Custom Functions ### Func _Open() $file = FileOpenDialog("Open",@WorkingDir,"text (*.txt)| all (*.*)") If @error = 1 Then MsgBox(48,"Error", "Could not open file or no file selected.") Else $data = FileRead($file) _GUICtrlEdit_SetText($txtEdit,$data) EndIf EndFunc Func _Save($sData) FileClose($file) FileOpen($file,2) If @error = -1 Then MsgBox(48,"Error","File could not be written to.") EndIf FileWrite($file,$sData) If @error = 1 Then MsgBox(48,"Error","Could not write file contents.") EndIf $original = $sData EndFunc Func _Exit() If _GUICtrlEdit_GetText($txtEdit) <> $original Then $ask = MsgBox(35,"Save?","Save changes to file?") If $ask = 6 Then _Save(_GUICtrlEdit_GetText($txtEdit)) Exit ElseIf $ask = 7 Then Exit Else EndIf Else Exit EndIf EndFunc #EndRegion ### End Custom Functions ### Now please help me in completing my task Share this post Link to post Share on other sites
sathish 0 Posted April 21, 2012 Please suggest me, whether this task is possible or not???? Share this post Link to post Share on other sites