Jump to content
Sign in to follow this  
goldenix

recrusive func question.

Recommended Posts

goldenix

I want to recrusively DL friles from server.

But the problem is that the new folder URL is not being declared, & I do not understand why. I mean I do re declare the new URL in the function, so why does it not work?

Instead _ScanFolder($oLink.href) this function is called for some reason: _ScanFolder($URL)

Sample: Instead _ScanFolder(site.com/enviromnent/textures/) this function is called for some reason: _ScanFolder(site.com/enviromnent)

_ScanFolder($URL)

Func _ScanFolder($URL)
    
    $split = StringSplit($oLink.href,'booo/',1)
    $split = $split[2]

    ;get link collection
;~  ......................
    For $oLink In $oLinks
            
            If StringInStr($split,'.') Then         ;its a file DL it       
                ;
            Else                                    ;its folder scan it
                
                _ScanFolder($oLink.href)            
            EndIf
        EndIf
    Next
EndFunc
Edited by goldenix

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites
Authenticity

Maybe it should be like this?

_ScanFolder($URL)

Func _ScanFolder($URL)
   
    $split = StringSplit($URL,'booo/',1) ; Was $oLink.href.
    $split = $split[2]

    ;get link collection
;~  ......................
    For $oLink In $oLinks
           
            If StringInStr($split,'.') Then         ;its a file DL it      
                ;
            Else                                    ;its folder scan it
               
                _ScanFolder($oLink.href)           
            EndIf
        EndIf
    Next
EndFunc

Share this post


Link to post
Share on other sites
goldenix

I think i have found the problem but im not 100% sure yet.

The folders on the server have russian names & it seems there are some hidden links the browser wont show you. And there is also a link to the parent dir. & because it includes russian chars I need to screw around with browser generated replacements for those chars [sample: %d0%98%d0%b3] But when autoit retrieves the link it looks different than this d0%...... & tried to stringreplace, but its unable to find the string it gave me in the first place.

& this is freakin complicated.

I tried saving IE.au3 as UTF 8 my script is also UTF8 & it still does not recognize the chars.

I remember that in some old autoit & scite version i had no problems handeling japanese, chineese, russian text strings. But I really dont know now.

Edited by goldenix

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites
MrCreatoR

About the urls with russian (perhaps with other to) chars - Try this example:

$sOriginal_URL = "http://ru.wikipedia.org/wiki/Википедия"

$sStringURLToHex = _StringURLToHex($sOriginal_URL)
$sStringHexToURL = _StringHexToURL($sStringURLToHex)

MsgBox(64, 'Results', _
    StringFormat("Original: %s\n\nURL To Hex: %s\n\n\nOriginal: %s\n\nHex To URL: %s", _
    $sOriginal_URL, $sStringURLToHex, $sStringURLToHex, $sStringHexToURL))

Func _StringURLToHex($sURLString)
    ;=========== _StringToUTF($sString) ===========
    
    Local $sString = $sURLString
    
    Local $sResult = "", $iCode
    Local $VarUTFArr = StringSplit($sString, "")
    
    For $i = 1 To $VarUTFArr[0]
        $iCode = Asc($VarUTFArr[$i])
        
        Select
            Case $iCode >= 192 And $iCode <= 239
                $VarUTFArr[$i] = Chr(208) & Chr($iCode - 48)
            Case $iCode >= 240 And $iCode <= 255
                $VarUTFArr[$i] = Chr(209) & Chr($iCode - 112)
            Case $iCode = 168
                $VarUTFArr[$i] = Chr(208) & Chr(129)
            Case $iCode = 184
                $VarUTFArr[$i] = Chr(209) & Chr(145)
            Case Else
                $VarUTFArr[$i] = Chr($iCode)
        EndSelect
        
        $sResult &= $VarUTFArr[$i]
    Next
    ;=========== _StringToUTF($sString) ===========
    
    $sURLString = $sResult
    
    Local $aURLStrSplit = StringSplit($sURLString, "")
    Local $sRetString = ""
    
    For $i = 1 To UBound($aURLStrSplit)-1
        If Not StringRegExp($aURLStrSplit[$i], '(?i)[a-z]|\.|-|_') Then $aURLStrSplit[$i] = "%" & Hex(Asc($aURLStrSplit[$i]), 2)
        $sRetString &= $aURLStrSplit[$i]
    Next
    
    Return $sRetString
