Manjish Posted September 9, 2009 Posted September 9, 2009 Hi, I still am not very sure of what u mean by "Online" and "offline" link.. Please explain this.. I put in google, autoit, yahoo.. etc links but I get all of them as offline.. So I am not able to test the scenario for online links.. [font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com
AuToItItAlIaNlOv3R Posted September 9, 2009 Author Posted September 9, 2009 @Manjish Manjish i read the source of page, if source contains that string "Enter this" the file that i would download are online, if not contains that string are offline. The script work done, it rightly find files online and offline. But i've a problem when i would to write te online checked link with this new code expandcollapse popup#include <GUIConstants.au3> #Include <GuiListView.au3> #include <INet.au3> #include <ListViewConstants.au3> #Include <GuiListView.au3> #include <GuiConstantsEx.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ;========== Global $j=1,$ArrayOL[1000] Local $controllsource $Form1 = GUICreate("Add Link Here", 394, 247, 156, 156) $Link = GUICtrlCreateEdit("", 0, 0, 393, 201) $Clear = GUICtrlCreateButton("Clear", 120, 208, 75, 33, $WS_GROUP) $Check = GUICtrlCreateButton("Check Now!", 216, 208, 75, 33, $WS_GROUP) $Exitnow = GUICtrlCreateButton("Exit Now", 312, 208, 75, 33, $WS_GROUP) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Clear GUICtrlSetData($Link, "") Case $Check Linkcheck (GUICtrlRead ($Link)) Case $Exitnow Exit EndSwitch WEnd Func Linkcheck ($sLinks) $_1 = GUICreate("Link Checker", 653, 244, 31, 65) $Listonline = GUICtrlCreateListView("Link|Title|State", 8, 40, 282, 150,-1, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_CHECKBOXES)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 255) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 219) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 84) $Listoffline = GUICtrlCreateListView("Link|Title|State", 336, 40, 282, 150) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 255) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 219) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 84) $Label1 = GUICtrlCreateLabel("Online Links", 8, 16, 62, 17) $Label2 = GUICtrlCreateLabel("Offline Links", 336, 16, 62, 17) $Deselect = GUICtrlCreateButton("Deselect All", 456, 208, 75, 25, $WS_GROUP) $Select = GUICtrlCreateButton("Select All", 368, 208, 75, 25, $WS_GROUP) $Exit = GUICtrlCreateButton("Exit", 544, 208, 75, 25, $WS_GROUP) $Add = GUICtrlCreateButton("Add to list", 280, 208, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) $aLinks = StringSplit(StringReplace($sLinks, @CR, ""), @LF) For $i = 1 To $aLinks[0] Dim $listitem[$aLinks[0] + 1] $sourcecontroll = _INetGetSource ($aLinks[$i]) If StringInStr ($sourcecontroll,"Enter this") Then $Sourcetitle =_INetGetSource ("http:/www.xxxxxx.com" & $aLinks[$i]) $onlinetitle = StringTrimLeft($Sourcetitle,StringInStr($Sourcetitle,'/',0,-1)) $listitem[$i] = GUICtrlCreateListViewItem ($aLinks[$i] & "|" &$onlinetitle & "|" & "Online",$Listonline) GUICtrlSetState($listitem[$i], $GUI_CHECKED) EndIf If Not StringInStr ($sourcecontroll,"Enter this") Then $listitem[$i] = GUICtrlCreateListViewItem ($aLinks[$i] & "|" & "//" & "|" & "Offline",$Listoffline) EndIf Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Add For $i = 1 To $aLinks[0] If _GUICtrlListView_GetItemChecked($Listonline,$i-1)=1 Then $ArrayOL[$j]=$aLinks[$i] ;Don't write the online checked link $j=$j+1 EndIf Next _ArrayDisplay($ArrayOL) Case $Select For $x = 1 To $aLinks[0] _GUICtrlListView_SetItemChecked($Listonline,-1) Next Case $Deselect For $y = 1 To $aLinks[0] _GUICtrlListView_SetItemChecked($Listonline,-1,False) Next Case $Exit Exit EndSwitch WEnd EndFunc How i fix it? i would to write te online checked link in an array, but with my code this don't work done. Thank's a lot P.S. You know how to do this ? http://www.autoitscript.com/forum/index.php?showtopic=100427
AuToItItAlIaNlOv3R Posted September 10, 2009 Author Posted September 10, 2009 (edited) I've fixed my problem, but now i have a new question to ask : Now i've this code expandcollapse popup#include <GUIConstants.au3> #Include <GuiListView.au3> #include <INet.au3> #include <ListViewConstants.au3> #Include <GuiListView.au3> #include <GuiConstantsEx.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ;========== Global $j=1,$ArrayOL[1000] Local $controllsource $Form1 = GUICreate("Add Link Here", 394, 247, 156, 156) $Link = GUICtrlCreateEdit("", 0, 0, 393, 201) $Clear = GUICtrlCreateButton("Clear", 120, 208, 75, 33, $WS_GROUP) $Check = GUICtrlCreateButton("Check Now!", 216, 208, 75, 33, $WS_GROUP) $Exitnow = GUICtrlCreateButton("Exit Now", 312, 208, 75, 33, $WS_GROUP) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Clear GUICtrlSetData($Link, "") Case $Check Linkcheck (GUICtrlRead ($Link)) Case $Exitnow Exit EndSwitch WEnd Func Linkcheck ($sLinks) $_1 = GUICreate("Link Checker", 653, 244, 31, 65) $Listonline = GUICtrlCreateListView("Link|Title|State", 8, 40, 282, 150,-1, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_CHECKBOXES)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 255) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 219) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 84) $Listoffline = GUICtrlCreateListView("Link|Title|State", 336, 40, 282, 150) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 255) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 219) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 84) $Label1 = GUICtrlCreateLabel("Online Links", 8, 16, 62, 17) $Label2 = GUICtrlCreateLabel("Offline Links", 336, 16, 62, 17) $Deselect = GUICtrlCreateButton("Deselect All", 456, 208, 75, 25, $WS_GROUP) $Select = GUICtrlCreateButton("Select All", 368, 208, 75, 25, $WS_GROUP) $Exit = GUICtrlCreateButton("Exit", 544, 208, 75, 25, $WS_GROUP) $Add = GUICtrlCreateButton("Add to list", 280, 208, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) $aLinks = StringSplit(StringReplace($sLinks, @CR, ""), @LF) For $i = 1 To $aLinks[0] Dim $listitem[$aLinks[0] + 1] Dim $listitemx[$aLinks[0] + 1] ;I've added this line and i've fix the problem $sourcecontroll = _INetGetSource ($aLinks[$i]) If StringInStr ($sourcecontroll,"Enter this") Then $Sourcetitle =_INetGetSource ("http:/www.xxxxxx.com" & $aLinks[$i]) $onlinetitle = StringTrimLeft($Sourcetitle,StringInStr($Sourcetitle,'/',0,-1)) $listitem[$i] = GUICtrlCreateListViewItem ($aLinks[$i] & "|" &$onlinetitle & "|" & "Online",$Listonline) GUICtrlSetState($listitem[$i], $GUI_CHECKED) EndIf If Not StringInStr ($sourcecontroll,"Enter this") Then $listitemx[$i] = GUICtrlCreateListViewItem ($aLinks[$i] & "|" & "//" & "|" & "Offline",$Listoffline) EndIf Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Add For $i = 1 To $aLinks[0] If _GUICtrlListView_GetItemChecked($Listonline,$i-1)=1 Then $ArrayOL[$j]=$aLinks[$i] $j=$j+1 EndIf Next _ArrayDisplay($ArrayOL) For $i = 1 To UBound ($ArrayOL) ;This is the problem, i've a for cycle to 1000. But i would like to have a for many cycle as are the checked links, for esample if i've 3 checked links i would like to have a "For $i=1 to 3". How to do this? InetGet ($ArrayOL[$i],"/downloadedfile") Next MsgBox (0,"Done!","File downloaded!") Case $Select For $x = 1 To $aLinks[0] _GUICtrlListView_SetItemChecked($Listonline,-1) Next Case $Deselect For $y = 1 To $aLinks[0] _GUICtrlListView_SetItemChecked($Listonline,-1,False) Next Case $Exit Exit EndSwitch WEnd EndFunc The problem is here : For $i = 1 To UBound ($ArrayOL) InetGet ($ArrayOL[$i],"/downloadedfile") Next MsgBox (0,"Done!","File downloaded!") This is the problem, i've a for cycle to 1000. But i would like to have a for many cycle as are links, for esample if i've 3 checked links i would like to have a "For $i=1 to 3". How to do this? Thank's exscuse for my bad english! Edited September 10, 2009 by AuToItItAlIaNlOv3R
Moderators SmOke_N Posted September 11, 2009 Moderators Posted September 11, 2009 For $i = 1 To UBound($ArrayOL) - 1 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
AuToItItAlIaNlOv3R Posted September 11, 2009 Author Posted September 11, 2009 It give me a "999" for cicle!
Moderators SmOke_N Posted September 11, 2009 Moderators Posted September 11, 2009 It give me a "999" for cicle!I wasn't answering any specific questions, I was merely showing you an issue/error.If you don't know how to use arrays, http://www.autoitscript.com/wiki/Arrays is a good place to start. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
AuToItItAlIaNlOv3R Posted September 11, 2009 Author Posted September 11, 2009 i fix the error, i add this code $ArrayOL[1] = [""] ;To empty the array _ArrayAdd ; To add selected link in an array
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