Jump to content

FileWrite Help


Recommended Posts

Hello forum, i've a problem >_<

I've this script :

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <String.au3>
#include <Array.au3>
#include <Ie.au3>
#include <INet.au3>
#include <File.au3>
$Form1 = GUICreate("Insert link....", 341, 237, 328, 135)
$Link = GUICtrlCreateEdit("", 0, 0, 337, 201)
$Download = GUICtrlCreateButton("Download", 104, 208, 139, 25, $WS_GROUP)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Download
            FileWrite ("C:\link.txt",GUICtrlRead ($Link))
            GUIDelete()
            Download()

    EndSwitch
WEnd

Func Download()
$Formdownload = GUICreate("Please Wait", 278, 62, 302, 218)
$Label1 = GUICtrlCreateLabel("Downloading...Please Wait...", 8, 8, 141, 17)
$Start = GUICtrlCreateButton("Start!", 104, 32, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
Local $Filelink1 = ("C:\link.txt")
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Start
            For $i = 1 To _FileCountLines ($Filelink1)
            $explode1 = _StringExplode(FileReadLine($Filelink1,$i),"http://xxxxxx.com")
            $source = _INetGetSource("http://xxxxx.com/?=" & $explode1[1])
            $array1 = _StringBetween($source,"download","/>")
            $sOutput1 = _ArrayToString($array1, @CRLF)
            InetGet ($sOutput1,@DesktopDir & "\" & "filedownlod.rar")
            Next
    EndSwitch
WEnd
EndFunc

I write the link in a file and i download it, there is a way to do this without creating a text file??

Link to comment
Share on other sites

You can define the Download() function as taking a single parameter which is expected to be the link string to download, but because the controls are globally visible you can just use GUICtrlRead() in the Download() function, terminate it if the string is empty, etc.. plenty of approaches.

Link to comment
Share on other sites

; ...
        Case $Download
            GUIDelete()
            Download(GUICtrlRead($Link))



Func Download($sLinks)
$Formdownload = GUICreate("Please Wait", 278, 62, 302, 218)
$Label1 = GUICtrlCreateLabel("Downloading...Please Wait...", 8, 8, 141, 17)
$Start = GUICtrlCreateButton("Start!", 104, 32, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
$aLinks = StringSplit(StringReplace($sLinks, @CR, ""), @LF)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Start
            For $i = 1 To $aLinks[0]
                 $source = _INetGetSource("http://xxxxx.com/?=" & $aLinks[$i])
                 $array1 = _StringBetween($source,"download","/>")
                 $sOutput1 = _ArrayToString($array1, @CRLF)
                 InetGet ($sOutput1,@DesktopDir & "\" & "filedownlod.rar")
            Next
    EndSwitch
WEnd

I guess you could drop the parameter and read the control content directly inside the Download() function as the controls in your script are globally visible.

Link to comment
Share on other sites

@ Authenticity

Your script give me a corret link for esample

http://www.xxxxxxxx.com/?download=$$$$$$$$

But now i woul link to capture the $$$$$$$ (letter and number after "?download="

I write this code

$explode1 = _StringExplode($aLinks[$i],"http://www.xxxxxxx.com/?download=")

But that don't give me the e $$$$$$$$, how i do it?

Edited by AuToItItAlIaNlOv3R
Link to comment
Share on other sites

What the array should contain in first place? If it should contain the download=, and the last part of the string is what you want to capture you can do something like:

Local $aMatch = StringRegExp($aLinks[$i], '(?i)download=(.+)', 1)

If IsArray($aMatch) Then $sDownload = $aMatch[0]

or using one of the string manipulation string functions to shorten things:

$sDownload = StringTrimLeft($aLinks[$i], StringInStr($aLinks[$i], 'download=')+StringLen('download='))

Didn't test them.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...