Jump to content

How do I display IE downloadable text files inside GUI?


aa2zz6
 Share

Recommended Posts

Just click:

_IECreateEmbedded(..)

and read.

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

.....

use _IECreate and set $iVisible = 0
Get content with _IETableWriteToArray

....

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

aa2zz6,

Just rip the file names from the FTP site like this...

#include <ie.au3>
#include <array.au3>

Local $oIE = _IECreate("ftp://68.142.166.18/TUSC_GIS_FTP/Tus157_gis-mapdatastore ",0,0)
Local $links = _IELinkGetCollection($oIE), $out

For $link In $links
    $out &= stringregexpreplace($link.href,'.*/(.*)','$1') & @CRLF
Next

ConsoleWrite($out & @CRLF)

then create a gui and present the data in whatever way you want.

kylomas

edit: Example creating a dropdown list (combo)...

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <ie.au3>
#include <array.au3>

Local $oIE = _IECreate("ftp://68.142.166.18/TUSC_GIS_FTP/Tus157_gis-mapdatastore ",0,0)
Local $links = _IELinkGetCollection($oIE), $out

For $link In $links
    $out &= stringregexpreplace($link.href,'.*/(.*)','$1') & '|'
Next

#AutoIt3Wrapper_Add_Constants=n

local $gui010 = guicreate('')
local $aSize  = wingetclientsize($gui010)
local $cmb010 = guictrlcreatecombo('',20,20,200,250)
guisetstate()

guictrlsetdata($cmb010,$out,stringregexpreplace($out,'\|(.*?)\|.*','$1'))

while 1
    switch guigetmsg()
        case $gui_event_close
            Exit
    EndSwitch
WEnd

 

Edited by kylomas
example

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

I created a GUICtrlCreateEdit to store the information of all the different mapping files. Would it be possible to download the files from the GUICtrlCreateEdit? Each one would have a link attached and allow to click and download directly.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <array.au3>
#include <EditConstants.au3>

;Press to EXIT program!
HotKeySet("{ESC}", "Terminate")

$width = 1050
$height = 771
Global $LogMessage

_IEErrorHandlerRegister()
#Region ### START Koda GUI section ### Form=
$hMain = GUICreate("GIS Data", 1024, 600, @DesktopWidth / 2 - $width / 2, @DesktopHeight / 2 - $height / 2, _
        $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN + $WS_BORDER)

#EndRegion ### END Koda GUI section ###

;Button link to Auditor's > GIS > Mapping Data
Local $Tusc = GUICtrlCreateButton("Tuscarawas County", 10, 10, 115, 50)

$Log = GUICtrlCreateEdit("", 500, 15, 520, 560, BitOR($ES_WANTRETURN, $ES_READONLY, $ES_AUTOVSCROLL, $WS_VSCROLL));



GUISetState(@SW_SHOW, $hMain)

Local $iPID = 0



While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop

        Case $Tusc
        
            $iPID = Run(Tuscarawas(), "", @SW_SHOWMAXIMIZED)

    EndSwitch
WEnd

If $iPID Then ProcessClose($iPID)

Func Tuscarawas()

    Local $oIE = _IECreate("ftp://68.142.166.18/TUSC_GIS_FTP/Tus157_gis-mapdatastore ", 0, 0)
    Local $links = _IELinkGetCollection($oIE), $out

    For $link In $links
        $out &= StringRegExpReplace($link.href, '.*/(.*)', '$1') & @CRLF
    Next

        $LogMessage = $out & @CRLF
        GUICtrlSetData($Log, $LogMessage)

EndFunc   ;==>Tuscarawas

;STOP program
Func Terminate()
    Exit
EndFunc   ;==>Terminate

 

Edited by aa2zz6
Link to comment
Share on other sites

or a simple combo control, as illustrated above...

What is the purpose of $ipid?

You can write the edit control directly from $out, no need for $logmessage, or eliminate $out altogether and write $logmessage from the links loop.

How are you going to store the links and associate them to a selection from the gui?

They all have a common prefix

kylomas

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

2 hours ago, kylomas said:

aa2zz6,

Just rip the file names from the FTP site like this...

#include <ie.au3>
#include <array.au3>

Local $oIE = _IECreate("ftp://68.142.166.18/TUSC_GIS_FTP/Tus157_gis-mapdatastore ",0,0)
Local $links = _IELinkGetCollection($oIE), $out

