Jump to content
Sign in to follow this  
incepator

_ARRAYUNIQUE not working :(

Recommended Posts

incepator

can remove duplicate lines from that... "listview"? :(

#NoTrayIcon
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <IE.au3>
#include <String.au3>
#include <Array.au3>
#include <GuiListView.au3>
$Form1 = GUICreate("Motor 1", 635, 368, -1, -1)
GUISetBkColor(0x000000)
$Button1 = GUICtrlCreateButton("Add List", 8, 2, 75, 24, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetCursor (-1, 0)
$Input1 = GUICtrlCreateInput("", 88, 5, 537, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY))
$Label1 = GUICtrlCreateLabel("Start Row - Word", 8, 32, 120, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Input2 = GUICtrlCreateInput("1", 128, 32, 49, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
$Label2 = GUICtrlCreateLabel("End Row - Word", 184, 32, 115, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Input3 = GUICtrlCreateInput("10", 304, 32, 49, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
$Label3 = GUICtrlCreateLabel("Start Page", 360, 32, 77, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Input4 = GUICtrlCreateInput("1", 440, 32, 49, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
$Label4 = GUICtrlCreateLabel("End Page", 496, 32, 72, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Input5 = GUICtrlCreateInput("2", 576, 32, 49, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
$Label5 = GUICtrlCreateLabel("Please Wait...", 56, 346, 571, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x00FFFF)
$Label6 = GUICtrlCreateLabel("Algoritm Link Generate:", 8, 57, 165, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Label7 = GUICtrlCreateLabel("Parameter 1", 172, 60, 61, 17)
GUICtrlSetColor(-1, 0xFF0000)
$Input6 = GUICtrlCreateInput("http://en.search.wordpress.com", 232, 56, 121, 21)
$Label8 = GUICtrlCreateLabel("2", 356, 60, 10, 17)
GUICtrlSetColor(-1, 0xFF0000)
$Input7 = GUICtrlCreateInput("/?q=", 368, 56, 121, 21)
$Label9 = GUICtrlCreateLabel("3", 492, 60, 10, 17)
GUICtrlSetColor(-1, 0xFF0000)
$Input8 = GUICtrlCreateInput("&t=comment&page=", 504, 56, 121, 21)
$ListView1 = GUICtrlCreateListView("#Nr. Pages|Link Pages", 8, 80, 618, 246, BitOR($GUI_SS_DEFAULT_LISTVIEW,$WS_BORDER))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 70)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 520)
$Button2 = GUICtrlCreateButton("GO", 8, 328, 43, 35, BitOR($BS_CENTER,$BS_VCENTER), $WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetCursor (-1, 0)
$Progress1 = GUICtrlCreateProgress(56, 328, 570, 14)
Dim $Form1_AccelTable[1][2] = [["{ENTER}", $Button2]]
GUISetAccelerators($Form1_AccelTable)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$Add_List = FileOpenDialog("Select List Words", @ScriptDir & "\", "Txt File (*.txt)", 1, "", $Form1)
         If Not @error Then
             GUICtrlSetData($Input1, $Add_List)
ElseIf @error = 1 Then
Sleep(1)
Else
MsgBox(16, "Error Function","Error: " & @error)
         EndIf
Case $Button2
_GO_FUNC()
EndSwitch
WEnd
Func _GO_FUNC()
If GUICtrlRead($Input1) = "" Then
MsgBox(16,"Error","NO List Exist !")
ElseIf GUICtrlRead($Input2) = "" Then
MsgBox(16,"Error","NO Start Row - Word INSERT !")
ElseIf GUICtrlRead($Input3) = "" Then
MsgBox(16,"Error","NO End Row - Word INSERT !")
ElseIf GUICtrlRead($Input4) = "" Then
MsgBox(16,"Error","NO Start Page INSERT !")
ElseIf GUICtrlRead($Input5) = "" Then
MsgBox(16,"Error","NO End Page INSERT !")
ElseIf GUICtrlRead($Input6) = "" Then
MsgBox(16,"Error","NO Parameter 1 INSERT !")
ElseIf GUICtrlRead($Input7) = "" Then
MsgBox(16,"Error","NO Parameter 2 INSERT !")
ElseIf GUICtrlRead($Input8) = "" Then
MsgBox(16,"Error","NO Parameter 3 INSERT !")
Else
_GO_FUNC_START()
EndIf
EndFunc
Func _GO_FUNC_START()
$primul_cuvant = GUICtrlRead($Input2);1 Default
$ultimul_cuvant = GUICtrlRead($Input3);10 Default
$total_randuri_fisier_adaugat = _FileCountLines(GUICtrlRead($Input1))
If $ultimul_cuvant > $total_randuri_fisier_adaugat Then
MsgBox(16,"Error","Max Word File Is: "&$total_randuri_fisier_adaugat)
Else
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Dim $master_array[1]
$deschide_fisier = FileOpen(GUICtrlRead($Input1),0)
For $pagina_actuala = GUICtrlRead($Input4) To GUICtrlRead($Input5)
For $cuvant_actual_numar = $primul_cuvant To $ultimul_cuvant
$cuvant_actual = FileReadLine($deschide_fisier,$cuvant_actual_numar)
$Link_Generat = _IECreate(GUICtrlRead($Input6) & GUICtrlRead($Input7) & $cuvant_actual & GUICtrlRead($Input8) & $pagina_actuala , 0, 0, 1, 0)
_IELoadWait($Link_Generat)
$text_extras = _IEBodyReadHTML($Link_Generat)
_IEQuit($Link_Generat)
$pagini = _StringBetween($text_extras, 'class=post-title href="','">')
If IsArray($pagini) Then
_ArrayConcatenate($master_array, $pagini, 1)
EndIf
Next
_ArrayDelete($master_array, 0)
$arry_unic = _ArrayUnique($master_array)
For $1 = 1 To UBound($arry_unic) - 1
$prima_culoare = GUICtrlCreateListViewItem($1&"|"&$arry_unic[$1], $ListView1)
GUICtrlSetColor($prima_culoare, 0x0000FF)
Next
Next
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MsgBox(64,"Info","Finish !")
$salvare_totala = FileSaveDialog("Save...",@DesktopDir,"Text files (*.txt)","",GUICtrlRead($Input1))
If Not @error Then
     Local $deschide_salvare = FileOpen($salvare_totala&".txt", 1)
     For $i = 0 To _GUICtrlListView_GetItemCount($ListView1)-1
     FileWrite($deschide_salvare,_GUICtrlListView_GetItemTextString($ListView1,$i)&@CRLF)
     Next
EndIf
EndIf
EndFunc

Share this post


Link to post
Share on other sites
PhoenixXL

can you recreate your problem in a little example


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
incepator

can you recreate your problem in a little example

course, please wait a few minutes, thanks.

EDIT

_________________________________________________________________________

Hello!

I have a problem ...

How can number the number of rows in "ListViewItem"?

and how to reduce duplicate rows?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <IE.au3>
#include <String.au3>
#include <Array.au3>
#include <GuiListView.au3>
$Form1 = GUICreate("", 585, 442, 192, 124)
$Label1 = GUICtrlCreateLabel("Start Line Nr. Word", 8, 16, 95, 17)
$Input1 = GUICtrlCreateInput("1", 104, 16, 49, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_NUMBER))
$Label2 = GUICtrlCreateLabel("Stop To Line Nr. Word", 160, 16, 111, 17)
$Input2 = GUICtrlCreateInput("4", 285, 16, 49, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_NUMBER))
$Label3 = GUICtrlCreateLabel("Start Page Nr.", 336, 16, 71, 17)
$Input3 = GUICtrlCreateInput("1", 405, 16, 49, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_NUMBER))
$Label4 = GUICtrlCreateLabel("Start Page Nr.", 461, 16, 71, 17)
$Input4 = GUICtrlCreateInput("2", 530, 16, 49, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_NUMBER))
$ListView1 = GUICtrlCreateListView("Total Link Nr|Links", 2, 64, 578, 374)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 80)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 400)
$Button1 = GUICtrlCreateButton("Extract", 8, 36, 75, 22)
GUISetState(@SW_SHOW)
$list_words = "Words.txt"
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Button1
$first_word = GUICtrlRead($Input1)
$last_word = GUICtrlRead($Input2)
  Dim $master_array[1]
  $open_read = FileOpen($list_words,0)
For $page = GUICtrlRead($Input3) To GUICtrlRead($Input4)
For $word = $first_word To $last_word
  $actual_word = FileReadLine($open_read,$word)
  $Link_Generate = _IECreate("http://en.search.wordpress.com/?q=" & $actual_word & "&t=comment&page=" & $page , 0, 0, 1, 0)
  _IELoadWait($Link_Generate)
  $text_extract = _IEBodyReadHTML($Link_Generate)
  _IEQuit($Link_Generate)
  $pages = _StringBetween($text_extract, 'class=post-title href="','">')
  If IsArray($pages) Then
   _ArrayConcatenate($master_array, $pages, 1)
  EndIf
Next
  _ArrayDelete($master_array, 0)
  $arry_unic = _ArrayUnique($master_array)
  For $1 = 1 To UBound($arry_unic) - 1
   $prima_culoare = GUICtrlCreateListViewItem("|"&$arry_unic[$1], $ListView1)
  Next
Next
  MsgBox(64,"Info","Finish !")
$salvare_totala = FileSaveDialog("Save...",@DesktopDir,"Text files (*.txt)","",GUICtrlRead($Input1))
   If Not @error Then
     Local $saves = FileOpen($salvare_totala&".txt", 1)
     For $i = 0 To _GUICtrlListView_GetItemCount($ListView1)-1
     FileWrite($saves,_GUICtrlListView_GetItemTextString($ListView1,$i)&@CRLF)
     Next
   EndIf
EndSwitch
WEnd
Edited by incepator

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×