BrewManNH Posted April 24, 2012 Share Posted April 24, 2012 Because you haven't read the help file on how to use _ArrayFindAll and just grabbed the example script perhaps? Maybe you should actually try using the function the way it's supposed to be used and not ask everyone else to write this for you. This isn't even a good attempt at fishing for a script because you didn't even try that hard. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
GEOSoft Posted April 24, 2012 Share Posted April 24, 2012 (edited) For me this is working find to get rid of the duplicates. #Include<array.au3> $sFile = @DesktopDir & "test.txt" $sResultFile = @DesktopDir & "Result.txt" $aLines = StringRegExp(FileRead($sFile), "(?m:^)(.*)(?:v+|$)", 3) $aCleaned = _ArrayUnique($aLines) _ArrayDisplay($aCleaned, "Result") Then you would just loop through $aCleaned to re-write the file $sWriteback = "" For $i = 1 To Ubound($aCleaned) -1 $sWriteback &= $aCleaned[$i] & @CRLF Next If $sWriteback <> "" Then $hFile = FileOpen($sResultFile, 2) FileWrite($hFile, StringStripWS($sWriteback, 2)) FileClose($hFile) EndIf The test file only contained the following text [17:15:54] test = hello [17:15:54] test = hello [17:15:54] test = hello2 [17:15:54] test = hello2 [17:15:54] test = hello3 [17:15:54] test = hello3 [17:15:54] test = hello4 [17:15:54] test = hello4 [17:15:54] test = hello2 [17:15:54] test = hello Edited April 24, 2012 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
ileandros Posted April 24, 2012 Author Share Posted April 24, 2012 (edited) For me this is working find to get rid of the duplicates. #Include<array.au3> $sFile = @DesktopDir & "test.txt" $sResultFile = @DesktopDir & "Result.txt" $aLines = StringRegExp(FileRead($sFile), "(?m:^)(.*)(?:v+|$)", 3) $aCleaned = _ArrayUnique($aLines) _ArrayDisplay($aCleaned, "Result") Then you would just loop through $aCleaned to re-write the file $sWriteback = "" For $i = 1 To Ubound($aCleaned) -1 $sWriteback &= $aCleaned[$i] & @CRLF Next If $sWriteback <> "" Then $hFile = FileOpen($sResultFile, 2) FileWrite($hFile, StringStripWS($sWriteback, 2)) FileClose($hFile) EndIf The test file only contained the following text Good shot my friend. I managed adding that in my script but to be honest i would never image that it should work this way. My only problem is that i want it only to capture duplicated lines nothing else. This here capture one of every different line exists and display them. I think this is to avoid duplicated text. I guess this find every unique line and displays it. Edit: I tried and added _ArrayFindAll() but it returns me all the lines instead of returning me only the duplivated lines. I think this is the right command to find duplicated lines but i cant make it work right. I got no idea of array. As i already said i have only used autoit for IE :/ Edited April 24, 2012 by ileandros I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
Malkey Posted April 25, 2012 Share Posted April 25, 2012 Try this. #include<array.au3> #include <File.au3> Local $sFileName = "test.txt" Local $aFile, $sRes = "" _FileReadToArray($sFileName, $aFile) ;_ArrayDisplay($aFile) For $i = 1 To UBound($aFile) - 1 For $j = 1 To UBound($aFile) - 1 If ($i <> $j) And $aFile[$i] == $aFile[$j] Then ; Check if the "$i"'th element exists any where else in the whole array. $sRes &= StringFormat("Line %3d/ is: ""%s""n", $i, $aFile[$i]) ExitLoop EndIf Next Next ;ConsoleWrite($sRes & @LF) MsgBox(0, "All Duplicate Lines Only", $sRes) Link to comment Share on other sites More sharing options...
ileandros Posted April 26, 2012 Author Share Posted April 26, 2012 (edited) Try this. #include<array.au3> #include <File.au3> Local $sFileName = "test.txt" Local $aFile, $sRes = "" _FileReadToArray($sFileName, $aFile) ;_ArrayDisplay($aFile) For $i = 1 To UBound($aFile) - 1 For $j = 1 To UBound($aFile) - 1 If ($i <> $j) And $aFile[$i] == $aFile[$j] Then ; Check if the "$i"'th element exists any where else in the whole array. $sRes &= StringFormat("Line %3d/ is: ""%s""n", $i, $aFile[$i]) ExitLoop EndIf Next Next ;ConsoleWrite($sRes & @LF) MsgBox(0, "All Duplicate Lines Only", $sRes) Thanks to you my friend it works. This is the code. #include <Array.au3> #include <File.au3> if WinExists("test") Then $sFiles = _FileCreate(@ScriptDir & "test.txt") Local $sFile = ControlGetText("test","","RichEdit20W1") $file = FileWrite("test.txt", $sFile) Local $sFileName = "test.txt" Local $aFile, $sRes = "" _FileReadToArray($sFileName, $aFile) ;_ArrayDisplay($aFile) For $i = 1 To UBound($aFile) - 1 For $j = 1 To UBound($aFile) - 1 If ($i <> $j) And $aFile[$i] == $aFile[$j] Then ; Check if the "$i"'th element exists any where else in the whole array. $sRes &= StringFormat("Line %3d/ is: ""%s""n", $i, $aFile[$i]) ExitLoop EndIf Next Next ;ConsoleWrite($sRes & @LF) MsgBox(0, "All Duplicate Lines Only", $sRes) FileDelete($sFiles) EndIf I am creating each time a file and writing my text because i dont know if there is a way to delete the str i am setting in the file. There are more thing i want to ask but i am afraid because there are people here who get offended. I am sorry but as i already mention before i got no idea of Arrays. Is it able to make this programm keep running in my computer and everytime a duplicated line appears show the MsgBox?? Edited April 26, 2012 by ileandros I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
Malkey Posted April 26, 2012 Share Posted April 26, 2012 Another example without using files. expandcollapse popup#include<array.au3> ; For _ArrayDisplay only (when un-commented). Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase Local $sWinTitle = "Notepad" ; "WordPad" ; If WinExists($sWinTitle) Then WinActivate($sWinTitle) WinWaitActive($sWinTitle) Local $sLines = ControlGetText($sWinTitle, "", "") ; 3rd parameter, "", means Active Control. ;Local $aLines = StringRegExp($sLines, "(?:([^v]+)(?:v+|$))", 3) ; Lines to a zero-based array (blank lines not included). Local $aLines = StringSplit(StringStripCR($sLines), @LF, 2) ; Lines to a zero-based array (blank lines included). If IsArray($aLines) Then Local $sRes = "" ;_ArrayDisplay($aLines) For $i = 0 To UBound($aLines) - 1 For $j = 0 To UBound($aLines) - 1 If ($i <> $j) And $aLines[$i] == $aLines[$j] Then ; Check if the "$i"'th element exists any where else in the whole array. $sRes &= StringFormat("Line %3d/ is: ""%s""n", $i + 1, $aLines[$i]) ExitLoop EndIf Next Next If $sRes = "" Then MsgBox(0, "Duplicate Lines", "There are no duplicate lines.", 2) Else MsgBox(0, "All Duplicate Lines Only", $sRes) EndIf Else MsgBox(64, "Attention", $sWinTitle & " has no lines present.", 2) EndIf Else MsgBox(64, "Attention", $sWinTitle & " window not running.", 2) EndIf Link to comment Share on other sites More sharing options...
ileandros Posted April 26, 2012 Author Share Posted April 26, 2012 (edited) This works better As i have mentioned before my text are like this [17:15:54] test = hello [17:15:54] test = hello Ase you see the is called a spam. Is it able to edit this string and check the time the message was send?? What i mean is that is it able to edit the string and check the time. If a message is the same and the spam difference time is more than 3 mins it is not a spam so i am not allowed o block this spammers. Something like this. [17:15:54] test = hello [17:18:54] test = helloThis is not a spam. Malkey this is not obligatory. If ur tiried or have no willing to help me anymore it is fine. You have already done a lot:D Edited April 26, 2012 by ileandros I feel nothing.It feels great. 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