For $link In $links
    $out &= stringregexpreplace($link.href,'.*/(.*)','$1') & @CRLF
Next

ConsoleWrite($out & @CRLF)

then create a gui and present the data in whatever way you want.

kylomas

edit: Example creating a dropdown list (combo)...

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <ie.au3>
#include <array.au3>

Local $oIE = _IECreate("ftp://68.142.166.18/TUSC_GIS_FTP/Tus157_gis-mapdatastore ",0,0)
Local $links = _IELinkGetCollection($oIE), $out

For $link In $links
    $out &= stringregexpreplace($link.href,'.*/(.*)','$1') & '|'
Next

#AutoIt3Wrapper_Add_Constants=n

local $gui010 = guicreate('')
local $aSize  = wingetclientsize($gui010)
local $cmb010 = guictrlcreatecombo('',20,20,200,250)
guisetstate()

guictrlsetdata($cmb010,$out,stringregexpreplace($out,'\|(.*?)\|.*','$1'))

while 1
    switch guigetmsg()
        case $gui_event_close
            Exit
    EndSwitch
WEnd

 

The example is very nice and I will probably use that style.

1 hour ago, kylomas said:

or a simple combo control, as illustrated above...

What is the purpose of $ipid?

You can write the edit control directly from $out, no need for $logmessage, or eliminate $out altogether and write $logmessage from the links loop.

How are you going to store the links and associate them to a selection from the gui?

They all have a common prefix

kylomas

At the time I didn't see the example prior to posting my piece of code. The $ipid was something that I copied from the help file. I put the code together quickly in order to put some type of code in response to the first piece of code that displayed the text from the website.

Edited by aa2zz6
Link to comment
Share on other sites

The InetGet inside the Case $Tusc doesn't seem to download the current information from the combo box.  Looking at the help file it says:

InetGet ( "URL", "filename" [, options = 0 [, background = 0]] )

That being said, I put the $oIE as the current url and the file name would be $cmb010 (combo box) displaying a name and a file extension. It doesn't seem to read from the combo box.

While 1
    Switch GUIGetMsg()
        Case $gui_event_close
            Exit
        Case $Tusc
            InetGet($oIE, $cmb010, 16, 0)
    EndSwitch
WEnd
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <ie.au3>
#include <array.au3>

HotKeySet("{ESC}", "Terminate")


Local $oIE = _IECreate("ftp://68.142.166.18/TUSC_GIS_FTP/Tus157_gis-mapdatastore", 0, 0)
Local $links = _IELinkGetCollection($oIE), $out

For $link In $links
    $out &= StringRegExpReplace($link.href, '.*/(.*)', '$1') & '|'
Next

#AutoIt3Wrapper_Add_Constants=n

Local $gui010 = GUICreate('')
Local $aSize = WinGetClientSize($gui010)
Local $cmb010 = GUICtrlCreateCombo('', 20, 20, 200, 250)
GUISetState()

GUICtrlSetData($cmb010, $out, StringRegExpReplace($out, '\|(.*?)\|.*', '$1'))

Local $Tusc = GUICtrlCreateButton("Download", 20, 50, 115, 30)

While 1
    Switch GUIGetMsg()
        Case $gui_event_close
            Exit
        Case $Tusc
            InetGet($oIE, $cmb010, 16, 0)
    EndSwitch
WEnd

Func Terminate()
    Exit
EndFunc   ;==>Terminate

 

Link to comment
Share on other sites

I got an illegal character error in this piece of code so I removed the "&" towards the end. I didn't get any errors after that but nothing download. The local FilePath is a directory on my computer correct? I wonder if I placed this wrong.

Error

