Malkey Posted December 5, 2017 Share Posted December 5, 2017 In case you are not aware. When using SciTE as your AutoIt script text editor, and you run a script within SciTE, "ConsoleWrite()" will write to the output pane. The output pane is the lower window of the SciTE editor, and on occasions, shows the script's errors which helps in debugging. Code has been added to have /: put in the clipboard only while the Adlib function, _FileDeleteLines(), is running. HotKeySet("{ESC}", "Terminate") ; Press Esc key to exit script. Global $sFileName = "281478146260429_chatlog.txt" Global $sSearch4 = "tips you" Global $sSearch5 = "bank credits" Global $sSearch6 = "trade with you" Global $sSearch7 = "you tell" Global $sSearch8 = "to a duel" _FileDeleteLines() AdlibRegister("_FileDeleteLines", 10 * 1000) ; Run the function, _FileDeleteLines(), every 10 secs While Sleep(100) WEnd Func _FileDeleteLines() local $sCBOld = ClipGet() ; Store clipboard contents for restoration later. ClipPut("/:") Local $sFileContents = FileRead($sFileName) Local $hFileOpen = FileOpen($sFileName, 2) ; $FO_OVERWRITE (2) = Write mode (erase previous contents) FileWrite($hFileOpen, StringRegExpReplace($sFileContents, _ '(?m)^.*(\Q' & $sSearch4 & "\E|\Q" & $sSearch5 & "\E|\Q" & $sSearch6 & "\E|\Q" & $sSearch7 & "\E|\Q" & $sSearch8 & _ '\E.*\R?)(*SKIP)(?!)|^.*\R*', "")) FileClose($hFileOpen) ConsoleWrite(ClipGet() & @CRLF) ; Show contents of clipboard ClipPut($sCBOld) ; Restore contents of clipboard ConsoleWrite(ClipGet() & @CRLF) ; Show contents of clipboard EndFunc ;==>_FileDeleteLines Func Terminate() AdlibUnRegister("_FileDeleteLines") Exit EndFunc ;==>Terminate Link to comment Share on other sites More sharing options...
PlatinumDruggie Posted December 10, 2017 Author Share Posted December 10, 2017 On 12/5/2017 at 0:31 AM, Malkey said: Alright this is all working great. But after a while, if there's no activity, the script will terminate. Is there a way to make sure it's always running? The script is saved as SCRIPT.exe HotKeySet("{ESC}", "Terminate") ; Press Esc key to exit script. Global $sFileName = "281478146260429_chatlog.txt" Global $sSearch4 = "tips you" Global $sSearch5 = "bank credits" Global $sSearch6 = "trade with you" Global $sSearch7 = "you tell" Global $sSearch8 = "to a duel" _FileDeleteLines() AdlibRegister("_FileDeleteLines", 10 * 1000) ; Run the function, _FileDeleteLines(), every 10 secs While Sleep(100) WEnd Func _FileDeleteLines() local $sCBOld = ClipGet() ; Store clipboard contents for restoration later. ClipPut("/:") Local $sFileContents = FileRead($sFileName) Local $hFileOpen = FileOpen($sFileName, 2) ; $FO_OVERWRITE (2) = Write mode (erase previous contents) FileWrite($hFileOpen, StringRegExpReplace($sFileContents, _ '(?m)^.*(\Q' & $sSearch4 & "\E|\Q" & $sSearch5 & "\E|\Q" & $sSearch6 & "\E|\Q" & $sSearch7 & "\E|\Q" & $sSearch8 & _ '\E.*\R?)(*SKIP)(?!)|^.*\R*', "")) FileClose($hFileOpen) ConsoleWrite(ClipGet() & @CRLF) ; Show contents of clipboard ClipPut($sCBOld) ; Restore contents of clipboard ConsoleWrite(ClipGet() & @CRLF) ; Show contents of clipboard EndFunc ;==>_FileDeleteLines Func Terminate() AdlibUnRegister("_FileDeleteLines") Exit EndFunc ;==>Terminate Link to comment Share on other sites More sharing options...
PlatinumDruggie Posted December 11, 2017 Author Share Posted December 11, 2017 On 12/10/2017 at 7:23 PM, PlatinumDruggie said: Nevermind, I figured it out. I was hitting ESC and the script was designed to end upon pressing esc. I just removed that line and it works fine now Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now