Jump to content

_FF_DM.au3 for FF.au3


Stilgar
 Share

Recommended Posts

Here's an UDF to control the FireFox Download-Manager (not the download-window):

_FF_DM.au3

Current functions:

; _FF_DM_CleanUp

; _FF_DM_DownloadPause

; _FF_DM_DownloadRemove

; _FF_DM_DownloadResume

; _FF_DM_DownloadCancel

; _FF_DM_DownloadRetry

; _FF_DM_GetActiveDownloadsIDs

; _FF_DM_GetActiveDownloadsCount

; _FF_DM_GetDownloadInfo

; _FF_DM_GetDownloadState

; _FF_DM_IsDownloading

Requirement(s).: FF.au3 >= 0.5.3.0 / MozRepl

Example (to try this, start at first to download a bigger file);

#Region Includes
#include <Array.au3>
#include <_FF_DM.au3>
#EndRegion Includes

If _FFConnect() Then
    If _FF_DM_IsDownloading() Then
        ; IDs of the current downloads
        $aIDs = _FF_DM_GetActiveDownloadsIDs()
        _ArrayDisplay($aIDs)

        If UBound($aIDs) > 1 Then
            ; Informations about the first download
            $aInfo = _FF_DM_GetDownloadInfo($aIDs[1])
            _ArrayDisplay($aInfo)

            ; Pausing the first download
            _FF_DM_DownloadPause($aIDs[1])
            If _FF_DM_GetDownloadState($aIDs[1]) = 4 Then MsgBox(64,"Download paused:",$aInfo[6])
            sleep(5000)

            ; Resume the first download
            _FF_DM_DownloadResume($aIDs[1])
            If _FF_DM_GetDownloadState($aIDs[1]) = 0 Then MsgBox(64,"Download is active:",$aInfo[6])
        EndIf
    EndIf
EndIf

Exit
Edited by Stilgar
Link to comment
Share on other sites

  • 4 weeks later...

I wonder about some of this...like..

Func __FF_DM_Action($sAction, $iID = -1, $sAttr = "")
    Local $sState = ""
    If $iID > -1 Then
        $iID = '(' & $iID & ')'
    Else
        $iID = ""
    EndIf
    Local $RetVal = _FFCmd('try{FFau3.obj = Components.classes["@mozilla.org/download-manager;1"].getService(Components.interfaces.nsIDownloadManager).' & $sAction & $iID & $sAttr & ';}catch(e){-3;};')
    SetError(@error)
    Return $RetVal
EndFunc   ;==>__FF_DM_ActionoÝ÷ ÚÈhºW[y«­¢+ÙÕ¹}}}5}Ñ¥½¸ ÀÌØíÍÑ¥½¸°ÀÌØí¥%ôÅÕ½ÐìÅÕ½Ðì°ÀÌØíÍÑÑÈôÅÕ½ÐìÅÕ½Ðì¤(%%ÀÌØí¥%±ÐìÐìÅÕ½ÐìÅÕ½ÐìQ¡¸ÀÌØí¥%ôÌäì ÌäìµÀìÀÌØí¥%µÀìÌäì¤Ìäì(%1½°ÀÌØíIÑY°ô}
µ ÌäíÑÉåíÔ̹½¨ô
½µÁ½¹¹Ñ̹±ÍÍÍlÅÕ½Ðíµ½é¥±±¹½É½½Ý¹±½µµ¹ÈìÄÅÕ½Ðít¹ÑMÉÙ¥¡
½µÁ½¹¹Ñ̹¥¹ÑÉ̹¹Í%½Ý¹±½5¹È¤¸ÌäìµÀìÀÌØíÍÑ¥½¸µÀìÀÌØí¥%µÀìÀÌØíÍÑÑȵÀìÌäìíõÑ ¡¥ì´ÌíôìÌäì¤(%IÑÕɸMÑÉɽȡÉɽȰÅÕ½ÐìÅÕ½Ðì°ÀÌØíIÑY°¤)¹Õ¹ìôôÐí}}}5}Ñ¥½¸

Thanks for sharing your work!!!

8)

NEWHeader1.png

Link to comment
Share on other sites

...

Func __FF_DM_Action($sAction, $iID = "", $sAttr = "")
    If $iID <> "" Then $iID = '(' & $iID & ')'
    Local $RetVal = _FFCmd('try{FFau3.obj = Components.classes["@mozilla.org/download-manager;1"].getService(Components.interfaces.nsIDownloadManager).' & $sAction & $iID & $sAttr & ';}catch(e){-3;};')
    Return SetError(@error, "", $RetVal)
EndFunc   ;==>__FF_DM_Action
Yes that's right. On my first tries with this interface I received sometimes a -1 ID (from an other function) and I forget to change this ^_^ Edited by Stilgar
Link to comment
Share on other sites

Thanks for sharing! ^_^

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

  • 4 months later...