InetGet("ftp://68.142.166.18/TUSC_GIS_FTP/Tus157_gis-mapdatastore" & GUICtrlRead($cmb010), "C:\Users\j\Desktop\ "&" & GUICtrlRead($cmb010))
                                                                                                                ----

Non Error - path wrote wrong?

InetGet("ftp://68.142.166.18/TUSC_GIS_FTP/Tus157_gis-mapdatastore" & GUICtrlRead($cmb010), "C:\Users\j\Downloads" & GUICtrlRead($cmb010))

 

Edited by aa2zz6
Link to comment
Share on other sites

Sorry, i forgot the slash in RemotePath and the backslash in LocalPath.

InetGet("ftp://68.142.166.18/TUSC_GIS_FTP/Tus157_gis-mapdatastore/" & GUICtrlRead($cmb010), "C:\Users\j\Downloads\" & GUICtrlRead($cmb010))

And here the solution with LV:

#include <ListViewConstants.au3>
#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>
#include <ie.au3>
#include <array.au3>

Global $sDL_URL="ftp://68.142.166.18/TUSC_GIS_FTP/Tus157_gis-mapdatastore"
Global $hGui=GUICreate('MapFiles DL',640,480)
Global $idLV=GUICtrlCreateListView('DL|RemoteFilename',5,5,630,430,$LVS_REPORT,BitOR($LVS_EX_CHECKBOXES,$LVS_EX_FULLROWSELECT))
Global $idtnDL=GUICtrlCreateButton('&Download checked Files',5,445,630,25,BitOR($BS_CENTER,$BS_DEFPUSHBUTTON))
Global $oIE = _IECreate($sDL_URL,0,0)
Global $links = _IELinkGetCollection($oIE)
Global $sItemText, $sLPath, $sRPath, $iBytes

For $link In $links
    $sItemText=stringregexpreplace($link.href,'.*/(.*)','$1')
    If $sItemText <> '' Then GUICtrlCreateListViewItem('|' & $sItemText,$idLV)
Next
_GUICtrlListView_SetColumnWidth($idLV,0, $LVSCW_AUTOSIZE_USEHEADER)
_GUICtrlListView_SetColumnWidth($idLV,1, $LVSCW_AUTOSIZE)
GUISetState()


while 1
    switch guigetmsg()
        case $gui_event_close
            Exit
        Case $idtnDL
            $sDownloads=FileSelectFolder("Choose folder you want to save the file's","")
            ConsoleWrite($sDownloads&@CRLF)
            If $sDownloads<>'' Then
                For $x = 0 To _GUICtrlListView_GetItemCount($idLV)
                    If _GUICtrlListView_GetItemChecked($idLV,$x) Then
                        $sItemText=_GUICtrlListView_GetItemText($idLV,$x,1)
                        $sRPath=$sDL_URL&'/'&$sItemText
                        $sLPath=$sDownloads&'\'&$sItemText
                        ConsoleWrite($sRPath&@TAB&$sLPath&@TAB)
                        $iBytes=InetGet($sRPath,$sLPath,0,0)
                        ;1. 0= Get the file from local cache if available
                        ;2. 0=waiting DL for File is comlete
                        ConsoleWrite($iBytes&' Bytes'&@CRLF)
                    EndIf
                Next
                ConsoleWrite('DL finished'&@CRLF)
            EndIf
    EndSwitch
WEnd

 

 

Edited by AutoBert
Link to comment
Share on other sites

8 hours ago, AutoBert said:

Sorry, i forgot the slash in RemotePath and the backslash in LocalPath.

InetGet("ftp://68.142.166.18/TUSC_GIS_FTP/Tus157_gis-mapdatastore/" & GUICtrlRead($cmb010), "C:\Users\j\Downloads\" & GUICtrlRead($cmb010))

And here the solution with LV:

#include <ListViewConstants.au3>
#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>
#include <ie.au3>
#include <array.au3>

Global $sDL_URL="ftp://68.142.166.18/TUSC_GIS_FTP/Tus157_gis-mapdatastore"
Global $hGui=GUICreate('MapFiles DL',640,480)
Global $idLV=GUICtrlCreateListView('DL|RemoteFilename',5,5,630,430,$LVS_REPORT,BitOR($LVS_EX_CHECKBOXES,$LVS_EX_FULLROWSELECT))
Global $idtnDL=GUICtrlCreateButton('&Download checked Files',5,445,630,25,BitOR($BS_CENTER,$BS_DEFPUSHBUTTON))
Global $oIE = _IECreate($sDL_URL,0,0)
Global $links = _IELinkGetCollection($oIE)
Global $sItemText, $sLPath, $sRPath, $iBytes

For $link In $links
    $sItemText=stringregexpreplace($link.href,'.*/(.*)','$1')
    If $sItemText <> '' Then GUICtrlCreateListViewItem('|' & $sItemText,$idLV)
Next
_GUICtrlListView_SetColumnWidth($idLV,0, $LVSCW_AUTOSIZE_USEHEADER)
_GUICtrlListView_SetColumnWidth($idLV,1, $LVSCW_AUTOSIZE)
GUISetState()


while 1
    switch guigetmsg()
        case $gui_event_close
            Exit
        Case $idtnDL
            $sDownloads=FileSelectFolder("Choose folder you want to save the file's","")
            ConsoleWrite($sDownloads&@CRLF)
            If $sDownloads<>'' Then
                For $x = 0 To _GUICtrlListView_GetItemCount($idLV)
                    If _GUICtrlListView_GetItemChecked($idLV,$x) Then
                        $sItemText=_GUICtrlListView_GetItemText($idLV,$x,1)
                        $sRPath=$sDL_URL&'/'&$sItemText
                        $sLPath=$sDownloads&'\'&$sItemText
                        ConsoleWrite($sRPath&@TAB&$sLPath&@TAB)
                        $iBytes=InetGet($sRPath,$sLPath,0,0)
                        ;1. 0= Get the file from local cache if available
                        ;2. 0=waiting DL for File is comlete
                        ConsoleWrite($iBytes&' Bytes'&@CRLF)
                    EndIf
                Next
                ConsoleWrite('DL finished'&@CRLF)
            EndIf
    EndSwitch
WEnd

 

The GUICtrlCreateListView provides a nice platform for downloading mapping data. 

Thank you, Kylomas and AutoBert for the support on this post. 

 

Link to comment
Share on other sites

I added a URL GUICtrlCreateListView on the right to replace the Global $sDL_URL="" but it doesn't show the downloads. The idea was to implement multiple URL links and store the data instead of using a single variable. 

#include <ListViewConstants.au3>
#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>
#include <ie.au3>
#include <array.au3>
#include <EditConstants.au3>

HotKeySet("{ESC}", "Terminate")

;|RIGHT|IE|DOWNLOAD|
;Global $sDL_URL="http://downloads.ddti.net/starkoh/" [Replaced with $ConfigURL to store multiple DL address]
;ftp://68.142.166.18/TUSC_GIS_FTP/Tus157_gis-mapdatastore/" ;County Data
;http://downloads.ddti.net/starkoh/" ;County Data

Global $ConfigCounty, $ConfigURL
Global $ConfigList
Global $hGui=GUICreate('MapFiles DL',640,480)

Global $idLV=GUICtrlCreateListView('DL|RemoteFilename',350,5,288,430,$LVS_REPORT,BitOR($LVS_EX_CHECKBOXES,$LVS_EX_FULLROWSELECT))
Global $idtnDL=GUICtrlCreateButton('&Download checked Files',350,445,200,25,BitOR($BS_CENTER,$BS_DEFPUSHBUTTON))
Global $oIE = _IECreate($ConfigURL,0,0)
Global $links = _IELinkGetCollection($oIE)
Global $sItemText, $sLPath, $sRPath, $iBytes

For $link In $links
    $sItemText=stringregexpreplace($link.href,'.*/(.*)','$1')
    If $sItemText <> '' Then GUICtrlCreateListViewItem('|' & $sItemText,$idLV)
Next
_GUICtrlListView_SetColumnWidth($idLV,0, $LVSCW_AUTOSIZE_USEHEADER)
_GUICtrlListView_SetColumnWidth($idLV,1, $LVSCW_AUTOSIZE)

;|LEFT|DATABASE|URL|COUNTY|
Func ConfigData()

    $ConfigList = GUICtrlCreateListView("County |URL", 5, 5, 305, 360, $LVS_REPORT)
    _GUICtrlListView_SetColumnWidth($ConfigList, 0, 70)
    _GUICtrlListView_SetColumnWidth($ConfigList, 1, 160)
    _GUICtrlListView_SetColumnWidth($ConfigList, 2, 70)

    GUICtrlCreateLabel("URL:", 5, 380, 60, 20)
    GUICtrlCreateLabel("County:", 5, 410, 60, 20)

    $ConfigURL = GUICtrlCreateInput("", 70, 380, 240, 20)

    $ConfigCounty = GUICtrlCreateInput("", 70, 410, 80, 20)

    $ConfigAdd = GUICtrlCreateButton("Add", 20, 450, 80, 25)
    $ConfigRem = GUICtrlCreateButton("Remove", 115, 450, 80, 25)
    $ConfigClr = GUICtrlCreateButton("Clear", 210, 450, 80, 25)

    GUISetState()

    Do
        $msg = GUIGetMsg()
        Switch $msg
            Case $ConfigAdd
                ConfigAddData()
            Case $ConfigRem
                ConfigRemData()
            Case $ConfigClr
                ConfigClrData()
        EndSwitch
    Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>ConfigData

Func ConfigAddData()
    $ReadCounty = GUICtrlRead($ConfigCounty)
    $ReadURL = GUICtrlRead($ConfigURL)

    GUICtrlCreateListViewItem($ReadCounty & "|" & $ReadURL, $ConfigList)

    GUICtrlSetData($ConfigCounty, "")
    GUICtrlSetData($ConfigURL, "")
EndFunc   ;==>ConfigAddData

Func ConfigRemData()
    _GUICtrlListView_DeleteItemsSelected($ConfigList)
EndFunc   ;==>ConfigRemData

Func ConfigClrData()
    _GUICtrlListView_DeleteAllItems($ConfigList)
EndFunc   ;==>ConfigClrData

GUISetState()

while 1
    ConfigData()
    switch guigetmsg()
        case $gui_event_close
            Exit
        Case $idtnDL
            $sDownloads=FileSelectFolder("Choose folder you want to save the file's","")
            ConsoleWrite($sDownloads&@CRLF)
            If $sDownloads<>'' Then
                For $x = 0 To _GUICtrlListView_GetItemCount($idLV)
                    If _GUICtrlListView_GetItemChecked($idLV,$x) Then
                        $sItemText=_GUICtrlListView_GetItemText($idLV,$x,1)
                        $sRPath=$ConfigURL&'/'&$sItemText
                        $sLPath=$sDownloads&'\'&$sItemText
                        ConsoleWrite($sRPath&@TAB&$sLPath&@TAB)
                        $iBytes=InetGet($sRPath,$sLPath,0,0)
                        ;1. 0= Get the file from local cache if available
                        ;2. 0=waiting DL for File is comlete
                        ConsoleWrite($iBytes&' Bytes'&@CRLF)
                    EndIf
                Next
                ConsoleWrite('DL finished'&@CRLF)
            EndIf
    EndSwitch
WEnd

Func Terminate()
    Exit
EndFunc   ;==>Terminate

Link to comment
Share on other sites

Your code was not the best and (for me)  bad to read, so renamed some Variables, moved functions to another place etc. For my logic of UI a Button for filling DL-Listview must be,  so inserted. It's tested only little because my internetspeed is very poor (64 kbits/s).

Here is the script: mapDL.au3 It's not the best but runable.

What should be done:

  • commenting the script (by you with trying to understand the logic behind and reading about the (yet) unknown functions
  • searching for unused variables and funcs.

What could be done:

  • switch from the script blocking mode of InetGet to X Background Downloads at same time. 
  • adding additional infos of the DL-files (size, date)
  • sorting the LV by clicking ColumnHeader
  • and, and ...

But please when implementing new features test the example(s) of needed func's.

 

Have fun with the script and test excesive (it's 4:50 in Germany and i am tired)  

Link to comment
Share on other sites

On 1/29/2016 at 10:44 PM, AutoBert said:

Your code was not the best and (for me)  bad to read, so renamed some Variables, moved functions to another place etc. For my logic of UI a Button for filling DL-Listview must be,  so inserted. It's tested only little because my internetspeed is very poor (64 kbits/s).

Here is the script: mapDL.au3 It's not the best but runable.

What should be done:

  • commenting the script (by you with trying to understand the logic behind and reading about the (yet) unknown functions
  • searching for unused variables and funcs.

What could be done:

  • switch from the script blocking mode of InetGet to X Background Downloads at same time. 
  • adding additional infos of the DL-files (size, date)
  • sorting the LV by clicking ColumnHeader
  • and, and ...

But please when implementing new features test the example(s) of needed func's.

 

Have fun with the script and test excesive (it's 4:50 in Germany and i am tired)  

I will definitely do my best to improve my knowledge in AutoIT and become a better programmer. Thanks for the support and advice. I'll strive towards improving this project one day at a time!

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...