EndFunc

Func _StringHexToURL($sURLHex)
    Local $aURLHexSplit = StringSplit($sURLHex, "")
    Local $sRetString = "", $iDec, $iUbound = UBound($aURLHexSplit)
    
    For $i = 1 To $iUbound-1
        If $aURLHexSplit[$i] = "%" And $i+2 <= $iUbound-1 Then
            $i += 2
            $iDec = Dec($aURLHexSplit[$i-1] & $aURLHexSplit[$i])
            
            If Not @error Then
                $sRetString &= Chr($iDec)
            Else
                $sRetString &= $aURLHexSplit[$i-2]
            EndIf
        Else
            $sRetString &= $aURLHexSplit[$i]
        EndIf
    Next
    
    ;_UTF8ToANSI($sUTF8):
    
    Local $sUTF8 = $sRetString
    
    Local $iLen = StringLen($sUTF8)
    Local $stBuf = DllStructCreate("byte[" & $iLen * 2 & "];byte[2]")
    
    Local $aRet = DllCall("Kernel32.dll", "int", "MultiByteToWideChar", _
            "int", 65001, "int", 0, _
            "str", $sUTF8, "int", -1, _
            "ptr", DllStructGetPtr($stBuf), "int", $iLen * 2 + 2)
    
    Local $stOut = DllStructCreate("char[" & $iLen & "];char")
    
    $aRet = DllCall("kernel32.dll", "int", "WideCharToMultiByte", _
            "int", 0, "int", 0, _
            "ptr", DllStructGetPtr($stBuf), "int", -1, _
            "ptr", DllStructGetPtr($stOut), "int", $iLen + 1, _
            "int", 0, "int", 0)
    
    Return DllStructGetData($stOut, 1)
EndFunc

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites
goldenix

im getting this: is this normal?

Results
Original: http%3A%2F%2Fru.wikipedia.org%2Fwiki%2F%3F%3F%3F%3F%3F%3F%3F%3F%3F

URL To Hex: http%3A%2F%2Fru.wikipedia.org%2Fwiki%2F%3F%3F%3F%3F%3F%3F%3F%3F%3F


Original: http://ru.wikipedia.org/wiki/?????????

Hex To URL:
Edited by goldenix

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites
MrCreatoR

im getting this: is this normal?

Results
Original: http%3A%2F%2Fru.wikipedia.org%2Fwiki%2F%3F%3F%3F%3F%3F%3F%3F%3F%3F

URL To Hex: http%3A%2F%2Fru.wikipedia.org%2Fwiki%2F%3F%3F%3F%3F%3F%3F%3F%3F%3F


Original: http://ru.wikipedia.org/wiki/?????????

Hex To URL:
No, it's probably because your system's native language (english?), i get this:

Posted Image

Or maybe it's not copied properly, try the attached file.

_StringURLToHex.zip


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites
goldenix

No, it's probably because your system's native language (english?), i get this:

Or maybe it's not copied properly, try the attached file.

_StringURLToHex.zip

now this is funny. I run my file & I get this:

Posted Image

Then I run your file & get this: And after I save your file in UTF 8 format I still get this:

Posted Image

ill try to reinstall my language packs, I did my OS with Nlite, maybe its because of that. (but i did include russian & Asian languages.)

EDIT: not I tried this in clean Win XP install in my virtual os, same thing.

Edited by goldenix

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites
MrCreatoR

The second one is ok, you just see it like this in the message box (it's converted by the functions to UTF-8 and back to ANSI).


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.