#SingleInstance force Process, priority, , High Gui, Add, Edit, x16 y10 w550 h90 vContent, Gui, Add, Button, x16 y110 w100 h30 gGetLinks, Get ed2k Links! Gui, Add, Button, x466 y110 w100 h30 gCancel, E&xit Gui, Add, Text, x220 y120 w200 h30, http://www.dr-leech.com.ar/ ; Generated using SmartGUI Creator 4.0 Gui, Show, x232 y408 h152 w577, ed2k Links Extractor by Leech Return GetLinks: Gui, Submit, NoHide LinkCount = 0 FinalContent = URLSearchString = %Content% GoSub, URLSearch StringReplace, FinalContent, FinalContent, `",,All GuiControl, , Content, %FinalContent% clipboard = %FinalContent% Return ; ################################################################################## URLSearch: ; It's done this particular way because some URLs have other URLs embedded inside them: StringGetPos, URLStart1, URLSearchString, ed2k:// ; Find the left-most starting position: URLStart = %URLStart1% ; Set starting default. Loop { ; It helps performance (at least in a script with many variables) to resolve ; "URLStart%A_Index%" only once: ArrayElement := URLStart%A_Index% if ArrayElement = ; End of the array has been reached. break if ArrayElement = -1 ; This element is disqualified. continue if URLStart = -1 URLStart = %ArrayElement% else ; URLStart has a valid position in it, so compare it with ArrayElement. { if ArrayElement <> -1 if ArrayElement < %URLStart% URLStart = %ArrayElement% } } if URLStart = -1 ; No URLs exist in URLSearchString. return LinkCount += 1 ; Otherwise, extract this URL: StringTrimLeft, URL, URLSearchString, %URLStart% ; Omit the beginning/irrelevant part. Loop, parse, URL, %A_Tab%%A_Space%<> ; Find the first space, tab, or angle (if any). { URL = %A_LoopField% FinalContent := FinalContent . A_LoopField . "`n" break ; i.e. perform only one loop iteration to fetch the first "field". } ; See if there are any other URLs in this line: StringLen, CharactersToOmit, URL CharactersToOmit += %URLStart% StringTrimLeft, URLSearchString, URLSearchString, %CharactersToOmit% Gosub, URLSearch ; Recursive call to self. return Cancel: ExitApp GuiClose: ExitApp