(((( Posted Image what i can do? :D

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Link to comment
Share on other sites

What have you tried to do? I can't reproduce this error.

i have this error for all ur examples.. like this:

#Region Includes
#include <Array.au3>
#include <_FF_DM.au3>
#EndRegion Includes

If _FFConnect() Then
    If _FF_DM_IsDownloading() Then
        ; IDs of the current downloads
        $aIDs = _FF_DM_GetActiveDownloadsIDs()
        _ArrayDisplay($aIDs)

        If UBound($aIDs) > 1 Then
            ; Informations about the first download
            $aInfo = _FF_DM_GetDownloadInfo($aIDs[1])
            _ArrayDisplay($aInfo)

            ; Pausing the first download
            _FF_DM_DownloadPause($aIDs[1])
            If _FF_DM_GetDownloadState($aIDs[1]) = 4 Then MsgBox(64,"Download paused:",$aInfo[6])
            sleep(5000)

            ; Resume the first download
            _FF_DM_DownloadResume($aIDs[1])
            If _FF_DM_GetDownloadState($aIDs[1]) = 0 Then MsgBox(64,"Download is active:",$aInfo[6])
        EndIf
    EndIf
EndIf

Exit

i runs more 10 examples.. and all give this error :D i have latest version of all FF scripts and MozRelp :D

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Link to comment
Share on other sites

This example works here, too.

It looks like an error in the FF.au3, because of the unkown function name. Have you tried to download it again?

yes, ohh now is new error.. now that script can't run _FF_DM.au3

line 3 "#include <_FF_DM.au3>" i updated that file(( but that error is again(( ohhhhh...

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Link to comment
Share on other sites

  • 1 month later...

Hi all,

I was wondering if there's a way to start a download from autoit using the FireFox scripts...

I see that the download manager only help keeping track of the downloads, but is there a way I can start a download from the script of a image file for example? instead of opening it in firefox and doing a "saveas" ?

btw - i know i can use InetGet but i'm trying to download something that requires me to log-in, so the website recognizes InetGet is not logged in and it doesn't work and i must do it from the browser...

10x.

Edited by hagaizenberg
Link to comment
Share on other sites

Hi all,

I was wondering if there's a way to start a download from autoit using the FireFox scripts...

I see that the download manager only help keeping track of the downloads, but is there a way I can start a download from the script of a image file for example? instead of opening it in firefox and doing a "saveas" ?

btw - i know i can use InetGet but i'm trying to download something that requires me to log-in, so the website recognizes InetGet is not logged in and it doesn't work and i must do it from the browser...

10x.

You can use this function:

; example
_FF_DownloadFile("https://developer.mozilla.org/skins/mozilla/Fox3/img/mdc-logo.png", "c:\\")
; ==============================================================================
Func _FF_DownloadFile($sURL, $sDir = "")
    If $sDir = "" Then
        $sDir = _FFPrefGet("browser.download.defaultFolder")
        If $sDir = "" Then $sDir = @DesktopDir & "\"
    Else
        If Not StringInStr(FileGetAttrib($sDir), "D") Then
            SetError(1)
            Return 0
        EndIf
    EndIf
    Local $sFile = StringMid($sURL, StringInStr($sURL, "/", 2, -1) + 1)
    $sFile = $sDir & $sFile

    $sFile = StringReplace($sFile, "\", "\\")
    Local $sJavascript = 'var Ci=Components.interfaces;var Cc=Components.classes;'
    $sJavascript &= 'var oSrc=Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService).newURI("' & $sURL & '", null, null);'
    $sJavascript &= 'var oDst=Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);'
    $sJavascript &= 'oDst.initWithPath("' & $sFile & '");if(!oDst.exists()){oDst.create(0x00,0644);}'
    $sJavascript &= 'var nsIWBP=Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"].createInstance(Ci.nsIWebBrowserPersist);'
    $sJavascript &= 'nsIWBP.saveURI(oSrc,null,null,null,null,oDst);'
    If _FFCmd($sJavascript) <> "_FFCmd_Err" And FileExists($sFile) Then Return 1
    SetError(1)
    Return 0
EndFunc   ;==>_FFDownloadFile

It only downloads they file, but currently it don't add it to the download-manager.

Or if you have the AddOn "DownThemAll" installed, you can do this:

; example:
_FF_DTA_SaveSingleLink("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe")
;=============================================================
Func _FF_DTA_SaveSingleLink($sURL, $sReferrer = "")
    If $sReferrer = "" Then $sReferrer = _FFCmd(".location.href")
    _FFCmd(StringFormat("DTA_AddingFunctions.saveSingleLink(true,'%s', '%s')", $sURL, $sReferrer))
EndFunc
Link to comment
Share on other sites

  • 2 months later...

I not found manual helper on FF_DM ... i need monitor download of firefox without add-ons! Have idea? how to make for autoit?

I see a interessant of add-ons Auto-Shutdown is show download square 1 files/ 2 files (i need how to make show files 1,2,3,4....)

http://inbasic.mozdev.org/root/ext2/home/index.htm

Please me help.. thanks

Programmer PHP, ASP, CGI, Perl, Delphi, JScript, ......... :)

Link to comment
Share on other sites

I not found manual helper on FF_DM ... i need monitor download of firefox without add-ons! Have idea? how to make for autoit?

I see a interessant of add-ons Auto-Shutdown is show download square 1 files/ 2 files (i need how to make show files 1,2,3,4....)

http://inbasic.mozdev.org/root/ext2/home/index.htm

Please me help.. thanks

You can use Stilgar's _FF_DM UDF or monitor the Firefox download list located in the Profiles folder

(think its "@AppDataDir & "\Mozilla\Firefox\Profiles\" & Current User Profile & "\downloads.sqlite")

I used to use the download list until Stilgar produced his beautiful UDF. I did a quick and dirty

upgrade and ended up with a combination of both.

Link to comment
Share on other sites

  • 3 years later...
  • 11 months later...
  • 1 year later...

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