1 (изменено: OmTatSat, 2016-07-06 12:31:56)

Тема: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Возможно ли вытянуть прогресс скачивания торрент файла с программы uTorrent?

2

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

http://forum.script-coding.com/viewtopic.php?id=11543

3 (изменено: OmTatSat, 2016-07-05 02:32:07)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Malcev, это нужно через браузер? Далёк от webui.

Через http://forum.script-coding.com/viewtopic.php?id=8336 пишет нужные данные в пункте
Info - SysListView32

Как в этот SysListView32 залезть и вытянуть только прогресс?

Ещё бы как-то указать Child и id 1, только как?

4

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Это не через браузер, а через WinHTTPRequest.
Вот тут написано про интерфейс:
http://wd-x.ru/programma-utorrent-veb-interfejs/

5

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Malcev, первый скрипт вытягивает нужную информацию

{"build":28705,"label": [
]
,"torrents": [

["A5246C18C4BD5E29C84059CE17C3E0E33E172BD9",201,"Dark.Matter.S02E01.400p.HDTV.ColdFilm.Ru.avi",354526918,368,130580480,0,0,32,25622,8857,"",0,54,12,27,810439,1,223946438,"","","Загрузка","10cfcd8f",1467667675,0,"","G:\\TORRENTS",0,"C87B3D90"]]
,"torrentc": "82972423"
,"rssfeeds": []
,"rssfilters": []
}

Только нужно с неё ещё вытянуть конкретную информацию - "368" и при отображении поставить запятую после 36...

Второй и третий показывает что-то невразумительное, типа:

Encore Working
proDAD VitaScene v.2.0.232 (32+64)
VideoHive - 3D Abstract Logo R",999\
Adobe.Premiere.Pro.CS6.v6.0.1.014.Multilingual.mundomanuales.com

При чём "Adobe.Premiere.Pro.CS6" не стоит на закачке.

6

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

ip := "192.168.0.150"
port := "8080"
user := "user"
pass := "pass"
url := "http://" ip ":" port "/gui/"
tokenUrl := url "token.html"
action := "?list=1"
HTTP := ComObjCreate("WinHTTP.WinHTTPRequest.5.1")
HTTP.Open("GET", tokenUrl, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
token := "&token=" RegExReplace(HTTP.ResponseText, "<.+?>")
HTTP.Open("GET", url action token, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
JsonString := HTTP.ResponseText

JS := new ActiveScript("JScript")
JS.eval("delete ActiveXObject; delete GetObject;") 

obj := JS.eval("(" . JsonString . ")").torrents
SetFormat,Float,0.1
Loop % obj.length
   MsgBox % obj[A_Index - 1][2] " - " obj[A_Index - 1][4]/10 "%"


/*
 *  ActiveScript for AutoHotkey v1.1
 *
 *  Provides an interface to Active Scripting languages like VBScript and JScript,
 *  without relying on Microsoft's ScriptControl, which is not available to 64-bit
 *  programs.
 *
 *  License: Use, modify and redistribute without limitation, but at your own risk.
 */
class ActiveScript extends ActiveScript._base
{
    __New(Language)
    {
        if this._script := ComObjCreate(Language, ActiveScript.IID)
            this._scriptParse := ComObjQuery(this._script, ActiveScript.IID_Parse)
        if !this._scriptParse
            throw Exception("Invalid language", -1, Language)
        this._site := new ActiveScriptSite(this)
        this._SetScriptSite(this._site.ptr)
        this._InitNew()
        this._objects := {}
        this.Error := ""
        this._dsp := this._GetScriptDispatch()  ; Must be done last.
        try
            if this.ScriptEngine() = "JScript"
                this.SetJScript58()
    }

    SetJScript58()
    {
        static IID_IActiveScriptProperty := "{4954E0D0-FBC7-11D1-8410-006008C3FBFC}"
        if !prop := ComObjQuery(this._script, IID_IActiveScriptProperty)
            return false
        VarSetCapacity(var, 24, 0), NumPut(2, NumPut(3, var, "short") + 6)
        hr := DllCall(NumGet(NumGet(prop+0)+4*A_PtrSize), "ptr", prop, "uint", 0x4000
            , "ptr", 0, "ptr", &var), ObjRelease(prop)
        return hr >= 0
    }
    
    Eval(Code)
    {
        pvar := NumGet(ComObjValue(arr:=ComObjArray(0xC,1)) + 8+A_PtrSize)
        this._ParseScriptText(Code, 0x20, pvar)  ; SCRIPTTEXT_ISEXPRESSION := 0x20
        return arr[0]
    }
    
    Exec(Code)
    {
        this._ParseScriptText(Code, 0x42, 0)  ; SCRIPTTEXT_ISVISIBLE := 2, SCRIPTTEXT_ISPERSISTENT := 0x40
        this._SetScriptState(2)  ; SCRIPTSTATE_CONNECTED := 2
    }
    
    AddObject(Name, DispObj, AddMembers := false)
    {
        static a, supports_dispatch ; Test for built-in IDispatch support.
            := a := ((a:=ComObjArray(0xC,1))[0]:=[42]) && a[0][1]=42
        if IsObject(DispObj) && !(supports_dispatch || ComObjType(DispObj))
            throw Exception("Adding a non-COM object requires AutoHotkey v1.1.17+", -1)
        this._objects[Name] := DispObj
        this._AddNamedItem(Name, AddMembers ? 8 : 2)  ; SCRIPTITEM_ISVISIBLE := 2, SCRIPTITEM_GLOBALMEMBERS := 8
    }
    
    _GetObjectUnk(Name)
    {
        return !IsObject(dsp := this._objects[Name]) ? dsp  ; Pointer
            : ComObjValue(dsp) ? ComObjValue(dsp)  ; ComObject
            : &dsp  ; AutoHotkey object
    }
    
    class _base
    {
        __Call(Method, Params*)
        {
            if ObjHasKey(this, "_dsp")
                try
                    return (this._dsp)[Method](Params*)
                catch e
                    throw Exception(e.Message, -1, e.Extra)
        }
        
        __Get(Property, Params*)
        {
            if ObjHasKey(this, "_dsp")
                try
                    return (this._dsp)[Property, Params*]
                catch e
                    throw Exception(e.Message, -1, e.Extra)
        }
        
        __Set(Property, Params*)
        {
            if ObjHasKey(this, "_dsp")
            {
                Value := Params.Pop()
                try
                    return (this._dsp)[Property, Params*] := Value
                catch e
                    throw Exception(e.Message, -1, e.Extra)
            }
        }
    }
    
    _SetScriptSite(Site)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+3*A_PtrSize), "ptr", p, "ptr", Site)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::SetScriptSite")
    }
    
    _SetScriptState(State)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+5*A_PtrSize), "ptr", p, "int", State)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::SetScriptState")
    }
    
    _AddNamedItem(Name, Flags)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+8*A_PtrSize), "ptr", p, "wstr", Name, "uint", Flags)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::AddNamedItem")
    }
    
    _GetScriptDispatch()
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+10*A_PtrSize), "ptr", p, "ptr", 0, "ptr*", pdsp)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::GetScriptDispatch")
        return ComObject(9, pdsp, 1)
    }
    
    _InitNew()
    {
        hr := DllCall(NumGet(NumGet((p:=this._scriptParse)+0)+3*A_PtrSize), "ptr", p)
        if (hr < 0)
            this._HRFail(hr, "IActiveScriptParse::InitNew")
    }
    
    _ParseScriptText(Code, Flags, pvarResult)
    {
        VarSetCapacity(excp, 8 * A_PtrSize, 0)
        hr := DllCall(NumGet(NumGet((p:=this._scriptParse)+0)+5*A_PtrSize), "ptr", p
            , "wstr", Code, "ptr", 0, "ptr", 0, "ptr", 0, "uptr", 0, "uint", 1
            , "uint", Flags, "ptr", pvarResult, "ptr", 0)
        if (hr < 0)
            this._HRFail(hr, "IActiveScriptParse::ParseScriptText")
    }
    
    _HRFail(hr, what)
    {
        if e := this.Error
        {
            this.Error := ""
            throw Exception("`nError code:`t" this._HRFormat(e.HRESULT)
                . "`nSource:`t`t" e.Source "`nDescription:`t" e.Description
                . "`nLine:`t`t" e.Line "`nColumn:`t`t" e.Column
                . "`nLine text:`t`t" e.LineText, -3)
        }
        throw Exception(what " failed with code " this._HRFormat(hr), -2)
    }
    
    _HRFormat(hr)
    {
        return Format("0x{1:X}", hr & 0xFFFFFFFF)
    }
    
    _OnScriptError(err) ; IActiveScriptError err
    {
        VarSetCapacity(excp, 8 * A_PtrSize, 0)
        DllCall(NumGet(NumGet(err+0)+3*A_PtrSize), "ptr", err, "ptr", &excp) ; GetExceptionInfo
        DllCall(NumGet(NumGet(err+0)+4*A_PtrSize), "ptr", err, "uint*", srcctx, "uint*", srcline, "int*", srccol) ; GetSourcePosition
        DllCall(NumGet(NumGet(err+0)+5*A_PtrSize), "ptr", err, "ptr*", pbstrcode) ; GetSourceLineText
        code := StrGet(pbstrcode, "UTF-16"), DllCall("OleAut32\SysFreeString", "ptr", pbstrcode)
        if fn := NumGet(excp, 6 * A_PtrSize) ; pfnDeferredFillIn
            DllCall(fn, "ptr", &excp)
        wcode := NumGet(excp, 0, "ushort")
        hr := wcode ? 0x80040200 + wcode : NumGet(excp, 7 * A_PtrSize, "uint")
        this.Error := {HRESULT: hr, Line: srcline, Column: srccol, LineText: code}
        static Infos := "Source,Description,HelpFile"
        Loop Parse, % Infos, `,
            if pbstr := NumGet(excp, A_Index * A_PtrSize)
                this.Error[A_LoopField] := StrGet(pbstr, "UTF-16"), DllCall("OleAut32\SysFreeString", "ptr", pbstr)
        return 0x80004001 ; E_NOTIMPL (let Exec/Eval get a fail result)
    }
    
    __Delete()
    {
        if this._script
        {
            DllCall(NumGet(NumGet((p:=this._script)+0)+7*A_PtrSize), "ptr", p)  ; Close
            ObjRelease(this._script)
        }
        if this._scriptParse
            ObjRelease(this._scriptParse)
    }
    
    static IID := "{BB1A2AE1-A4F9-11cf-8F20-00805F2CD064}"
    static IID_Parse := A_PtrSize=8 ? "{C7EF7658-E1EE-480E-97EA-D52CB4D76D17}" : "{BB1A2AE2-A4F9-11cf-8F20-00805F2CD064}"
}

class ActiveScriptSite
{
    __New(Script)
    {
        ObjSetCapacity(this, "_site", 3 * A_PtrSize)
        NumPut(&Script
        , NumPut(ActiveScriptSite._vftable("_vft_w", "31122", 0x100)
        , NumPut(ActiveScriptSite._vftable("_vft", "31125232211", 0)
            , this.ptr := ObjGetAddress(this, "_site"))))
    }
    
    _vftable(Name, PrmCounts, EIBase)
    {
        if p := ObjGetAddress(this, Name)
            return p
        ObjSetCapacity(this, Name, StrLen(PrmCounts) * A_PtrSize)
        p := ObjGetAddress(this, Name)
        Loop Parse, % PrmCounts
        {
            cb := RegisterCallback("_ActiveScriptSite", "F", A_LoopField, A_Index + EIBase)
            NumPut(cb, p + (A_Index-1) * A_PtrSize)
        }
        return p
    }
}

_ActiveScriptSite(this, a1:=0, a2:=0, a3:=0, a4:=0, a5:=0)
{
    Method := A_EventInfo & 0xFF
    if A_EventInfo >= 0x100  ; IActiveScriptSiteWindow
    {
        if Method = 4  ; GetWindow
        {
            NumPut(0, a1+0) ; *phwnd := 0
            return 0 ; S_OK
        }
        if Method = 5  ; EnableModeless
        {
            return 0 ; S_OK
        }
        this -= A_PtrSize     ; Cast to IActiveScriptSite
    }
    ;else: IActiveScriptSite
    if Method = 1  ; QueryInterface
    {
        iid := _AS_GUIDToString(a1)
        if (iid = "{00000000-0000-0000-C000-000000000046}"  ; IUnknown
         || iid = "{DB01A1E3-A42B-11cf-8F20-00805F2CD064}") ; IActiveScriptSite
        {
            NumPut(this, a2+0)
            return 0 ; S_OK
        }
        if (iid = "{D10F6761-83E9-11cf-8F20-00805F2CD064}") ; IActiveScriptSiteWindow
        {
            NumPut(this + A_PtrSize, a2+0)
            return 0 ; S_OK
        }
        NumPut(0, a2+0)
        return 0x80004002 ; E_NOINTERFACE
    }
    if Method = 5  ; GetItemInfo
    {
        a1 := StrGet(a1, "UTF-16")
        , (a3 && NumPut(0, a3+0))  ; *ppiunkItem := NULL
        , (a4 && NumPut(0, a4+0))  ; *ppti := NULL
        if (a2 & 1) ; SCRIPTINFO_IUNKNOWN
        {
            if !(unk := Object(NumGet(this + A_PtrSize*2))._GetObjectUnk(a1))
                return 0x8002802B ; TYPE_E_ELEMENTNOTFOUND
            ObjAddRef(unk), NumPut(unk, a3+0)
        }
        return 0 ; S_OK
    }
    if Method = 9  ; OnScriptError
        return Object(NumGet(this + A_PtrSize*2))._OnScriptError(a1)
    
    ; AddRef and Release don't do anything because we want to avoid circular references.
    ; The site and IActiveScript are both released when the AHK script releases its last
    ; reference to the ActiveScript object.
    
    ; All of the other methods don't require implementations.
    return 0x80004001 ; E_NOTIMPL
}

_AS_GUIDToString(pGUID)
{
    VarSetCapacity(String, 38*2)
    DllCall("ole32\StringFromGUID2", "ptr", pGUID, "str", String, "int", 39)
    return String
}

Но там еще надо учесть проверку на ошибки:

* STATUS: The STATUS is a bitwise value, which is obtained by adding up the different values for corresponding statuses:

1 = Started2 = Checking4 = Start after check8 = Checked16 = Error32 = Paused64 = Queued128 = Loaded

For example, if a torrent job has a status of 201 = 128 + 64 + 8 + 1, then it is loaded, queued, checked, and started. A bitwise AND operator should be used to determine whether the given STATUS contains a particular status.

Я не знаю, как посчитать это побитово.

7

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Malcev, класс - работает! Спасибо!
Теперь бы ещё это отобразить прогрессбаром с какого-то края экрана.

8 (изменено: OmTatSat, 2016-07-06 02:26:54)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Вот такое насочинял.

loop
{
Loop % obj.length
{
   ;MsgBox % obj[A_Index - 1][4]/10
   p = % obj[A_Index - 1][4]/10
   n = % obj[A_Index - 1][2]
   s = % obj[A_Index - 1][9]/1000000
   t = % obj[A_Index - 1][10]/60
;MsgBox, % p
Progress, ws10 Fs7 ZY0 ZX0 ZW0 zh5 x1 y1 b w1750 h17 p%p%, %p%`% - %n% = %s%мб/с -- %t%м , ,
;Progress, % p ; Set the position of the bar to 50%.
}
sleep, 3000
}

Только есть проблемка, прогресс при обновлении идёт сначала до изменённого прогресса, как сделать, чтобы он просто продолжал идти дальше заместо каждый раз сначала?

9 (изменено: OmTatSat, 2016-07-06 12:38:22)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Рабочий вариант.
На монитор 1680х1050

Text=Shadowed

TextColor=ff00ff
ShadowColor=0725e6
TransColor=000003
Gui, Margin, 0, 0
;Gui, Color, %TransColor%  
Gui, -SysMenu -ToolWindow -Caption -Border +AlwaysOnTop +E0x20
                              
Gui +LastFound                                     
WinSet, TransColor, %TransColor%
WinSet, ExStyle, ^0x80,
WinSet, Transparent, 190
 
Gui, Font, s7 q5, Verdana
Gui, Add, Text, x4 y0 w1660 h8 Center c%ShadowColor%  BackgroundTrans vProg +0x201 , 
Gui, Add, Progress, w1678 h4 x0 y10 cBlue vMyProgress
Gui, Show, x1 y1037, AlwaysOnTop Window
;Gui, Show, HIDE NA
;WinSet Transparent, 100, ahk_id %Gui1%
Loop
{

ip := "192.168.1.107"
port := "8080"
user := "admin"
pass := "*****"
url := "http://" ip ":" port "/gui/"
tokenUrl := url "token.html"
action := "?list=1"
HTTP := ComObjCreate("WinHTTP.WinHTTPRequest.5.1")
HTTP.Open("GET", tokenUrl, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
token := "&token=" RegExReplace(HTTP.ResponseText, "<.+?>")
HTTP.Open("GET", url action token, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
;msgbox % HTTP.ResponseText


JsonString := HTTP.ResponseText

JS := new ActiveScript("JScript")
JS.eval("delete ActiveXObject; delete GetObject;") 

obj := JS.eval("(" . JsonString . ")").torrents
SetFormat,Float,0.1

{
Loop % obj.length
{
   ;MsgBox % obj[A_Index - 1][4]/10
   p = % obj[A_Index - 1][4]/10
   n = % obj[A_Index - 1][2]
   s = % obj[A_Index - 1][9]/1000000
   t = % obj[A_Index - 1][10]/60
;MsgBox, % p
;Progress, ws10 Fs7 ZY0 ZX0 ZW0 zh5 x1 y1 b w1750 h17 p%p%, %p%`% - %n% = %s%мб/с -- %t%м , ,
;Progress, % p ; Set the position of the bar to 50%.

;ToolTip %t%

GuiControl,, MyProgress, %p% vPRBAR cFF7200
GuiControl, , Prog,  %n%   скорость %s% мб/с   осталось-%t% м   завершено %p%`%
WinSetTitle,prog,,%a_space%
;Gui, Font, cBlack
;GuiControl, Font, Prog, 

                     
;Gui, show,W600 H480 , test
;WinSetTitle,test,,%a_space%


}

/*
 *  ActiveScript for AutoHotkey v1.1
 *
 *  Provides an interface to Active Scripting languages like VBScript and JScript,
 *  without relying on Microsoft's ScriptControl, which is not available to 64-bit
 *  programs.
 *
 *  License: Use, modify and redistribute without limitation, but at your own risk.
 */
class ActiveScript extends ActiveScript._base
{
    __New(Language)
    {
        if this._script := ComObjCreate(Language, ActiveScript.IID)
            this._scriptParse := ComObjQuery(this._script, ActiveScript.IID_Parse)
        if !this._scriptParse
            throw Exception("Invalid language", -1, Language)
        this._site := new ActiveScriptSite(this)
        this._SetScriptSite(this._site.ptr)
        this._InitNew()
        this._objects := {}
        this.Error := ""
        this._dsp := this._GetScriptDispatch()  ; Must be done last.
        try
            if this.ScriptEngine() = "JScript"
                this.SetJScript58()
    }

    SetJScript58()
    {
        static IID_IActiveScriptProperty := "{4954E0D0-FBC7-11D1-8410-006008C3FBFC}"
        if !prop := ComObjQuery(this._script, IID_IActiveScriptProperty)
            return false
        VarSetCapacity(var, 24, 0), NumPut(2, NumPut(3, var, "short") + 6)
        hr := DllCall(NumGet(NumGet(prop+0)+4*A_PtrSize), "ptr", prop, "uint", 0x4000
            , "ptr", 0, "ptr", &var), ObjRelease(prop)
        return hr >= 0
    }
    
    Eval(Code)
    {
        pvar := NumGet(ComObjValue(arr:=ComObjArray(0xC,1)) + 8+A_PtrSize)
        this._ParseScriptText(Code, 0x20, pvar)  ; SCRIPTTEXT_ISEXPRESSION := 0x20
        return arr[0]
    }
    
    Exec(Code)
    {
        this._ParseScriptText(Code, 0x42, 0)  ; SCRIPTTEXT_ISVISIBLE := 2, SCRIPTTEXT_ISPERSISTENT := 0x40
        this._SetScriptState(2)  ; SCRIPTSTATE_CONNECTED := 2
    }
    
    AddObject(Name, DispObj, AddMembers := false)
    {
        static a, supports_dispatch ; Test for built-in IDispatch support.
            := a := ((a:=ComObjArray(0xC,1))[0]:=[42]) && a[0][1]=42
        if IsObject(DispObj) && !(supports_dispatch || ComObjType(DispObj))
            throw Exception("Adding a non-COM object requires AutoHotkey v1.1.17+", -1)
        this._objects[Name] := DispObj
        this._AddNamedItem(Name, AddMembers ? 8 : 2)  ; SCRIPTITEM_ISVISIBLE := 2, SCRIPTITEM_GLOBALMEMBERS := 8
    }
    
    _GetObjectUnk(Name)
    {
        return !IsObject(dsp := this._objects[Name]) ? dsp  ; Pointer
            : ComObjValue(dsp) ? ComObjValue(dsp)  ; ComObject
            : &dsp  ; AutoHotkey object
    }
    
    class _base
    {
        __Call(Method, Params*)
        {
            if ObjHasKey(this, "_dsp")
                try
                    return (this._dsp)[Method](Params*)
                catch e
                    throw Exception(e.Message, -1, e.Extra)
        }
        
        __Get(Property, Params*)
        {
            if ObjHasKey(this, "_dsp")
                try
                    return (this._dsp)[Property, Params*]
                catch e
                    throw Exception(e.Message, -1, e.Extra)
        }
        
        __Set(Property, Params*)
        {
            if ObjHasKey(this, "_dsp")
            {
                Value := Params.Pop()
                try
                    return (this._dsp)[Property, Params*] := Value
                catch e
                    throw Exception(e.Message, -1, e.Extra)
            }
        }
    }
    
    _SetScriptSite(Site)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+3*A_PtrSize), "ptr", p, "ptr", Site)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::SetScriptSite")
    }
    
    _SetScriptState(State)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+5*A_PtrSize), "ptr", p, "int", State)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::SetScriptState")
    }
    
    _AddNamedItem(Name, Flags)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+8*A_PtrSize), "ptr", p, "wstr", Name, "uint", Flags)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::AddNamedItem")
    }
    
    _GetScriptDispatch()
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+10*A_PtrSize), "ptr", p, "ptr", 0, "ptr*", pdsp)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::GetScriptDispatch")
        return ComObject(9, pdsp, 1)
    }
    
    _InitNew()
    {
        hr := DllCall(NumGet(NumGet((p:=this._scriptParse)+0)+3*A_PtrSize), "ptr", p)
        if (hr < 0)
            this._HRFail(hr, "IActiveScriptParse::InitNew")
    }
    
    _ParseScriptText(Code, Flags, pvarResult)
    {
        VarSetCapacity(excp, 8 * A_PtrSize, 0)
        hr := DllCall(NumGet(NumGet((p:=this._scriptParse)+0)+5*A_PtrSize), "ptr", p
            , "wstr", Code, "ptr", 0, "ptr", 0, "ptr", 0, "uptr", 0, "uint", 1
            , "uint", Flags, "ptr", pvarResult, "ptr", 0)
        if (hr < 0)
            this._HRFail(hr, "IActiveScriptParse::ParseScriptText")
    }
    
    _HRFail(hr, what)
    {
        if e := this.Error
        {
            this.Error := ""
            throw Exception("`nError code:`t" this._HRFormat(e.HRESULT)
                . "`nSource:`t`t" e.Source "`nDescription:`t" e.Description
                . "`nLine:`t`t" e.Line "`nColumn:`t`t" e.Column
                . "`nLine text:`t`t" e.LineText, -3)
        }
        throw Exception(what " failed with code " this._HRFormat(hr), -2)
    }
    
    _HRFormat(hr)
    {
        return Format("0x{1:X}", hr & 0xFFFFFFFF)
    }
    
    _OnScriptError(err) ; IActiveScriptError err
    {
        VarSetCapacity(excp, 8 * A_PtrSize, 0)
        DllCall(NumGet(NumGet(err+0)+3*A_PtrSize), "ptr", err, "ptr", &excp) ; GetExceptionInfo
        DllCall(NumGet(NumGet(err+0)+4*A_PtrSize), "ptr", err, "uint*", srcctx, "uint*", srcline, "int*", srccol) ; GetSourcePosition
        DllCall(NumGet(NumGet(err+0)+5*A_PtrSize), "ptr", err, "ptr*", pbstrcode) ; GetSourceLineText
        code := StrGet(pbstrcode, "UTF-16"), DllCall("OleAut32\SysFreeString", "ptr", pbstrcode)
        if fn := NumGet(excp, 6 * A_PtrSize) ; pfnDeferredFillIn
            DllCall(fn, "ptr", &excp)
        wcode := NumGet(excp, 0, "ushort")
        hr := wcode ? 0x80040200 + wcode : NumGet(excp, 7 * A_PtrSize, "uint")
        this.Error := {HRESULT: hr, Line: srcline, Column: srccol, LineText: code}
        static Infos := "Source,Description,HelpFile"
        Loop Parse, % Infos, `,
            if pbstr := NumGet(excp, A_Index * A_PtrSize)
                this.Error[A_LoopField] := StrGet(pbstr, "UTF-16"), DllCall("OleAut32\SysFreeString", "ptr", pbstr)
        return 0x80004001 ; E_NOTIMPL (let Exec/Eval get a fail result)
    }
    
    __Delete()
    {
        if this._script
        {
            DllCall(NumGet(NumGet((p:=this._script)+0)+7*A_PtrSize), "ptr", p)  ; Close
            ObjRelease(this._script)
        }
        if this._scriptParse
            ObjRelease(this._scriptParse)
    }
    
    static IID := "{BB1A2AE1-A4F9-11cf-8F20-00805F2CD064}"
    static IID_Parse := A_PtrSize=8 ? "{C7EF7658-E1EE-480E-97EA-D52CB4D76D17}" : "{BB1A2AE2-A4F9-11cf-8F20-00805F2CD064}"
}

class ActiveScriptSite
{
    __New(Script)
    {
        ObjSetCapacity(this, "_site", 3 * A_PtrSize)
        NumPut(&Script
        , NumPut(ActiveScriptSite._vftable("_vft_w", "31122", 0x100)
        , NumPut(ActiveScriptSite._vftable("_vft", "31125232211", 0)
            , this.ptr := ObjGetAddress(this, "_site"))))
    }
    
    _vftable(Name, PrmCounts, EIBase)
    {
        if p := ObjGetAddress(this, Name)
            return p
        ObjSetCapacity(this, Name, StrLen(PrmCounts) * A_PtrSize)
        p := ObjGetAddress(this, Name)
        Loop Parse, % PrmCounts
        {
            cb := RegisterCallback("_ActiveScriptSite", "F", A_LoopField, A_Index + EIBase)
            NumPut(cb, p + (A_Index-1) * A_PtrSize)
        }
        return p
    }
}

_ActiveScriptSite(this, a1:=0, a2:=0, a3:=0, a4:=0, a5:=0)
{
    Method := A_EventInfo & 0xFF
    if A_EventInfo >= 0x100  ; IActiveScriptSiteWindow
    {
        if Method = 4  ; GetWindow
        {
            NumPut(0, a1+0) ; *phwnd := 0
            return 0 ; S_OK
        }
        if Method = 5  ; EnableModeless
        {
            return 0 ; S_OK
        }
        this -= A_PtrSize     ; Cast to IActiveScriptSite
    }
    ;else: IActiveScriptSite
    if Method = 1  ; QueryInterface
    {
        iid := _AS_GUIDToString(a1)
        if (iid = "{00000000-0000-0000-C000-000000000046}"  ; IUnknown
         || iid = "{DB01A1E3-A42B-11cf-8F20-00805F2CD064}") ; IActiveScriptSite
        {
            NumPut(this, a2+0)
            return 0 ; S_OK
        }
        if (iid = "{D10F6761-83E9-11cf-8F20-00805F2CD064}") ; IActiveScriptSiteWindow
        {
            NumPut(this + A_PtrSize, a2+0)
            return 0 ; S_OK
        }
        NumPut(0, a2+0)
        return 0x80004002 ; E_NOINTERFACE
    }
    if Method = 5  ; GetItemInfo
    {
        a1 := StrGet(a1, "UTF-16")
        , (a3 && NumPut(0, a3+0))  ; *ppiunkItem := NULL
        , (a4 && NumPut(0, a4+0))  ; *ppti := NULL
        if (a2 & 1) ; SCRIPTINFO_IUNKNOWN
        {
            if !(unk := Object(NumGet(this + A_PtrSize*2))._GetObjectUnk(a1))
                return 0x8002802B ; TYPE_E_ELEMENTNOTFOUND
            ObjAddRef(unk), NumPut(unk, a3+0)
        }
        return 0 ; S_OK
    }
    if Method = 9  ; OnScriptError
        return Object(NumGet(this + A_PtrSize*2))._OnScriptError(a1)
    
    ; AddRef and Release don't do anything because we want to avoid circular references.
    ; The site and IActiveScript are both released when the AHK script releases its last
    ; reference to the ActiveScript object.
    
    ; All of the other methods don't require implementations.
    return 0x80004001 ; E_NOTIMPL
}

_AS_GUIDToString(pGUID)
{
    VarSetCapacity(String, 38*2)
    DllCall("ole32\StringFromGUID2", "ptr", pGUID, "str", String, "int", 39)
    return String
}

}

sleep 3000
}

return 
GuiEscape:
ExitApp

Может кто-то подскажет как можно сделать подложку только под текстом?
И как сделать, чтобы информация с разных загружаемых в данный момент торрентов чередовалась?

10 (изменено: OmTatSat, 2016-07-09 13:11:11)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Заместо подложки сделал чтобы под прогресс бар не лезли окна.

Информация оказывается и так чередовалась, только этого не было видно из-за отсутствия задержки. Фильтр, чтобы отображать только те которые грузятся тоже получилось сделать.

Сейчас код прогресс бара имеет такой вид.

#NoTrayIcon
#SingleInstance, force
SetTitleMatchMode, 2
DetectHiddenWindows, On
Text=Shadowed



TextColor=ff00ff
ShadowColor=0725e6
TransColor=000003
Gui, Margin, 0, 0
Gui, Color, 000000 
Gui, -SysMenu -ToolWindow -Caption -Border +AlwaysOnTop +E0x20
                              
Gui +LastFound                                     
WinSet, TransColor, %TransColor%
WinSet, ExStyle, ^0x80,
WinSet, Transparent, 190
 
Gui, Font, s7 q5, Verdana
Gui, Add, Text, x1 y0 w1660 h13 Center cf2ee11  BackgroundTrans vProg +0x201 , 
Gui, Add, Progress, w1678 h1 x0 y12 cBlue vMyProgress

     ; Gui, Show, x1 y1037, AlwaysOnTop Window
runonce = 0

Loop
{

Process, Exist, uTorrent.exe
status = %ErrorLevel% 
if status = 0
{
run, "C:\staff\margin\margin hsi.exe" "C:\staff\margin\destroy margin 0.hss" ; убрать кусок отрезаного от приложений экрана
Process, close, uTorrent_osd.exe
}



    


ip := "192.168.1.107"
port := "8080"
user := "admin"
pass := "*****"
url := "http://" ip ":" port "/gui/"
tokenUrl := url "token.html"
action := "?list=1"
HTTP := ComObjCreate("WinHTTP.WinHTTPRequest.5.1")
HTTP.Open("GET", tokenUrl, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
token := "&token=" RegExReplace(HTTP.ResponseText, "<.+?>")
HTTP.Open("GET", url action token, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
Body := HTTP.ResponseBody
pArr := ComObjValue(Body)
cBytes := NumGet(pArr+0, A_PtrSize = 8? 24:16, "uint")
pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, "ptr")
;MsgBox, % StrGet(pText, cBytes, "utf-8")
;msgbox % HTTP.ResponseText


JsonString := StrGet(pText, cBytes, "utf-8")

JS := new ActiveScript("JScript")
JS.eval("delete ActiveXObject; delete GetObject;") 

obj := JS.eval("(" . JsonString . ")").torrents
SetFormat,Float,0.1

{
Loop % obj.length
{
   ;MsgBox % obj[A_Index - 1][4]/10
   p = % obj[A_Index - 1][4]/10
   n = % obj[A_Index - 1][2]
   s = % obj[A_Index - 1][9]/1000000
   t = % obj[A_Index - 1][10]/60

var1 := RegExMatch(p, "(.*)\.", match)

IfNotEqual, match1, 100  
{
    if runonce = 0
    {
    runonce = 1
    run, "C:\staff\margin\margin hsi.exe" "C:\staff\margin\margin bottom 15.hss"
    Gui, Show, x1 y1037, AlwaysOnTop Window
}
GuiControl,, MyProgress, %p% vPRBAR cFF7200

GuiControl, , Prog,  %n%   скорость %s%мб/с   осталось %t%м   завершено %p%`%

sleep, 3000
}



/*
 *  ActiveScript for AutoHotkey v1.1
 *
 *  Provides an interface to Active Scripting languages like VBScript and JScript,
 *  without relying on Microsoft's ScriptControl, which is not available to 64-bit
 *  programs.
 *
 *  License: Use, modify and redistribute without limitation, but at your own risk.
 */
class ActiveScript extends ActiveScript._base
{
    __New(Language)
    {
        if this._script := ComObjCreate(Language, ActiveScript.IID)
            this._scriptParse := ComObjQuery(this._script, ActiveScript.IID_Parse)
        if !this._scriptParse
            throw Exception("Invalid language", -1, Language)
        this._site := new ActiveScriptSite(this)
        this._SetScriptSite(this._site.ptr)
        this._InitNew()
        this._objects := {}
        this.Error := ""
        this._dsp := this._GetScriptDispatch()  ; Must be done last.
        try
            if this.ScriptEngine() = "JScript"
                this.SetJScript58()
    }

    SetJScript58()
    {
        static IID_IActiveScriptProperty := "{4954E0D0-FBC7-11D1-8410-006008C3FBFC}"
        if !prop := ComObjQuery(this._script, IID_IActiveScriptProperty)
            return false
        VarSetCapacity(var, 24, 0), NumPut(2, NumPut(3, var, "short") + 6)
        hr := DllCall(NumGet(NumGet(prop+0)+4*A_PtrSize), "ptr", prop, "uint", 0x4000
            , "ptr", 0, "ptr", &var), ObjRelease(prop)
        return hr >= 0
    }
    
    Eval(Code)
    {
        pvar := NumGet(ComObjValue(arr:=ComObjArray(0xC,1)) + 8+A_PtrSize)
        this._ParseScriptText(Code, 0x20, pvar)  ; SCRIPTTEXT_ISEXPRESSION := 0x20
        return arr[0]
    }
    
    Exec(Code)
    {
        this._ParseScriptText(Code, 0x42, 0)  ; SCRIPTTEXT_ISVISIBLE := 2, SCRIPTTEXT_ISPERSISTENT := 0x40
        this._SetScriptState(2)  ; SCRIPTSTATE_CONNECTED := 2
    }
    
    AddObject(Name, DispObj, AddMembers := false)
    {
        static a, supports_dispatch ; Test for built-in IDispatch support.
            := a := ((a:=ComObjArray(0xC,1))[0]:=[42]) && a[0][1]=42
        if IsObject(DispObj) && !(supports_dispatch || ComObjType(DispObj))
            throw Exception("Adding a non-COM object requires AutoHotkey v1.1.17+", -1)
        this._objects[Name] := DispObj
        this._AddNamedItem(Name, AddMembers ? 8 : 2)  ; SCRIPTITEM_ISVISIBLE := 2, SCRIPTITEM_GLOBALMEMBERS := 8
    }
    
    _GetObjectUnk(Name)
    {
        return !IsObject(dsp := this._objects[Name]) ? dsp  ; Pointer
            : ComObjValue(dsp) ? ComObjValue(dsp)  ; ComObject
            : &dsp  ; AutoHotkey object
    }
    
    class _base
    {
        __Call(Method, Params*)
        {
            if ObjHasKey(this, "_dsp")
                try
                    return (this._dsp)[Method](Params*)
                catch e
                    throw Exception(e.Message, -1, e.Extra)
        }
        
        __Get(Property, Params*)
        {
            if ObjHasKey(this, "_dsp")
                try
                    return (this._dsp)[Property, Params*]
                catch e
                    throw Exception(e.Message, -1, e.Extra)
        }
        
        __Set(Property, Params*)
        {
            if ObjHasKey(this, "_dsp")
            {
                Value := Params.Pop()
                try
                    return (this._dsp)[Property, Params*] := Value
                catch e
                    throw Exception(e.Message, -1, e.Extra)
            }
        }
    }
    
    _SetScriptSite(Site)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+3*A_PtrSize), "ptr", p, "ptr", Site)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::SetScriptSite")
    }
    
    _SetScriptState(State)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+5*A_PtrSize), "ptr", p, "int", State)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::SetScriptState")
    }
    
    _AddNamedItem(Name, Flags)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+8*A_PtrSize), "ptr", p, "wstr", Name, "uint", Flags)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::AddNamedItem")
    }
    
    _GetScriptDispatch()
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+10*A_PtrSize), "ptr", p, "ptr", 0, "ptr*", pdsp)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::GetScriptDispatch")
        return ComObject(9, pdsp, 1)
    }
    
    _InitNew()
    {
        hr := DllCall(NumGet(NumGet((p:=this._scriptParse)+0)+3*A_PtrSize), "ptr", p)
        if (hr < 0)
            this._HRFail(hr, "IActiveScriptParse::InitNew")
    }
    
    _ParseScriptText(Code, Flags, pvarResult)
    {
        VarSetCapacity(excp, 8 * A_PtrSize, 0)
        hr := DllCall(NumGet(NumGet((p:=this._scriptParse)+0)+5*A_PtrSize), "ptr", p
            , "wstr", Code, "ptr", 0, "ptr", 0, "ptr", 0, "uptr", 0, "uint", 1
            , "uint", Flags, "ptr", pvarResult, "ptr", 0)
        if (hr < 0)
            this._HRFail(hr, "IActiveScriptParse::ParseScriptText")
    }
    
    _HRFail(hr, what)
    {
        if e := this.Error
        {
            this.Error := ""
            throw Exception("`nError code:`t" this._HRFormat(e.HRESULT)
                . "`nSource:`t`t" e.Source "`nDescription:`t" e.Description
                . "`nLine:`t`t" e.Line "`nColumn:`t`t" e.Column
                . "`nLine text:`t`t" e.LineText, -3)
        }
        throw Exception(what " failed with code " this._HRFormat(hr), -2)
    }
    
    _HRFormat(hr)
    {
        return Format("0x{1:X}", hr & 0xFFFFFFFF)
    }
    
    _OnScriptError(err) ; IActiveScriptError err
    {
        VarSetCapacity(excp, 8 * A_PtrSize, 0)
        DllCall(NumGet(NumGet(err+0)+3*A_PtrSize), "ptr", err, "ptr", &excp) ; GetExceptionInfo
        DllCall(NumGet(NumGet(err+0)+4*A_PtrSize), "ptr", err, "uint*", srcctx, "uint*", srcline, "int*", srccol) ; GetSourcePosition
        DllCall(NumGet(NumGet(err+0)+5*A_PtrSize), "ptr", err, "ptr*", pbstrcode) ; GetSourceLineText
        code := StrGet(pbstrcode, "UTF-16"), DllCall("OleAut32\SysFreeString", "ptr", pbstrcode)
        if fn := NumGet(excp, 6 * A_PtrSize) ; pfnDeferredFillIn
            DllCall(fn, "ptr", &excp)
        wcode := NumGet(excp, 0, "ushort")
        hr := wcode ? 0x80040200 + wcode : NumGet(excp, 7 * A_PtrSize, "uint")
        this.Error := {HRESULT: hr, Line: srcline, Column: srccol, LineText: code}
        static Infos := "Source,Description,HelpFile"
        Loop Parse, % Infos, `,
            if pbstr := NumGet(excp, A_Index * A_PtrSize)
                this.Error[A_LoopField] := StrGet(pbstr, "UTF-16"), DllCall("OleAut32\SysFreeString", "ptr", pbstr)
        return 0x80004001 ; E_NOTIMPL (let Exec/Eval get a fail result)
    }
    
    __Delete()
    {
        if this._script
        {
            DllCall(NumGet(NumGet((p:=this._script)+0)+7*A_PtrSize), "ptr", p)  ; Close
            ObjRelease(this._script)
        }
        if this._scriptParse
            ObjRelease(this._scriptParse)
    }
    
    static IID := "{BB1A2AE1-A4F9-11cf-8F20-00805F2CD064}"
    static IID_Parse := A_PtrSize=8 ? "{C7EF7658-E1EE-480E-97EA-D52CB4D76D17}" : "{BB1A2AE2-A4F9-11cf-8F20-00805F2CD064}"
}

class ActiveScriptSite
{
    __New(Script)
    {
        ObjSetCapacity(this, "_site", 3 * A_PtrSize)
        NumPut(&Script
        , NumPut(ActiveScriptSite._vftable("_vft_w", "31122", 0x100)
        , NumPut(ActiveScriptSite._vftable("_vft", "31125232211", 0)
            , this.ptr := ObjGetAddress(this, "_site"))))
    }
    
    _vftable(Name, PrmCounts, EIBase)
    {
        if p := ObjGetAddress(this, Name)
            return p
        ObjSetCapacity(this, Name, StrLen(PrmCounts) * A_PtrSize)
        p := ObjGetAddress(this, Name)
        Loop Parse, % PrmCounts
        {
            cb := RegisterCallback("_ActiveScriptSite", "F", A_LoopField, A_Index + EIBase)
            NumPut(cb, p + (A_Index-1) * A_PtrSize)
        }
        return p
    }
}

_ActiveScriptSite(this, a1:=0, a2:=0, a3:=0, a4:=0, a5:=0)
{
    Method := A_EventInfo & 0xFF
    if A_EventInfo >= 0x100  ; IActiveScriptSiteWindow
    {
        if Method = 4  ; GetWindow
        {
            NumPut(0, a1+0) ; *phwnd := 0
            return 0 ; S_OK
        }
        if Method = 5  ; EnableModeless
        {
            return 0 ; S_OK
        }
        this -= A_PtrSize     ; Cast to IActiveScriptSite
    }
    ;else: IActiveScriptSite
    if Method = 1  ; QueryInterface
    {
        iid := _AS_GUIDToString(a1)
        if (iid = "{00000000-0000-0000-C000-000000000046}"  ; IUnknown
         || iid = "{DB01A1E3-A42B-11cf-8F20-00805F2CD064}") ; IActiveScriptSite
        {
            NumPut(this, a2+0)
            return 0 ; S_OK
        }
        if (iid = "{D10F6761-83E9-11cf-8F20-00805F2CD064}") ; IActiveScriptSiteWindow
        {
            NumPut(this + A_PtrSize, a2+0)
            return 0 ; S_OK
        }
        NumPut(0, a2+0)
        return 0x80004002 ; E_NOINTERFACE
    }
    if Method = 5  ; GetItemInfo
    {
        a1 := StrGet(a1, "UTF-16")
        , (a3 && NumPut(0, a3+0))  ; *ppiunkItem := NULL
        , (a4 && NumPut(0, a4+0))  ; *ppti := NULL
        if (a2 & 1) ; SCRIPTINFO_IUNKNOWN
        {
            if !(unk := Object(NumGet(this + A_PtrSize*2))._GetObjectUnk(a1))
                return 0x8002802B ; TYPE_E_ELEMENTNOTFOUND
            ObjAddRef(unk), NumPut(unk, a3+0)
        }
        return 0 ; S_OK
    }
    if Method = 9  ; OnScriptError
        return Object(NumGet(this + A_PtrSize*2))._OnScriptError(a1)
    
    ; AddRef and Release don't do anything because we want to avoid circular references.
    ; The site and IActiveScript are both released when the AHK script releases its last
    ; reference to the ActiveScript object.
    
    ; All of the other methods don't require implementations.
    return 0x80004001 ; E_NOTIMPL
}

_AS_GUIDToString(pGUID)
{
    VarSetCapacity(String, 38*2)
    DllCall("ole32\StringFromGUID2", "ptr", pGUID, "str", String, "int", 39)
    return String
}

}

sleep 3000

}

}

return 
GuiEscape:
ExitApp


EncodeInteger( p_value, p_size, p_address, p_offset )
{
	loop, %p_size%
		DllCall( "RtlFillMemory"
			, "uint", p_address+p_offset+A_Index-1
			, "uint", 1
			, "uchar", ( p_value >> ( 8*( A_Index-1 ) ) ) & 0xFF )
}

http://s018.radikal.ru/i522/1607/1b/d6f3cad8ca6f.png

Post's attachments

margin.rar 24.76 kb, 5 downloads since 2016-07-09 

You don't have the permssions to download the attachments of this post.

11 (изменено: stealzy, 2016-07-09 18:02:43)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Здорово, кстати, как называется эта программа (margin hsi.exe), изменяющая размер десктопа для окон?
Наверняка есть какой-то раздел в реестре, где можно задать размер десктопа.
Значок какого дополнения у вас в правом нижнем углу?

12

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Наверняка есть какой-то раздел в реестре, где можно задать размер десктопа.

SetWorkArea(0,0,1800,1200)       ; maximized windows not to cover (not on-top, right edge) taskbar

SetWorkArea(left,top,right,bottom) { ; set main monitor work area; windows are not resized!
   VarSetCapacity(area,16)
   NumPut(left,  area, 0) ; left
   NumPut(top,   area, 4) ; top
   NumPut(right, area, 8) ; right
   NumPut(bottom,area,12) ; bottom
   DllCall("SystemParametersInfo", UInt,0x2F, UInt,0, UInt,&area, UInt,0) ; SPI_SETWORKAREA
}

13

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Добрый день!
Раньше пользовался гаджетом.

Post's attachments

utorrent_ru.gadget 174.84 kb, 3 downloads since 2016-07-09 

You don't have the permssions to download the attachments of this post.

14 (изменено: OmTatSat, 2016-07-09 20:10:24)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

red2881, здравствуйте, спасибо за вариант, если бы увидел гаджет до того как просидел над ahk вариантом несколько дней, то наверное пользовался бы им, а так, как по мне, прогресс бар удобней.

15

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

stealzy пишет:

как называется эта программа (margin hsi.exe), изменяющая размер десктопа для окон?

Называется Hawkeye ShellInit.

stealzy пишет:

Значок какого дополнения у вас в правом нижнем углу?

Adguard - лучший резак рекламы в интернете.

16 (изменено: OmTatSat, 2016-07-09 20:25:03)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Malcev пишет:

Наверняка есть какой-то раздел в реестре, где можно задать размер десктопа.

SetWorkArea(0,0,1800,1200)       ; maximized windows not to cover (not on-top, right edge) taskbar

SetWorkArea(left,top,right,bottom) { ; set main monitor work area; windows are not resized!
   VarSetCapacity(area,16)
   NumPut(left,  area, 0) ; left
   NumPut(top,   area, 4) ; top
   NumPut(right, area, 8) ; right
   NumPut(bottom,area,12) ; bottom
   DllCall("SystemParametersInfo", UInt,0x2F, UInt,0, UInt,&area, UInt,0) ; SPI_SETWORKAREA
}

Сюда вводить свои значения? (0,0,1800,1200)
Ввёл SetWorkArea(100,100,100,1000) - ничего не меняется.

До Hawkeye ShellInit, пробовал вариант https://autohotkey.com/board/topic/6284-taskbar-like-gui-style-where-nothing-can-occupy-its-space/ так отступ делался, но потом через некоторое время пропадал, отловить что ему мешало не смог, по сему hsi нашелся, с ним всё отлично + проги автоматом меняют размер окон после его запуска, а при использовании SPI_SETWORKAREA приходилось минимизировать потом максимизировать.

17

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Может это поможет?
https://autohotkey.com/board/topic/2063 … ntry531261

18

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Malcev, не понял, что там? Запустил тот скрипт, сверху экрана появился тулбар, но окна он не сдвинул, чем именно он может помочь?

19

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Наверное у вас AHK 64 бит.
Так как на AHK 32 бит всё сдвигается.

20

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Malcev, вы правы, скомпилировал через ansi 32, и отступ появился.
Посмотрел код, и понял что с моим микро пониманием ahk туда нечего лезть)) - найти пару строк которые можно вынуть и использовать в прогресс баре не нашел. Вообще меня устраивает вариант с hsi.exe, конечно хотелось бы обойтись без использования доп софта, но это не на столько критично, чтобы тратить день на разбирательства и переделку, и то не факт что даже за день разберусь с тем кодом...

А вот добавить действия по клику на прогресс бар - это более привлекательное время вложение)

Можно ли нажать кнопку "поток" "пуск" "просмотр" - в разных версиях по разному, суть - просмотр во время скачки, без открытия интерфейса utorrent, и прикрутить такое к клику по прогресс бару?

21

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Не понимаю, что вы хотите.
Если просто посмотреть скачиваемый видеофайл, то вы можете же получить его путь и открыть его в любом видеоплеере.

22 (изменено: OmTatSat, 2016-07-10 13:38:24)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Как получить путь?
Но я говорил чуть о другом, есть функция такая в уторренте, нажимаешь "поток" "пуск" "просмотр" - в разных версиях по разному, и начинается просмотр через плеер но не просто открытие файла, а через прокси торента, разница в том, что при таком открытии работает перемотка, а если просто открыть недокачанный файл, то можно смотреть только то, что уже скачано.

http://s31.radikal.ru/tempfiles/dd27bc4424474c5d9dacca5a92ada7e4/-929206895.png

23

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Вряд ли можно запускать через апи интегрированный видеоплеер.
Попробуйте VLC - думаю, он должен перематывать.

Как получить путь?

obj := JS.eval("(" . JsonString . ")").torrents
Loop % obj.length
{
   folder := obj[A_Index - 1][26]
   hash := obj[A_Index - 1][0]
   action := "?action=getfiles&hash=" hash 
   HTTP.Open("GET", url action token, false)
   HTTP.SetCredentials(user, pass, 0)
   HTTP.Send()
   JsonString := HTTP.ResponseText
   file := JS.eval("(" . JsonString . ")").files
   loop % file[1].length
      msgbox % folder "\" file[1][A_Index-1][0]
}

24 (изменено: OmTatSat, 2016-07-10 17:16:07)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Malcev пишет:

Вряд ли можно запускать через апи интегрированный видеоплеер.

Плеер не интегрированный - PotPlayer, а вот функция прокси это с торрента, её бы научится запускать без интерфейса.

Malcev пишет:

Попробуйте VLC - думаю, он должен перематывать.

К сожалению Vlc в этом плане не поможет


хотя у меня есть в коде

HTTP.Open("GET", tokenUrl, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()

Но если ваш код добавить без

HTTP.Open("GET", url action token, false)
   HTTP.SetCredentials(user, pass, 0)
   HTTP.Send()

То пишет

Error:  0x80020006 - Неизвестное имя.

Specifically: files

Line#
079: {
082: folder := obj[A_Index - 1][26]
083: hash := obj[A_Index - 1][0]
084: action := "?action=getfiles&hash=" hash
086: HTTP.SetCredentials(user, pass, 0) 
087: HTTP.Send() 
088: JsonString := HTTP.ResponseText
---> 089: file := JS.eval("(" . JsonString . ")").files
090: Loop,file[1].length
092: p := obj[A_Index - 1][4]/10
093: n := obj[A_Index - 1][2]
094: s := obj[A_Index - 1][9]/1000000
095: t := obj[A_Index - 1][10]/60
096: path := folder "\" file[1][A_Index-1][0]
098: var1 := RegExMatch(p, "(.*)\.", match)

Continue running the script?

25

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Вы не все значит добавили.
Надо так:

ip := "192.168.0.150"
port := "8080"
user := "log"
pass := "pass"

url := "http://" ip ":" port "/gui/"
tokenUrl := url "token.html"
action := "?list=1"
HTTP := ComObjCreate("WinHTTP.WinHTTPRequest.5.1")
HTTP.Open("GET", tokenUrl, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
token := "&token=" RegExReplace(HTTP.ResponseText, "<.+?>")
HTTP.Open("GET", url action token, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
JsonString := HTTP.ResponseText

JS := new ActiveScript("JScript")
JS.eval("delete ActiveXObject; delete GetObject;") 

obj := JS.eval("(" . JsonString . ")").torrents
SetFormat,Float,0.1
Loop % obj.length
{
   folder := obj[A_Index - 1][26]
   hash := obj[A_Index - 1][0]
   action := "?action=getfiles&hash=" hash 
   HTTP.Open("GET", url action token, false)
   HTTP.SetCredentials(user, pass, 0)
   HTTP.Send()
   JsonString := HTTP.ResponseText
   file := JS.eval("(" . JsonString . ")").files
   loop % file[1].length
      msgbox % folder "\" file[1][A_Index-1][0]
}

26

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

В общем эта кнопка "пуск" имеет даже classnn вот только он один для всех закачек. Как бы нажать эту кнопку именно на против нужного файла...?

27 (изменено: OmTatSat, 2016-07-10 17:38:12)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Malcev, понял, значит дублировать - норма, тогда хорошо)
Есть мысль как скрипт поведёт себя с русскими названиями.
А использовать JsonString := StrGet(pText, cBytes, "utf-8")  в вашем коде не получается, работает  только    JsonString := HTTP.ResponseText

28

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Зайдите на вебсервер через IE и посмотрите, что отправляется при нажатии Play.
После этого можно будет отправить такой же запрос.

29

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Malcev пишет:

Зайдите на вебсервер через IE и посмотрите, что отправляется при нажатии Play.
После этого можно будет отправить такой же запрос.

Тоже думал об этом, но почему-то в webui не увидел кнопки play, у вас она есть?

30 (изменено: OmTatSat, 2016-07-10 17:48:19)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

OmTatSat пишет:

Есть мысль как скрипт поведёт себя с русскими названиями.

http://kinosvit.tv/katalog-torrent-films/2256-holodnaya-voyna-cold-war-2012.html файл 1.66gb имеет русские символы в названии.

Опасения подтвердились, заместо русских букв знаки вопросов.

Как задействовать в вашем коде JsonString := StrGet(pText, cBytes, "utf-8") ?

31

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

А использовать JsonString := StrGet(pText, cBytes, "utf-8")  в вашем коде не получается, работает  только    JsonString := HTTP.ResponseText

У меня работает:

ip := "192.168.0.150"
port := "8080"
user := "user"
pass := "pass"

url := "http://" ip ":" port "/gui/"
tokenUrl := url "token.html"
action := "?list=1"
HTTP := ComObjCreate("WinHTTP.WinHTTPRequest.5.1")
HTTP.Open("GET", tokenUrl, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
token := "&token=" RegExReplace(HTTP.ResponseText, "<.+?>")
HTTP.Open("GET", url action token, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
Body := HTTP.ResponseBody
pArr := ComObjValue(Body)
cBytes := NumGet(pArr+0, A_PtrSize = 8? 24:16, "uint")
pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, "ptr")
JsonString := StrGet(pText, cBytes, "utf-8")

JS := new ActiveScript("JScript")
JS.eval("delete ActiveXObject; delete GetObject;") 

obj := JS.eval("(" . JsonString . ")").torrents
SetFormat,Float,0.1
Loop % obj.length
{
   folder := obj[A_Index - 1][26]
   hash := obj[A_Index - 1][0]
   action := "?action=getfiles&hash=" hash 
   HTTP.Open("GET", url action token, false)
   HTTP.SetCredentials(user, pass, 0)
   HTTP.Send()
   Body := HTTP.ResponseBody
   pArr := ComObjValue(Body)
   cBytes := NumGet(pArr+0, A_PtrSize = 8? 24:16, "uint")
   pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, "ptr")
   JsonString := StrGet(pText, cBytes, "utf-8")
   file := JS.eval("(" . JsonString . ")").files
   loop % file[1].length
      msgbox % folder "\" file[1][A_Index-1][0]
}

Тоже думал об этом, но почему-то в webui не увидел кнопки play, у вас она есть?

https://habrahabr.ru/post/251625/

32 (изменено: OmTatSat, 2016-07-10 18:14:14)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Malcev пишет:

У меня работает:

Ага, так у меня тоже заработало, туплю с тем, что нужно дублировать несколько параметров а не только один.

Malcev пишет:

https://habrahabr.ru/post/251625/

Да, похоже из-за старой версии, у вас на какой работает? Просто последние версии даже антивир не хочет загружать))

33

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

У меня вообще опции стриминга нету. У меня не Pro версия.

34 (изменено: OmTatSat, 2016-07-10 20:00:44)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Malcev пишет:

У меня вообще опции стриминга нету. У меня не Pro версия.

У меня тоже не про. Видимо только в новых версиях на этой функции решили заработать. Нашел в интернете про версию, с кнопкой стрима, не может стримить вообще, пишет, не получилось попробуйте позже или дождитесь окончания загрузки... вернулся на старую проверенную версию. Помнится раньше тоже много версий перепробовал пока нашел ту на которой рабочий стриминг.

Post's attachments

uTorrent.rar 767.58 kb, 11 downloads since 2016-07-10 

You don't have the permssions to download the attachments of this post.

35 (изменено: Malcev, 2016-07-10 21:11:26)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Не хочу я ее ставить, да и мне стримминг никогда не нужен был.
Не понимаю почему вы не можете просто открыть плеером ссылку на нужный вам торрент:
http://wiki.acestream.org/wiki/index.ph … e_HTTP_API

36

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Malcev пишет:

Не хочу я ее ставить, да и мне стримминг никогда не нужен был.
Не понимаю почему вы не можете просто открыть плеером ссылку на нужный вам торрент:
http://wiki.acestream.org/wiki/index.ph … e_HTTP_API

Именно acestream плеер который на базе vlc не хочу, так как кучу рекламы показывает...
А как прикрутить его api к другому плееру не знаю, и есть сомнение что даже в другом плеере будет реклама.

Ладно, походу это не реальная затея) так как я там вообще ничего не смыслю.
А вот с кликом по прогрессбару вроде должно быть просто, но после команды хоткея нужно поставить return, но тогда цикл прерывается и всё перестаёт работать, если оставить хоткей за циклом тогда он тоже не работает, как быть?

37

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Пока выход который вижу - вынести хоткей в другую программу, это единственный выход?

38

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Читайте справке OnMessage.
Там даже пример есть.

39 (изменено: OmTatSat, 2016-07-11 00:39:45)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

path1 := % folder "\" file[1][A_Index-1][0]

WM_LBUTTONDOWN(wParam, lParam)
{
   ; X := lParam & 0xFFFF
   ; Y := lParam >> 16
    ;if A_GuiControl
       Control := "`n(in control " . A_GuiControl . ")"
    ToolTip path1 %path1%
}
ToolTip 2%path1%

При клике по гуи выводится path1 а данных с самой переменной нет, а ToolTip 2%path1% показывает данные переменной. Это глюк? Как победить?

40

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Если сделать так.

WM_LBUTTONDOWN(wParam, lParam, path1)
{
   ; X := lParam & 0xFFFF
   ; Y := lParam >> 16
    ;if A_GuiControl
      ; Control := "`n(in control " . A_GuiControl . ")"
    ToolTip path1 %path1%
}

То в переменной появляется 513

41

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

path1 должен быть глобальным.

Global path1 := folder "\" file[1][A_Index-1][0]

42

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Malcev вот оно что! Спасибо! А то уже голову сломал...

43 (изменено: OmTatSat, 2016-07-11 13:19:34)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Добавил отображение размера торрента, его состояния, возможность запустить файл кликнув ЛКМ по прогрессбару, открыть окно уторрента по ПКМ, остановить/возобновить загрузку всех торентов по СКМ. Отображение текущих времени и даты.

#NoTrayIcon
#SingleInstance, force
SetTitleMatchMode, 2
DetectHiddenWindows, On
Gui, Color, 000000 
Gui, -SysMenu -ToolWindow -Caption -Border +AlwaysOnTop ; (+E0x20 - клик сквозь)
Gui +LastFound                                     
WinSet, Transparent, 200
WinSet, ExStyle, ^0x80,
Gui, Font, s7 q5, Verdana
Gui, Add, Text, x1 y-1 w1660 h12 Center cf2ee11  BackgroundTrans vProg +0x201 , 
Gui, Add, Text, x792 y-1 w1660 h12 Center cf2ee11  BackgroundTrans vtime +0x201 ,
Gui, Add, Progress, w1678 h1 x0 y12 cBlue vMyProgress
runonce = 0

OnMessage(0x201, "WM_LBUTTONDOWN")
onmessage(0x207,"WM_MBUTTONDOWN")
onmessage(0x204,"WM_RBUTTONDOWN")

WM_LBUTTONDOWN()
{
    run,  %path1%
}

WM_MBUTTONDOWN()
{
    WinGet, utid, ID,  / ahk_exe uTorrent.exe
   
    if state = Загрузка
    {
      DllCall( "PostMessage", UInt,utid, UInt,0x111, UInt,62, Int,0 ) ; pouse https://autohotkey.com/board/topic/46880-utorrent-wm-command-wparam-values-for-menu-items/
      GuiControl, , Prog,  Загрузка останавлливается...
    }
if state = Пауза
    {
 DllCall( "PostMessage", UInt,utid, UInt,0x111, UInt,61, Int,0 ) ; resume
 GuiControl, , Prog,  Загрузка востанавлливается... 
   }
}

WM_RBUTTONDOWN()
{
    winactivate, / ahk_exe uTorrent.exe
}

Loop
{
Process, Exist, uTorrent.exe
status = %ErrorLevel% 
if status = 0
{
run, "C:\staff\margin\margin hsi.exe" "C:\staff\margin\destroy margin 0.hss" ; убрать кусок отрезаного от приложений экрана
Process, close, uTorrent_osd.exe
}
ip := "192.168.*.*"
port := "******"
user := "*****"
pass := "*****"
url := "http://" ip ":" port "/gui/"
tokenUrl := url "token.html"
action := "?list=1"
HTTP := ComObjCreate("WinHTTP.WinHTTPRequest.5.1")
HTTP.Open("GET", tokenUrl, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
token := "&token=" RegExReplace(HTTP.ResponseText, "<.+?>")
HTTP.Open("GET", url action token, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
Body := HTTP.ResponseBody
pArr := ComObjValue(Body)
cBytes := NumGet(pArr+0, A_PtrSize = 8? 24:16, "uint")
pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, "ptr")
;MsgBox, % StrGet(pText, cBytes, "utf-8")
;msgbox % HTTP.ResponseText
JsonString := StrGet(pText, cBytes, "utf-8")
JS := new ActiveScript("JScript")
JS.eval("delete ActiveXObject; delete GetObject;") 
obj := JS.eval("(" . JsonString . ")").torrents
SetFormat,Float,0.1
{
Loop % obj.length
{
   ;MsgBox % obj[A_Index - 1][4]/10
   
   folder := obj[A_Index - 1][26]
   hash := obj[A_Index - 1][0]
   action := "?action=getfiles&hash=" hash 
   HTTP.Open("GET", url action token, false)
   HTTP.SetCredentials(user, pass, 0)
   HTTP.Send()
   Body := HTTP.ResponseBody
   pArr := ComObjValue(Body)
   cBytes := NumGet(pArr+0, A_PtrSize = 8? 24:16, "uint")
   pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, "ptr")
   JsonString := StrGet(pText, cBytes, "utf-8")
   file := JS.eval("(" . JsonString . ")").files
   
   global state = % obj[A_Index - 1][21]
   p = % obj[A_Index - 1][4]/10
   n = % obj[A_Index - 1][2]
   s = % obj[A_Index - 1][9]/1000000
   size = % obj[A_Index - 1][3]/1000000
   t = % obj[A_Index - 1][10]/60
   loop % file[1].length
   Global path1 := % folder "\" file[1][A_Index-1][0]



var1 := RegExMatch(p, "(.*)\.", match)
if t contains -
{
var2 := RegExMatch(t, "-(.*)", matchh)
t = 
}

IfNotEqual, match1, 100  
{
    if runonce = 0
    {
    runonce = 1
    run, "C:\staff\margin\margin hsi.exe" "C:\staff\margin\margin bottom 15.hss"
    Gui, Show, x1 y1037, uTorrent_osd
    
}

GuiControl,, MyProgress, %p% ;vPRBAR cFF7200

GuiControl, , Prog,  %n% - %size%мб   скорость %s%мб/с   осталось %matchh1%м   завершено %p%`% %state%  ;%path1%
formattime,date,,dd/MM/yy
GuiControl,, Time, %A_Hour%:%A_Min% %A_DDD% %date% 


sleep, 3000
}


/*
 *  ActiveScript for AutoHotkey v1.1
 *
 *  Provides an interface to Active Scripting languages like VBScript and JScript,
 *  without relying on Microsoft's ScriptControl, which is not available to 64-bit
 *  programs.
 *
 *  License: Use, modify and redistribute without limitation, but at your own risk.
 */
class ActiveScript extends ActiveScript._base
{
    __New(Language)
    {
        if this._script := ComObjCreate(Language, ActiveScript.IID)
            this._scriptParse := ComObjQuery(this._script, ActiveScript.IID_Parse)
        if !this._scriptParse
            throw Exception("Invalid language", -1, Language)
        this._site := new ActiveScriptSite(this)
        this._SetScriptSite(this._site.ptr)
        this._InitNew()
        this._objects := {}
        this.Error := ""
        this._dsp := this._GetScriptDispatch()  ; Must be done last.
        try
            if this.ScriptEngine() = "JScript"
                this.SetJScript58()
    }

    SetJScript58()
    {
        static IID_IActiveScriptProperty := "{4954E0D0-FBC7-11D1-8410-006008C3FBFC}"
        if !prop := ComObjQuery(this._script, IID_IActiveScriptProperty)
            return false
        VarSetCapacity(var, 24, 0), NumPut(2, NumPut(3, var, "short") + 6)
        hr := DllCall(NumGet(NumGet(prop+0)+4*A_PtrSize), "ptr", prop, "uint", 0x4000
            , "ptr", 0, "ptr", &var), ObjRelease(prop)
        return hr >= 0
    }
    
    Eval(Code)
    {
        pvar := NumGet(ComObjValue(arr:=ComObjArray(0xC,1)) + 8+A_PtrSize)
        this._ParseScriptText(Code, 0x20, pvar)  ; SCRIPTTEXT_ISEXPRESSION := 0x20
        return arr[0]
    }
    
    Exec(Code)
    {
        this._ParseScriptText(Code, 0x42, 0)  ; SCRIPTTEXT_ISVISIBLE := 2, SCRIPTTEXT_ISPERSISTENT := 0x40
        this._SetScriptState(2)  ; SCRIPTSTATE_CONNECTED := 2
    }
    
    AddObject(Name, DispObj, AddMembers := false)
    {
        static a, supports_dispatch ; Test for built-in IDispatch support.
            := a := ((a:=ComObjArray(0xC,1))[0]:=[42]) && a[0][1]=42
        if IsObject(DispObj) && !(supports_dispatch || ComObjType(DispObj))
            throw Exception("Adding a non-COM object requires AutoHotkey v1.1.17+", -1)
        this._objects[Name] := DispObj
        this._AddNamedItem(Name, AddMembers ? 8 : 2)  ; SCRIPTITEM_ISVISIBLE := 2, SCRIPTITEM_GLOBALMEMBERS := 8
    }
    
    _GetObjectUnk(Name)
    {
        return !IsObject(dsp := this._objects[Name]) ? dsp  ; Pointer
            : ComObjValue(dsp) ? ComObjValue(dsp)  ; ComObject
            : &dsp  ; AutoHotkey object
    }
    
    class _base
    {
        __Call(Method, Params*)
        {
            if ObjHasKey(this, "_dsp")
                try
                    return (this._dsp)[Method](Params*)
                catch e
                    throw Exception(e.Message, -1, e.Extra)
        }
        
        __Get(Property, Params*)
        {
            if ObjHasKey(this, "_dsp")
                try
                    return (this._dsp)[Property, Params*]
                catch e
                    throw Exception(e.Message, -1, e.Extra)
        }
        
        __Set(Property, Params*)
        {
            if ObjHasKey(this, "_dsp")
            {
                Value := Params.Pop()
                try
                    return (this._dsp)[Property, Params*] := Value
                catch e
                    throw Exception(e.Message, -1, e.Extra)
            }
        }
    }
    
    _SetScriptSite(Site)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+3*A_PtrSize), "ptr", p, "ptr", Site)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::SetScriptSite")
    }
    
    _SetScriptState(State)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+5*A_PtrSize), "ptr", p, "int", State)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::SetScriptState")
    }
    
    _AddNamedItem(Name, Flags)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+8*A_PtrSize), "ptr", p, "wstr", Name, "uint", Flags)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::AddNamedItem")
    }
    
    _GetScriptDispatch()
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+10*A_PtrSize), "ptr", p, "ptr", 0, "ptr*", pdsp)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::GetScriptDispatch")
        return ComObject(9, pdsp, 1)
    }
    
    _InitNew()
    {
        hr := DllCall(NumGet(NumGet((p:=this._scriptParse)+0)+3*A_PtrSize), "ptr", p)
        if (hr < 0)
            this._HRFail(hr, "IActiveScriptParse::InitNew")
    }
    
    _ParseScriptText(Code, Flags, pvarResult)
    {
        VarSetCapacity(excp, 8 * A_PtrSize, 0)
        hr := DllCall(NumGet(NumGet((p:=this._scriptParse)+0)+5*A_PtrSize), "ptr", p
            , "wstr", Code, "ptr", 0, "ptr", 0, "ptr", 0, "uptr", 0, "uint", 1
            , "uint", Flags, "ptr", pvarResult, "ptr", 0)
        if (hr < 0)
            this._HRFail(hr, "IActiveScriptParse::ParseScriptText")
    }
    
    _HRFail(hr, what)
    {
        if e := this.Error
        {
            this.Error := ""
            throw Exception("`nError code:`t" this._HRFormat(e.HRESULT)
                . "`nSource:`t`t" e.Source "`nDescription:`t" e.Description
                . "`nLine:`t`t" e.Line "`nColumn:`t`t" e.Column
                . "`nLine text:`t`t" e.LineText, -3)
        }
        throw Exception(what " failed with code " this._HRFormat(hr), -2)
    }
    
    _HRFormat(hr)
    {
        return Format("0x{1:X}", hr & 0xFFFFFFFF)
    }
    
    _OnScriptError(err) ; IActiveScriptError err
    {
        VarSetCapacity(excp, 8 * A_PtrSize, 0)
        DllCall(NumGet(NumGet(err+0)+3*A_PtrSize), "ptr", err, "ptr", &excp) ; GetExceptionInfo
        DllCall(NumGet(NumGet(err+0)+4*A_PtrSize), "ptr", err, "uint*", srcctx, "uint*", srcline, "int*", srccol) ; GetSourcePosition
        DllCall(NumGet(NumGet(err+0)+5*A_PtrSize), "ptr", err, "ptr*", pbstrcode) ; GetSourceLineText
        code := StrGet(pbstrcode, "UTF-16"), DllCall("OleAut32\SysFreeString", "ptr", pbstrcode)
        if fn := NumGet(excp, 6 * A_PtrSize) ; pfnDeferredFillIn
            DllCall(fn, "ptr", &excp)
        wcode := NumGet(excp, 0, "ushort")
        hr := wcode ? 0x80040200 + wcode : NumGet(excp, 7 * A_PtrSize, "uint")
        this.Error := {HRESULT: hr, Line: srcline, Column: srccol, LineText: code}
        static Infos := "Source,Description,HelpFile"
        Loop Parse, % Infos, `,
            if pbstr := NumGet(excp, A_Index * A_PtrSize)
                this.Error[A_LoopField] := StrGet(pbstr, "UTF-16"), DllCall("OleAut32\SysFreeString", "ptr", pbstr)
        return 0x80004001 ; E_NOTIMPL (let Exec/Eval get a fail result)
    }
    
    __Delete()
    {
        if this._script
        {
            DllCall(NumGet(NumGet((p:=this._script)+0)+7*A_PtrSize), "ptr", p)  ; Close
            ObjRelease(this._script)
        }
        if this._scriptParse
            ObjRelease(this._scriptParse)
    }
    
    static IID := "{BB1A2AE1-A4F9-11cf-8F20-00805F2CD064}"
    static IID_Parse := A_PtrSize=8 ? "{C7EF7658-E1EE-480E-97EA-D52CB4D76D17}" : "{BB1A2AE2-A4F9-11cf-8F20-00805F2CD064}"
}

class ActiveScriptSite
{
    __New(Script)
    {
        ObjSetCapacity(this, "_site", 3 * A_PtrSize)
        NumPut(&Script
        , NumPut(ActiveScriptSite._vftable("_vft_w", "31122", 0x100)
        , NumPut(ActiveScriptSite._vftable("_vft", "31125232211", 0)
            , this.ptr := ObjGetAddress(this, "_site"))))
    }
    
    _vftable(Name, PrmCounts, EIBase)
    {
        if p := ObjGetAddress(this, Name)
            return p
        ObjSetCapacity(this, Name, StrLen(PrmCounts) * A_PtrSize)
        p := ObjGetAddress(this, Name)
        Loop Parse, % PrmCounts
        {
            cb := RegisterCallback("_ActiveScriptSite", "F", A_LoopField, A_Index + EIBase)
            NumPut(cb, p + (A_Index-1) * A_PtrSize)
        }
        return p
    }
}

_ActiveScriptSite(this, a1:=0, a2:=0, a3:=0, a4:=0, a5:=0)
{
    Method := A_EventInfo & 0xFF
    if A_EventInfo >= 0x100  ; IActiveScriptSiteWindow
    {
        if Method = 4  ; GetWindow
        {
            NumPut(0, a1+0) ; *phwnd := 0
            return 0 ; S_OK
        }
        if Method = 5  ; EnableModeless
        {
            return 0 ; S_OK
        }
        this -= A_PtrSize     ; Cast to IActiveScriptSite
    }
    ;else: IActiveScriptSite
    if Method = 1  ; QueryInterface
    {
        iid := _AS_GUIDToString(a1)
        if (iid = "{00000000-0000-0000-C000-000000000046}"  ; IUnknown
         || iid = "{DB01A1E3-A42B-11cf-8F20-00805F2CD064}") ; IActiveScriptSite
        {
            NumPut(this, a2+0)
            return 0 ; S_OK
        }
        if (iid = "{D10F6761-83E9-11cf-8F20-00805F2CD064}") ; IActiveScriptSiteWindow
        {
            NumPut(this + A_PtrSize, a2+0)
            return 0 ; S_OK
        }
        NumPut(0, a2+0)
        return 0x80004002 ; E_NOINTERFACE
    }
    if Method = 5  ; GetItemInfo
    {
        a1 := StrGet(a1, "UTF-16")
        , (a3 && NumPut(0, a3+0))  ; *ppiunkItem := NULL
        , (a4 && NumPut(0, a4+0))  ; *ppti := NULL
        if (a2 & 1) ; SCRIPTINFO_IUNKNOWN
        {
            if !(unk := Object(NumGet(this + A_PtrSize*2))._GetObjectUnk(a1))
                return 0x8002802B ; TYPE_E_ELEMENTNOTFOUND
            ObjAddRef(unk), NumPut(unk, a3+0)
        }
        return 0 ; S_OK
    }
    if Method = 9  ; OnScriptError
        return Object(NumGet(this + A_PtrSize*2))._OnScriptError(a1)
    
    ; AddRef and Release don't do anything because we want to avoid circular references.
    ; The site and IActiveScript are both released when the AHK script releases its last
    ; reference to the ActiveScript object.
    
    ; All of the other methods don't require implementations.
    return 0x80004001 ; E_NOTIMPL
}

_AS_GUIDToString(pGUID)
{
    VarSetCapacity(String, 38*2)
    DllCall("ole32\StringFromGUID2", "ptr", pGUID, "str", String, "int", 39)
    return String
}

}

sleep 3000

}

}

return 
GuiEscape:
ExitApp


EncodeInteger( p_value, p_size, p_address, p_offset )
{
	loop, %p_size%
		DllCall( "RtlFillMemory"
			, "uint", p_address+p_offset+A_Index-1
			, "uint", 1
			, "uchar", ( p_value >> ( 8*( A_Index-1 ) ) ) & 0xFF )
}


http://s37.radikal.ru/tempfiles/fece5fe8e17f4547ae7da7c2baf8ed95/-929206895.png

44

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Вот так у меня проигрывает все файлы в торрентах с помощью vlc.
Точно также думаю можно скормить ссылку и потплееру.

ip := "127.0.0.1"
port := "8080"
user := "log"
pass := "pass"
vlc := "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe"

urlVlc := "http://" ip ":" port "/proxy"
url := "http://" ip ":" port "/gui/"
tokenUrl := url "token.html"
action := "?list=1"
HTTP := ComObjCreate("WinHTTP.WinHTTPRequest.5.1")
HTTP.Open("GET", tokenUrl, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
token := "&token=" RegExReplace(HTTP.ResponseText, "<.+?>")
HTTP.Open("GET", url action token, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
Body := HTTP.ResponseBody
pArr := ComObjValue(Body)
cBytes := NumGet(pArr+0, A_PtrSize = 8? 24:16, "uint")
pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, "ptr")
JsonString := StrGet(pText, cBytes, "utf-8")

JS := new ActiveScript("JScript")
JS.eval("delete ActiveXObject; delete GetObject;") 

obj := JS.eval("(" . JsonString . ")").torrents
Loop % obj.length
{
   sid := obj[A_Index - 1][22]
   hash := obj[A_Index - 1][0]
   action := "?action=getfiles&hash=" hash 
   HTTP.Open("GET", url action token, false)
   HTTP.SetCredentials(user, pass, 0)
   HTTP.Send()
   Body := HTTP.ResponseBody
   pArr := ComObjValue(Body)
   cBytes := NumGet(pArr+0, A_PtrSize = 8? 24:16, "uint")
   pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, "ptr")
   JsonString := StrGet(pText, cBytes, "utf-8")
   file := JS.eval("(" . JsonString . ")").files
   loop % file[1].length
   {
      Run, % vlc " " urlVlc "?sid=" sid "&file=" A_Index-1
      Msgbox play
   }
}

45 (изменено: OmTatSat, 2016-07-12 00:29:59)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Malcev, КРУТЬ!!! Спасибо! Я уже и смирился с невозможностью такого фокуса!) А тут на тебе, такой подарок!

Так Run, % vlc " " urlVlc "?sid=" sid "&file=" A_Index-1 работает только на первом торренте.

Вот так Run, % vlc " " urlVlc "?sid=" sid "&file=0"  работает на всех торрентах.

Странно, но правда. На первом варианте на след торрентах выбивало ошибку, потом попробовал открыть их через кнопку "пуск", и увидел что у них всех file=0

Теперь понял, file=1 у второго файла с раздачи, типа если сериал качаешь, то вторая серия будет file=1, прикрутить бы выбор файла к гуи...

46

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Добавляю чтобы по двойному клику открывался прокси файл

WM_LBUTTONDOWN()
{
	global Count_Presses += 1
	SetTimer, Timer_Presses, 3000
	return
	Timer_Presses:
SetTimer, Timer_Presses, off
;ToolTip, %Count_Presses%
If Count_Presses = 2
{
Run, % vlc " " urlVlc "?sid=" sid "&file=0" 
Count_Presses = 0
}
If Count_Presses = 1
	{
 run,  %path1%
 Count_Presses = 0
}

   return
	
}

Но почему-то срабатывает только по тройному клику, может есть мысли почему так?

47 (изменено: OmTatSat, 2016-07-12 01:12:46)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Нашелся другой вариант

Gui +LastFound
hWnd:=WinExist()
DllCall("SetClassLong","UInt",hWnd,"Int",-26,"UInt",0x8)

OnMessage(0x203,"WM_LBUTTONDBLCLK")
WM_LBUTTONDBLCLK()
{	
	Run, % vlc " " urlVlc "?sid=" sid "&file=0"
}

48 (изменено: OmTatSat, 2016-07-12 09:15:03)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Правда есть проблема, одиночное нажатие тоже срабатывает(
Может сможете помочь с воплощением этого решения?
http://rsdn.ru/forum/mfc/945108.all не могу понять как реализовать его.

49

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Можно так:

Gui, Add, Text,, Click anywhere in this window.
Gui, Add, Edit, w200 vMyEdit
Gui, Show
OnMessage(0x201, "WM_LBUTTONDOWN")
OnMessage(0x203,"WM_LBUTTONDBLCLK")
return

WM_LBUTTONDOWN(wParam, lParam)
{
   Global click := 1
   SetTimer, check, -250
   return

   check:
   if click = 1
      msgbox 1
   else
      msgbox 2
   return
}

WM_LBUTTONDBLCLK(wParam, lParam)
{
   Global click := 2
   return
}

GuiClose:
ExitApp

прикрутить бы выбор файла к гуи...

А в чём проблема? Прикручивайте:
https://autohotkey.com/docs/commands/Menu.htm
PS Ссылки следует оформлять тегом url.

50 (изменено: OmTatSat, 2016-07-12 09:19:01)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Malcev, спасибо! Самая главная проблема которая не даёт даже начать пробовать в том что в MsgBox, % StrGet(pText, cBytes, "utf-8") нет списка файлов которые скачиваются, где его взять?

51

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Разве что так. Но тогда не буду уверен в соответствии порядка представления файлов этого списка и списка в торренте.

list_files(Directory)
{
	files =
	Loop %Directory%\*.*
	{
		files = %files%`n%A_LoopFileName%
	}
	return files
}

52 (изменено: OmTatSat, 2016-07-12 12:21:41)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Нашелся довольно подходящий пример

WM_LBUTTONDBLCLK()
{	
	Global click := 2
   	;Run, % vlc " " urlVlc "?sid=" sid "&file=0"
	;return
fold = %folder%\
Gui,2:default
; Create the ListView with two columns, Name and Size:
Gui, 2:Add, ListView, r20 w700 gMyListView, Name|Size (KB)

; Gather a list of file names from a folder and put them into the ListView:
;ToolTip, %folder%\*.* %A_MyDocuments%\*.*

Loop, %folder%\*.*
    LV_Add("", A_LoopFileName, A_LoopFileSizeKB)

LV_ModifyCol()  ; Auto-size each column to fit its contents.
LV_ModifyCol(2, "Integer")  ; For sorting purposes, indicate that column 2 is an integer.

; Display the window and return. The script will be notified whenever the user double clicks a row.
Gui, 2:Show, x1 y537, choose
return

MyListView:
;KeyWait, LButton, D
if A_GuiEvent = DoubleClick
{
    LV_GetText(RowText, A_EventInfo)  ; Get the text from the row's first field.
	b =  %A_EventInfo%
	Run, % vlc " " urlVlc "?sid=" sid "&file=" A_EventInfo-1
    ToolTip You double-clicked row number %A_EventInfo%. Text: "%RowText%" %b%
	GuiClose:
	Gui, 2:Destroy
}
return


	

}

То в окне уже пусто, что не так?
Нашлось, не хватало Gui,2:default

53

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Проблема в том, что по вызову доп гуи, скрипт продолжает работать и данные "?sid=" sid "&file=" могут взяться с другого торрента, как остановить скрипт пока не сделан выбор?

54

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Gui, Add, Text,, Click anywhere in this window.
Gui, Add, Edit, w200 vMyEdit
Gui, Show
OnMessage(0x201, "WM_LBUTTONDOWN")
OnMessage(0x203,"WM_LBUTTONDBLCLK")
loop
{
   ToolTip, % A_Index, 500,500
   Sleep 2000
   While (a = 1)
      Sleep 100
}
return

WM_LBUTTONDOWN(wParam, lParam)
{
   Global click := 1
   SetTimer, check, -250
   return

   check:
   if click = 1
      Global a := 0
   else
      Global a := 1
   return
}

WM_LBUTTONDBLCLK(wParam, lParam)
{
   Global click := 2
   return
}

GuiClose:
ExitApp

55

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Malcev, спасибо!
Сложный кусок оказался, еле дошло куда добро указанное вами распихать, чтобы всё заработало)

WM_LBUTTONDBLCLK()
{	
	Global click := 2
   ;ToolTip, % vlc " " urlVlc "?sid=" sid "&file=0"
	;return
	 
fold = %folder%\
Gui,2:default
; Create the ListView with two columns, Name and Size:
Gui, 2:Add, ListView, r20 w700 gMyListView, Name|Size (KB)

; Gather a list of file names from a folder and put them into the ListView:
;ToolTip, %folder%\*.* %A_MyDocuments%\*.*

Loop, %folder%\*.*
    LV_Add("", A_LoopFileName, A_LoopFileSizeKB)

LV_ModifyCol()  ; Auto-size each column to fit its contents.
LV_ModifyCol(2, "Integer")  ; For sorting purposes, indicate that column 2 is an integer.
; Display the window and return. The script will be notified whenever the user double clicks a row.
Gui, 2:Show, x1 y537, choose
global dblclk = 1

MyListView:
;KeyWait, LButton, D
;While !(GetKeyState("LButton","P"))
Loop
{
    ToolTip, while a=%a%
    sleep, 200
    
        
	
if A_GuiEvent = DoubleClick
{
	
	Run, % vlc " " urlVlc "?sid=" sid "&file=" A_EventInfo-1
    ;ToolTip You double-clicked row number %A_EventInfo%. Text: "%RowText%" %b%
	Global a := 1
    ToolTip,  a=%a%
	GuiClose:
	Gui, 2:Destroy
	break
}
While (a = 1)
    return

}
return
}

Почему в этом коде может не работать if A_GuiEvent = Normal ? Хотелось бы с одного клика выбор делать, думаю - удобней. С двойным кликом хорошо работает.

56

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

У меня ваш код не запускается.
Но для того, чтобы отлавливать событие одиночного клика нужно указать AltSubmit в опциях.

; Create the ListView with two columns, Name and Size:
Gui, Add, ListView, r20 w700 AltSubMit gMyListView, Name|Size (KB)

; Gather a list of file names from a folder and put them into the ListView:
Loop, %A_MyDocuments%\*.*
    LV_Add("", A_LoopFileName, A_LoopFileSizeKB)

LV_ModifyCol()  ; Auto-size each column to fit its contents.
LV_ModifyCol(2, "Integer")  ; For sorting purposes, indicate that column 2 is an integer.

; Display the window and return. The script will be notified whenever the user double clicks a row.
Gui, Show
return

MyListView:
if A_GuiEvent = Normal
{
    LV_GetText(RowText, A_EventInfo)  ; Get the text from the row's first field.
    ToolTip You double-clicked row number %A_EventInfo%. Text: "%RowText%"
}
return

GuiClose:  ; Indicate that the script should exit automatically when the window is closed.
ExitApp

57 (изменено: OmTatSat, 2016-07-14 11:54:47)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

А если весь код, работает?

Пробовал добавить в опции AltSubmit, перестает работать даблклик а нормал не начинает(( Есть ещё варианты?

#NoTrayIcon
#SingleInstance, force
SetTitleMatchMode, 2
DetectHiddenWindows, On
Gui, Color, 000000 
Gui, -SysMenu -ToolWindow -Caption -Border +AlwaysOnTop ; (+E0x20 - клик сквозь)
Gui +LastFound 
hWnd:=WinExist()
DllCall("SetClassLong","UInt",hWnd,"Int",-26,"UInt",0x8)
WinSet, Transparent, 200
WinSet, ExStyle, ^0x80,
Gui, Font, s7 q5, Verdana
Gui, 1:Add, Text, x1 y-1 w1660 h12 Center cf2ee11  BackgroundTrans vProg +0x201 , 
Gui, Add, Text, x792 y-1 w1660 h12 Center cf2ee11  BackgroundTrans vtime +0x201 ,
Gui, Add, Progress, w1678 h1 x0 y12 cBlue vMyProgress
runonce = 0
global dblclk = 0
Global a := 0


OnMessage(0x201, "WM_LBUTTONDOWN")
OnMessage(0x203,"WM_LBUTTONDBLCLK")
onmessage(0x207,"WM_MBUTTONDOWN")
onmessage(0x204,"WM_RBUTTONDOWN")
OnMessage(0x100, "WM_KEYDOWN")



WM_LBUTTONDBLCLK()
{	
	Global click := 2
   ;ToolTip, % vlc " " urlVlc "?sid=" sid "&file=0"
	;return
	global dblclk = 1 
fold = %folder%\
Gui,2:default
; Create the ListView with two columns, Name and Size:
Gui, 2:Add, ListView, r20 w700 gMyListView, Name|Size (KB)

; Gather a list of file names from a folder and put them into the ListView:
;ToolTip, %folder%\*.* %A_MyDocuments%\*.*

Loop, %folder%\*.*
    LV_Add("", A_LoopFileName, A_LoopFileSizeKB)

LV_ModifyCol()  ; Auto-size each column to fit its contents.
LV_ModifyCol(2, "Integer")  ; For sorting purposes, indicate that column 2 is an integer.
; Display the window and return. The script will be notified whenever the user double clicks a row.
Gui, 2:Show, x1 y537, choose


MyListView:
;KeyWait, LButton, D
;While !(GetKeyState("LButton","P"))
Loop
{
    ToolTip, while a=%a% `n dblclkmylistview = %dblclk%
    sleep 200
    
    
        
	
if A_GuiEvent = DoubleClick
{
	
	Run, % vlc " " urlVlc "?sid=" sid "&file=" A_EventInfo-1
    ;ToolTip You double-clicked row number %A_EventInfo%. Text: "%RowText%" %b%
	Global a := 1
    ToolTip,  a=%a%
	GuiClose:
	Gui, 2:Destroy
	break
}
While (a = 1)
    return

}
return
}

WM_LBUTTONDOWN()
{
	 Global click := 1
   SetTimer, check, -950
   return

   check:
   ToolTip, dblclkcheck = %dblclk%
   if ((click = 1) & (dblclk = 0))

    run %path1%	
   

      return
	
}






WM_MBUTTONDOWN()
{
    WinGet, utid, ID,  / ahk_exe uTorrent.exe
   
    if state = Загрузка
    {
      DllCall( "PostMessage", UInt,utid, UInt,0x111, UInt,62, Int,0 ) ; pouse https://autohotkey.com/board/topic/46880-utorrent-wm-command-wparam-values-for-menu-items/
      GuiControl, , Prog,  Загрузка останавлливается...
    }
if state = Пауза
    {
 DllCall( "PostMessage", UInt,utid, UInt,0x111, UInt,61, Int,0 ) ; resume
 GuiControl, , Prog,  Загрузка востанавлливается... 
   }
}

WM_RBUTTONDOWN()
{
    winactivate, / ahk_exe uTorrent.exe
	}


Loop
{
Process, Exist, uTorrent.exe
status = %ErrorLevel% 
if status = 0
{
run, "C:\staff\margin\margin hsi.exe" "C:\staff\margin\destroy margin 0.hss" ; убрать кусок отрезаного от приложений экрана
Process, close, uTorrent_osd.exe
}
ip := "127.0.0.1"
port := "8080"
user := "admin"
pass := "pass"
url := "http://" ip ":" port "/gui/"
global vlc := "C:\Program Files\DAUM\PotPlayer\PotPlayerMini64.exe"
global urlVlc := "http://" ip ":" port "/proxy"
tokenUrl := url "token.html"
action := "?list=1"
HTTP := ComObjCreate("WinHTTP.WinHTTPRequest.5.1")
HTTP.Open("GET", tokenUrl, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
token := "&token=" RegExReplace(HTTP.ResponseText, "<.+?>")
HTTP.Open("GET", url action token, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
Body := HTTP.ResponseBody
pArr := ComObjValue(Body)
cBytes := NumGet(pArr+0, A_PtrSize = 8? 24:16, "uint")
pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, "ptr")
;MsgBox, % StrGet(pText, cBytes, "utf-8") 
;msgbox % HTTP.ResponseText
JsonString := StrGet(pText, cBytes, "utf-8")
JS := new ActiveScript("JScript")
JS.eval("delete ActiveXObject; delete GetObject;") 
obj := JS.eval("(" . JsonString . ")").torrents
SetFormat,Float,0.1
{
Loop % obj.length
{
   ;MsgBox % obj[A_Index - 1][4]/10
   global sid := obj[A_Index - 1][22]
   global folder := obj[A_Index - 1][26]
   hash := obj[A_Index - 1][0]
   action := "?action=getfiles&hash=" hash 
   HTTP.Open("GET", url action token, false)
   HTTP.SetCredentials(user, pass, 0)
   HTTP.Send()
   Body := HTTP.ResponseBody
   pArr := ComObjValue(Body)
   cBytes := NumGet(pArr+0, A_PtrSize = 8? 24:16, "uint")
   pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, "ptr")
   JsonString := StrGet(pText, cBytes, "utf-8")
   file := JS.eval("(" . JsonString . ")").files
   
   global state = % obj[A_Index - 1][21]
   p = % obj[A_Index - 1][4]/10
   n = % obj[A_Index - 1][2]
   s = % obj[A_Index - 1][9]/1000000
   size = % obj[A_Index - 1][3]/1000000
   t = % obj[A_Index - 1][10]/60
   loop % file[1].length
   Global path1 := % folder "\" file[1][A_Index-1][0]
   
;Run, % vlc " " urlVlc "?sid=" sid "&file=0" ; A_Index-1
     ; Msgbox play %urlVlc%


var1 := RegExMatch(p, "(.*)\.", match)
if t contains -
{
var2 := RegExMatch(t, "-(.*)", matchh)
t = 
}

IfNotEqual, match1, 100  
{
    if runonce = 0
    {
    runonce = 1
    run, "C:\staff\margin\margin hsi.exe" "C:\staff\margin\margin bottom 15.hss"
    Gui, 1:Show, x1 y1037, uTorrent_osd
    
}

GuiControl,, MyProgress, %p% ;vPRBAR cFF7200

GuiControl, , Prog,  %n% - %size%мб   скорость %s%мб/с   осталось %matchh1%м   завершено %p%`% %state%  ;%path1%
formattime,date,,dd/MM/yy
GuiControl,, Time, %A_Hour%:%A_Min% %A_DDD% %date% 


sleep, 3000
}


/*
 *  ActiveScript for AutoHotkey v1.1
 *
 *  Provides an interface to Active Scripting languages like VBScript and JScript,
 *  without relying on Microsoft's ScriptControl, which is not available to 64-bit
 *  programs.
 *
 *  License: Use, modify and redistribute without limitation, but at your own risk.
 */
class ActiveScript extends ActiveScript._base
{
    __New(Language)
    {
        if this._script := ComObjCreate(Language, ActiveScript.IID)
            this._scriptParse := ComObjQuery(this._script, ActiveScript.IID_Parse)
        if !this._scriptParse
            throw Exception("Invalid language", -1, Language)
        this._site := new ActiveScriptSite(this)
        this._SetScriptSite(this._site.ptr)
        this._InitNew()
        this._objects := {}
        this.Error := ""
        this._dsp := this._GetScriptDispatch()  ; Must be done last.
        try
            if this.ScriptEngine() = "JScript"
                this.SetJScript58()
    }

    SetJScript58()
    {
        static IID_IActiveScriptProperty := "{4954E0D0-FBC7-11D1-8410-006008C3FBFC}"
        if !prop := ComObjQuery(this._script, IID_IActiveScriptProperty)
            return false
        VarSetCapacity(var, 24, 0), NumPut(2, NumPut(3, var, "short") + 6)
        hr := DllCall(NumGet(NumGet(prop+0)+4*A_PtrSize), "ptr", prop, "uint", 0x4000
            , "ptr", 0, "ptr", &var), ObjRelease(prop)
        return hr >= 0
    }
    
    Eval(Code)
    {
        pvar := NumGet(ComObjValue(arr:=ComObjArray(0xC,1)) + 8+A_PtrSize)
        this._ParseScriptText(Code, 0x20, pvar)  ; SCRIPTTEXT_ISEXPRESSION := 0x20
        return arr[0]
    }
    
    Exec(Code)
    {
        this._ParseScriptText(Code, 0x42, 0)  ; SCRIPTTEXT_ISVISIBLE := 2, SCRIPTTEXT_ISPERSISTENT := 0x40
        this._SetScriptState(2)  ; SCRIPTSTATE_CONNECTED := 2
    }
    
    AddObject(Name, DispObj, AddMembers := false)
    {
        static a, supports_dispatch ; Test for built-in IDispatch support.
            := a := ((a:=ComObjArray(0xC,1))[0]:=[42]) && a[0][1]=42
        if IsObject(DispObj) && !(supports_dispatch || ComObjType(DispObj))
            throw Exception("Adding a non-COM object requires AutoHotkey v1.1.17+", -1)
        this._objects[Name] := DispObj
        this._AddNamedItem(Name, AddMembers ? 8 : 2)  ; SCRIPTITEM_ISVISIBLE := 2, SCRIPTITEM_GLOBALMEMBERS := 8
    }
    
    _GetObjectUnk(Name)
    {
        return !IsObject(dsp := this._objects[Name]) ? dsp  ; Pointer
            : ComObjValue(dsp) ? ComObjValue(dsp)  ; ComObject
            : &dsp  ; AutoHotkey object
    }
    
    class _base
    {
        __Call(Method, Params*)
        {
            if ObjHasKey(this, "_dsp")
                try
                    return (this._dsp)[Method](Params*)
                catch e
                    throw Exception(e.Message, -1, e.Extra)
        }
        
        __Get(Property, Params*)
        {
            if ObjHasKey(this, "_dsp")
                try
                    return (this._dsp)[Property, Params*]
                catch e
                    throw Exception(e.Message, -1, e.Extra)
        }
        
        __Set(Property, Params*)
        {
            if ObjHasKey(this, "_dsp")
            {
                Value := Params.Pop()
                try
                    return (this._dsp)[Property, Params*] := Value
                catch e
                    throw Exception(e.Message, -1, e.Extra)
            }
        }
    }
    
    _SetScriptSite(Site)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+3*A_PtrSize), "ptr", p, "ptr", Site)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::SetScriptSite")
    }
    
    _SetScriptState(State)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+5*A_PtrSize), "ptr", p, "int", State)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::SetScriptState")
    }
    
    _AddNamedItem(Name, Flags)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+8*A_PtrSize), "ptr", p, "wstr", Name, "uint", Flags)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::AddNamedItem")
    }
    
    _GetScriptDispatch()
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+10*A_PtrSize), "ptr", p, "ptr", 0, "ptr*", pdsp)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::GetScriptDispatch")
        return ComObject(9, pdsp, 1)
    }
    
    _InitNew()
    {
        hr := DllCall(NumGet(NumGet((p:=this._scriptParse)+0)+3*A_PtrSize), "ptr", p)
        if (hr < 0)
            this._HRFail(hr, "IActiveScriptParse::InitNew")
    }
    
    _ParseScriptText(Code, Flags, pvarResult)
    {
        VarSetCapacity(excp, 8 * A_PtrSize, 0)
        hr := DllCall(NumGet(NumGet((p:=this._scriptParse)+0)+5*A_PtrSize), "ptr", p
            , "wstr", Code, "ptr", 0, "ptr", 0, "ptr", 0, "uptr", 0, "uint", 1
            , "uint", Flags, "ptr", pvarResult, "ptr", 0)
        if (hr < 0)
            this._HRFail(hr, "IActiveScriptParse::ParseScriptText")
    }
    
    _HRFail(hr, what)
    {
        if e := this.Error
        {
            this.Error := ""
            throw Exception("`nError code:`t" this._HRFormat(e.HRESULT)
                . "`nSource:`t`t" e.Source "`nDescription:`t" e.Description
                . "`nLine:`t`t" e.Line "`nColumn:`t`t" e.Column
                . "`nLine text:`t`t" e.LineText, -3)
        }
        throw Exception(what " failed with code " this._HRFormat(hr), -2)
    }
    
    _HRFormat(hr)
    {
        return Format("0x{1:X}", hr & 0xFFFFFFFF)
    }
    
    _OnScriptError(err) ; IActiveScriptError err
    {
        VarSetCapacity(excp, 8 * A_PtrSize, 0)
        DllCall(NumGet(NumGet(err+0)+3*A_PtrSize), "ptr", err, "ptr", &excp) ; GetExceptionInfo
        DllCall(NumGet(NumGet(err+0)+4*A_PtrSize), "ptr", err, "uint*", srcctx, "uint*", srcline, "int*", srccol) ; GetSourcePosition
        DllCall(NumGet(NumGet(err+0)+5*A_PtrSize), "ptr", err, "ptr*", pbstrcode) ; GetSourceLineText
        code := StrGet(pbstrcode, "UTF-16"), DllCall("OleAut32\SysFreeString", "ptr", pbstrcode)
        if fn := NumGet(excp, 6 * A_PtrSize) ; pfnDeferredFillIn
            DllCall(fn, "ptr", &excp)
        wcode := NumGet(excp, 0, "ushort")
        hr := wcode ? 0x80040200 + wcode : NumGet(excp, 7 * A_PtrSize, "uint")
        this.Error := {HRESULT: hr, Line: srcline, Column: srccol, LineText: code}
        static Infos := "Source,Description,HelpFile"
        Loop Parse, % Infos, `,
            if pbstr := NumGet(excp, A_Index * A_PtrSize)
                this.Error[A_LoopField] := StrGet(pbstr, "UTF-16"), DllCall("OleAut32\SysFreeString", "ptr", pbstr)
        return 0x80004001 ; E_NOTIMPL (let Exec/Eval get a fail result)
    }
    
    __Delete()
    {
        if this._script
        {
            DllCall(NumGet(NumGet((p:=this._script)+0)+7*A_PtrSize), "ptr", p)  ; Close
            ObjRelease(this._script)
        }
        if this._scriptParse
            ObjRelease(this._scriptParse)
    }
    
    static IID := "{BB1A2AE1-A4F9-11cf-8F20-00805F2CD064}"
    static IID_Parse := A_PtrSize=8 ? "{C7EF7658-E1EE-480E-97EA-D52CB4D76D17}" : "{BB1A2AE2-A4F9-11cf-8F20-00805F2CD064}"
}

class ActiveScriptSite
{
    __New(Script)
    {
        ObjSetCapacity(this, "_site", 3 * A_PtrSize)
        NumPut(&Script
        , NumPut(ActiveScriptSite._vftable("_vft_w", "31122", 0x100)
        , NumPut(ActiveScriptSite._vftable("_vft", "31125232211", 0)
            , this.ptr := ObjGetAddress(this, "_site"))))
    }
    
    _vftable(Name, PrmCounts, EIBase)
    {
        if p := ObjGetAddress(this, Name)
            return p
        ObjSetCapacity(this, Name, StrLen(PrmCounts) * A_PtrSize)
        p := ObjGetAddress(this, Name)
        Loop Parse, % PrmCounts
        {
            cb := RegisterCallback("_ActiveScriptSite", "F", A_LoopField, A_Index + EIBase)
            NumPut(cb, p + (A_Index-1) * A_PtrSize)
        }
        return p
    }
}

_ActiveScriptSite(this, a1:=0, a2:=0, a3:=0, a4:=0, a5:=0)
{
    Method := A_EventInfo & 0xFF
    if A_EventInfo >= 0x100  ; IActiveScriptSiteWindow
    {
        if Method = 4  ; GetWindow
        {
            NumPut(0, a1+0) ; *phwnd := 0
            return 0 ; S_OK
        }
        if Method = 5  ; EnableModeless
        {
            return 0 ; S_OK
        }
        this -= A_PtrSize     ; Cast to IActiveScriptSite
    }
    ;else: IActiveScriptSite
    if Method = 1  ; QueryInterface
    {
        iid := _AS_GUIDToString(a1)
        if (iid = "{00000000-0000-0000-C000-000000000046}"  ; IUnknown
         || iid = "{DB01A1E3-A42B-11cf-8F20-00805F2CD064}") ; IActiveScriptSite
        {
            NumPut(this, a2+0)
            return 0 ; S_OK
        }
        if (iid = "{D10F6761-83E9-11cf-8F20-00805F2CD064}") ; IActiveScriptSiteWindow
        {
            NumPut(this + A_PtrSize, a2+0)
            return 0 ; S_OK
        }
        NumPut(0, a2+0)
        return 0x80004002 ; E_NOINTERFACE
    }
    if Method = 5  ; GetItemInfo
    {
        a1 := StrGet(a1, "UTF-16")
        , (a3 && NumPut(0, a3+0))  ; *ppiunkItem := NULL
        , (a4 && NumPut(0, a4+0))  ; *ppti := NULL
        if (a2 & 1) ; SCRIPTINFO_IUNKNOWN
        {
            if !(unk := Object(NumGet(this + A_PtrSize*2))._GetObjectUnk(a1))
                return 0x8002802B ; TYPE_E_ELEMENTNOTFOUND
            ObjAddRef(unk), NumPut(unk, a3+0)
        }
        return 0 ; S_OK
    }
    if Method = 9  ; OnScriptError
        return Object(NumGet(this + A_PtrSize*2))._OnScriptError(a1)
    
    ; AddRef and Release don't do anything because we want to avoid circular references.
    ; The site and IActiveScript are both released when the AHK script releases its last
    ; reference to the ActiveScript object.
    
    ; All of the other methods don't require implementations.
    return 0x80004001 ; E_NOTIMPL
}

_AS_GUIDToString(pGUID)
{
    VarSetCapacity(String, 38*2)
    DllCall("ole32\StringFromGUID2", "ptr", pGUID, "str", String, "int", 39)
    return String
}

}

sleep 3000

}

}

return 
GuiEscape:
ExitApp


EncodeInteger( p_value, p_size, p_address, p_offset )
{
	loop, %p_size%
		DllCall( "RtlFillMemory"
			, "uint", p_address+p_offset+A_Index-1
			, "uint", 1
			, "uchar", ( p_value >> ( 8*( A_Index-1 ) ) ) & 0xFF )
}


В таком коде срабатывает действие по одиночному клику

#NoTrayIcon
#SingleInstance, force
SetTitleMatchMode, 2
DetectHiddenWindows, On
Gui, Color, 000000 
Gui, -SysMenu -ToolWindow -Caption -Border +AlwaysOnTop ; (+E0x20 - клик сквозь)
Gui +LastFound 
hWnd:=WinExist()
DllCall("SetClassLong","UInt",hWnd,"Int",-26,"UInt",0x8)
WinSet, Transparent, 200
WinSet, ExStyle, ^0x80,
Gui, Font, s7 q5, Verdana
Gui, 1:Add, Text, x1 y-1 w1660 h12 Center cf2ee11  BackgroundTrans vProg +0x201 , 
Gui, Add, Text, x792 y-1 w1660 h12 Center cf2ee11  BackgroundTrans vtime +0x201 ,
Gui, Add, Progress, w1678 h1 x0 y12 cBlue vMyProgress
runonce = 0
global dblclk = 0
Global a := 0
global rundblclk = 0

OnMessage(0x201, "WM_LBUTTONDOWN")
OnMessage(0x203,"WM_LBUTTONDBLCLK")
onmessage(0x207,"WM_MBUTTONDOWN")
onmessage(0x204,"WM_RBUTTONDOWN")
OnMessage(0x100, "WM_KEYDOWN")



WM_LBUTTONDBLCLK()
{	
	Global click := 2
   ;ToolTip, % vlc " " urlVlc "?sid=" sid "&file=0"
	;return
	global dblclk = 1 
fold = %folder%\
Gui,2:default
; Create the ListView with two columns, Name and Size:
Gui, 2:Add, ListView, r20 w700 AltSubMit gMyListView, Name|Size (KB)

; Gather a list of file names from a folder and put them into the ListView:
;ToolTip, %folder%\*.* %A_MyDocuments%\*.*

Loop, %folder%\*.*
    LV_Add("", A_LoopFileName, A_LoopFileSizeKB)

LV_ModifyCol()  ; Auto-size each column to fit its contents.
LV_ModifyCol(2, "Integer")  ; For sorting purposes, indicate that column 2 is an integer.
; Display the window and return. The script will be notified whenever the user double clicks a row.
Gui, 2:Show, x1 y537, choose


MyListView:
;KeyWait, LButton, D
;While !(GetKeyState("LButton","P"))
Loop
{
    ToolTip, while a=%a% `n dblclkmylistview = %dblclk% `n rundblclk= %rundblclk%
    sleep 200
    
    
     
	
if rundblclk = 1
{
	
	Run, % vlc " " urlVlc "?sid=" sid "&file=" A_EventInfo
    ;ToolTip You double-clicked row number %A_EventInfo%. Text: "%RowText%" %b%
	Global a := 1
    ToolTip,  a=%a%
	GuiClose:
	Gui, 2:Destroy
	break
}
While (a = 1)
    return

}
return
}

WM_LBUTTONDOWN()
{
	 Global click := 1
   SetTimer, check, -950
   return

   check:
   ToolTip, dblclkcheck = %dblclk%
   if ((click = 1) & (dblclk = 0))
    run %path1%	
   if ((click = 1) & (dblclk = 1)) 
global rundblclk = 1
      return
	
}






WM_MBUTTONDOWN()
{
    WinGet, utid, ID,  / ahk_exe uTorrent.exe
   
    if state = Загрузка
    {
      DllCall( "PostMessage", UInt,utid, UInt,0x111, UInt,62, Int,0 ) ; pouse https://autohotkey.com/board/topic/46880-utorrent-wm-command-wparam-values-for-menu-items/
      GuiControl, , Prog,  Загрузка останавлливается...
    }
if state = Пауза
    {
 DllCall( "PostMessage", UInt,utid, UInt,0x111, UInt,61, Int,0 ) ; resume
 GuiControl, , Prog,  Загрузка востанавлливается... 
   }
}

WM_RBUTTONDOWN()
{
    winactivate, / ahk_exe uTorrent.exe
	}


Loop
{
Process, Exist, uTorrent.exe
status = %ErrorLevel% 
if status = 0
{
run, "C:\staff\margin\margin hsi.exe" "C:\staff\margin\destroy margin 0.hss" ; убрать кусок отрезаного от приложений экрана
Process, close, uTorrent_osd.exe
}
ip := "127.0.0.1"
port := "8080"
user := "admin"
pass := "pass"
url := "http://" ip ":" port "/gui/"
global vlc := "C:\Program Files\DAUM\PotPlayer\PotPlayerMini64.exe"
global urlVlc := "http://" ip ":" port "/proxy"
tokenUrl := url "token.html"
action := "?list=1"
HTTP := ComObjCreate("WinHTTP.WinHTTPRequest.5.1")
HTTP.Open("GET", tokenUrl, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
token := "&token=" RegExReplace(HTTP.ResponseText, "<.+?>")
HTTP.Open("GET", url action token, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
Body := HTTP.ResponseBody
pArr := ComObjValue(Body)
cBytes := NumGet(pArr+0, A_PtrSize = 8? 24:16, "uint")
pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, "ptr")
;MsgBox, % StrGet(pText, cBytes, "utf-8") 
;msgbox % HTTP.ResponseText
JsonString := StrGet(pText, cBytes, "utf-8")
JS := new ActiveScript("JScript")
JS.eval("delete ActiveXObject; delete GetObject;") 
obj := JS.eval("(" . JsonString . ")").torrents
SetFormat,Float,0.1
{
Loop % obj.length
{
   ;MsgBox % obj[A_Index - 1][4]/10
   global sid := obj[A_Index - 1][22]
   global folder := obj[A_Index - 1][26]
   hash := obj[A_Index - 1][0]
   action := "?action=getfiles&hash=" hash 
   HTTP.Open("GET", url action token, false)
   HTTP.SetCredentials(user, pass, 0)
   HTTP.Send()
   Body := HTTP.ResponseBody
   pArr := ComObjValue(Body)
   cBytes := NumGet(pArr+0, A_PtrSize = 8? 24:16, "uint")
   pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, "ptr")
   JsonString := StrGet(pText, cBytes, "utf-8")
   file := JS.eval("(" . JsonString . ")").files
   
   global state = % obj[A_Index - 1][21]
   p = % obj[A_Index - 1][4]/10
   n = % obj[A_Index - 1][2]
   s = % obj[A_Index - 1][9]/1000000
   size = % obj[A_Index - 1][3]/1000000
   t = % obj[A_Index - 1][10]/60
   loop % file[1].length
   Global path1 := % folder "\" file[1][A_Index-1][0]
   
;Run, % vlc " " urlVlc "?sid=" sid "&file=0" ; A_Index-1
     ; Msgbox play %urlVlc%


var1 := RegExMatch(p, "(.*)\.", match)
if t contains -
{
var2 := RegExMatch(t, "-(.*)", matchh)
t = 
}

IfNotEqual, match1, 100  
{
    if runonce = 0
    {
    runonce = 1
    run, "C:\staff\margin\margin hsi.exe" "C:\staff\margin\margin bottom 15.hss"
    Gui, 1:Show, x1 y1037, uTorrent_osd
    
}

GuiControl,, MyProgress, %p% ;vPRBAR cFF7200

GuiControl, , Prog,  %n% - %size%мб   скорость %s%мб/с   осталось %matchh1%м   завершено %p%`% %state%  ;%path1%
formattime,date,,dd/MM/yy
GuiControl,, Time, %A_Hour%:%A_Min% %A_DDD% %date% 


sleep, 3000
}


/*
 *  ActiveScript for AutoHotkey v1.1
 *
 *  Provides an interface to Active Scripting languages like VBScript and JScript,
 *  without relying on Microsoft's ScriptControl, which is not available to 64-bit
 *  programs.
 *
 *  License: Use, modify and redistribute without limitation, but at your own risk.
 */
class ActiveScript extends ActiveScript._base
{
    __New(Language)
    {
        if this._script := ComObjCreate(Language, ActiveScript.IID)
            this._scriptParse := ComObjQuery(this._script, ActiveScript.IID_Parse)
        if !this._scriptParse
            throw Exception("Invalid language", -1, Language)
        this._site := new ActiveScriptSite(this)
        this._SetScriptSite(this._site.ptr)
        this._InitNew()
        this._objects := {}
        this.Error := ""
        this._dsp := this._GetScriptDispatch()  ; Must be done last.
        try
            if this.ScriptEngine() = "JScript"
                this.SetJScript58()
    }

    SetJScript58()
    {
        static IID_IActiveScriptProperty := "{4954E0D0-FBC7-11D1-8410-006008C3FBFC}"
        if !prop := ComObjQuery(this._script, IID_IActiveScriptProperty)
            return false
        VarSetCapacity(var, 24, 0), NumPut(2, NumPut(3, var, "short") + 6)
        hr := DllCall(NumGet(NumGet(prop+0)+4*A_PtrSize), "ptr", prop, "uint", 0x4000
            , "ptr", 0, "ptr", &var), ObjRelease(prop)
        return hr >= 0
    }
    
    Eval(Code)
    {
        pvar := NumGet(ComObjValue(arr:=ComObjArray(0xC,1)) + 8+A_PtrSize)
        this._ParseScriptText(Code, 0x20, pvar)  ; SCRIPTTEXT_ISEXPRESSION := 0x20
        return arr[0]
    }
    
    Exec(Code)
    {
        this._ParseScriptText(Code, 0x42, 0)  ; SCRIPTTEXT_ISVISIBLE := 2, SCRIPTTEXT_ISPERSISTENT := 0x40
        this._SetScriptState(2)  ; SCRIPTSTATE_CONNECTED := 2
    }
    
    AddObject(Name, DispObj, AddMembers := false)
    {
        static a, supports_dispatch ; Test for built-in IDispatch support.
            := a := ((a:=ComObjArray(0xC,1))[0]:=[42]) && a[0][1]=42
        if IsObject(DispObj) && !(supports_dispatch || ComObjType(DispObj))
            throw Exception("Adding a non-COM object requires AutoHotkey v1.1.17+", -1)
        this._objects[Name] := DispObj
        this._AddNamedItem(Name, AddMembers ? 8 : 2)  ; SCRIPTITEM_ISVISIBLE := 2, SCRIPTITEM_GLOBALMEMBERS := 8
    }
    
    _GetObjectUnk(Name)
    {
        return !IsObject(dsp := this._objects[Name]) ? dsp  ; Pointer
            : ComObjValue(dsp) ? ComObjValue(dsp)  ; ComObject
            : &dsp  ; AutoHotkey object
    }
    
    class _base
    {
        __Call(Method, Params*)
        {
            if ObjHasKey(this, "_dsp")
                try
                    return (this._dsp)[Method](Params*)
                catch e
                    throw Exception(e.Message, -1, e.Extra)
        }
        
        __Get(Property, Params*)
        {
            if ObjHasKey(this, "_dsp")
                try
                    return (this._dsp)[Property, Params*]
                catch e
                    throw Exception(e.Message, -1, e.Extra)
        }
        
        __Set(Property, Params*)
        {
            if ObjHasKey(this, "_dsp")
            {
                Value := Params.Pop()
                try
                    return (this._dsp)[Property, Params*] := Value
                catch e
                    throw Exception(e.Message, -1, e.Extra)
            }
        }
    }
    
    _SetScriptSite(Site)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+3*A_PtrSize), "ptr", p, "ptr", Site)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::SetScriptSite")
    }
    
    _SetScriptState(State)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+5*A_PtrSize), "ptr", p, "int", State)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::SetScriptState")
    }
    
    _AddNamedItem(Name, Flags)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+8*A_PtrSize), "ptr", p, "wstr", Name, "uint", Flags)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::AddNamedItem")
    }
    
    _GetScriptDispatch()
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+10*A_PtrSize), "ptr", p, "ptr", 0, "ptr*", pdsp)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::GetScriptDispatch")
        return ComObject(9, pdsp, 1)
    }
    
    _InitNew()
    {
        hr := DllCall(NumGet(NumGet((p:=this._scriptParse)+0)+3*A_PtrSize), "ptr", p)
        if (hr < 0)
            this._HRFail(hr, "IActiveScriptParse::InitNew")
    }
    
    _ParseScriptText(Code, Flags, pvarResult)
    {
        VarSetCapacity(excp, 8 * A_PtrSize, 0)
        hr := DllCall(NumGet(NumGet((p:=this._scriptParse)+0)+5*A_PtrSize), "ptr", p
            , "wstr", Code, "ptr", 0, "ptr", 0, "ptr", 0, "uptr", 0, "uint", 1
            , "uint", Flags, "ptr", pvarResult, "ptr", 0)
        if (hr < 0)
            this._HRFail(hr, "IActiveScriptParse::ParseScriptText")
    }
    
    _HRFail(hr, what)
    {
        if e := this.Error
        {
            this.Error := ""
            throw Exception("`nError code:`t" this._HRFormat(e.HRESULT)
                . "`nSource:`t`t" e.Source "`nDescription:`t" e.Description
                . "`nLine:`t`t" e.Line "`nColumn:`t`t" e.Column
                . "`nLine text:`t`t" e.LineText, -3)
        }
        throw Exception(what " failed with code " this._HRFormat(hr), -2)
    }
    
    _HRFormat(hr)
    {
        return Format("0x{1:X}", hr & 0xFFFFFFFF)
    }
    
    _OnScriptError(err) ; IActiveScriptError err
    {
        VarSetCapacity(excp, 8 * A_PtrSize, 0)
        DllCall(NumGet(NumGet(err+0)+3*A_PtrSize), "ptr", err, "ptr", &excp) ; GetExceptionInfo
        DllCall(NumGet(NumGet(err+0)+4*A_PtrSize), "ptr", err, "uint*", srcctx, "uint*", srcline, "int*", srccol) ; GetSourcePosition
        DllCall(NumGet(NumGet(err+0)+5*A_PtrSize), "ptr", err, "ptr*", pbstrcode) ; GetSourceLineText
        code := StrGet(pbstrcode, "UTF-16"), DllCall("OleAut32\SysFreeString", "ptr", pbstrcode)
        if fn := NumGet(excp, 6 * A_PtrSize) ; pfnDeferredFillIn
            DllCall(fn, "ptr", &excp)
        wcode := NumGet(excp, 0, "ushort")
        hr := wcode ? 0x80040200 + wcode : NumGet(excp, 7 * A_PtrSize, "uint")
        this.Error := {HRESULT: hr, Line: srcline, Column: srccol, LineText: code}
        static Infos := "Source,Description,HelpFile"
        Loop Parse, % Infos, `,
            if pbstr := NumGet(excp, A_Index * A_PtrSize)
                this.Error[A_LoopField] := StrGet(pbstr, "UTF-16"), DllCall("OleAut32\SysFreeString", "ptr", pbstr)
        return 0x80004001 ; E_NOTIMPL (let Exec/Eval get a fail result)
    }
    
    __Delete()
    {
        if this._script
        {
            DllCall(NumGet(NumGet((p:=this._script)+0)+7*A_PtrSize), "ptr", p)  ; Close
            ObjRelease(this._script)
        }
        if this._scriptParse
            ObjRelease(this._scriptParse)
    }
    
    static IID := "{BB1A2AE1-A4F9-11cf-8F20-00805F2CD064}"
    static IID_Parse := A_PtrSize=8 ? "{C7EF7658-E1EE-480E-97EA-D52CB4D76D17}" : "{BB1A2AE2-A4F9-11cf-8F20-00805F2CD064}"
}

class ActiveScriptSite
{
    __New(Script)
    {
        ObjSetCapacity(this, "_site", 3 * A_PtrSize)
        NumPut(&Script
        , NumPut(ActiveScriptSite._vftable("_vft_w", "31122", 0x100)
        , NumPut(ActiveScriptSite._vftable("_vft", "31125232211", 0)
            , this.ptr := ObjGetAddress(this, "_site"))))
    }
    
    _vftable(Name, PrmCounts, EIBase)
    {
        if p := ObjGetAddress(this, Name)
            return p
        ObjSetCapacity(this, Name, StrLen(PrmCounts) * A_PtrSize)
        p := ObjGetAddress(this, Name)
        Loop Parse, % PrmCounts
        {
            cb := RegisterCallback("_ActiveScriptSite", "F", A_LoopField, A_Index + EIBase)
            NumPut(cb, p + (A_Index-1) * A_PtrSize)
        }
        return p
    }
}

_ActiveScriptSite(this, a1:=0, a2:=0, a3:=0, a4:=0, a5:=0)
{
    Method := A_EventInfo & 0xFF
    if A_EventInfo >= 0x100  ; IActiveScriptSiteWindow
    {
        if Method = 4  ; GetWindow
        {
            NumPut(0, a1+0) ; *phwnd := 0
            return 0 ; S_OK
        }
        if Method = 5  ; EnableModeless
        {
            return 0 ; S_OK
        }
        this -= A_PtrSize     ; Cast to IActiveScriptSite
    }
    ;else: IActiveScriptSite
    if Method = 1  ; QueryInterface
    {
        iid := _AS_GUIDToString(a1)
        if (iid = "{00000000-0000-0000-C000-000000000046}"  ; IUnknown
         || iid = "{DB01A1E3-A42B-11cf-8F20-00805F2CD064}") ; IActiveScriptSite
        {
            NumPut(this, a2+0)
            return 0 ; S_OK
        }
        if (iid = "{D10F6761-83E9-11cf-8F20-00805F2CD064}") ; IActiveScriptSiteWindow
        {
            NumPut(this + A_PtrSize, a2+0)
            return 0 ; S_OK
        }
        NumPut(0, a2+0)
        return 0x80004002 ; E_NOINTERFACE
    }
    if Method = 5  ; GetItemInfo
    {
        a1 := StrGet(a1, "UTF-16")
        , (a3 && NumPut(0, a3+0))  ; *ppiunkItem := NULL
        , (a4 && NumPut(0, a4+0))  ; *ppti := NULL
        if (a2 & 1) ; SCRIPTINFO_IUNKNOWN
        {
            if !(unk := Object(NumGet(this + A_PtrSize*2))._GetObjectUnk(a1))
                return 0x8002802B ; TYPE_E_ELEMENTNOTFOUND
            ObjAddRef(unk), NumPut(unk, a3+0)
        }
        return 0 ; S_OK
    }
    if Method = 9  ; OnScriptError
        return Object(NumGet(this + A_PtrSize*2))._OnScriptError(a1)
    
    ; AddRef and Release don't do anything because we want to avoid circular references.
    ; The site and IActiveScript are both released when the AHK script releases its last
    ; reference to the ActiveScript object.
    
    ; All of the other methods don't require implementations.
    return 0x80004001 ; E_NOTIMPL
}

_AS_GUIDToString(pGUID)
{
    VarSetCapacity(String, 38*2)
    DllCall("ole32\StringFromGUID2", "ptr", pGUID, "str", String, "int", 39)
    return String
}

}

sleep 3000

}

}

return 
GuiEscape:
ExitApp


EncodeInteger( p_value, p_size, p_address, p_offset )
{
	loop, %p_size%
		DllCall( "RtlFillMemory"
			, "uint", p_address+p_offset+A_Index-1
			, "uint", 1
			, "uchar", ( p_value >> ( 8*( A_Index-1 ) ) ) & 0xFF )
}


Но A_EventInfo несёт какую-то ахинею, и стрим не работает.

58 (изменено: OmTatSat, 2016-07-13 15:28:17)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Нашелся обходной путь.

 Gui,2:default
	RowNumber := LV_GetNext("0")
	Run, % vlc " " urlVlc "?sid=" sid "&file=" RowNumber -1

59 (изменено: OmTatSat, 2016-07-14 11:55:08)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Пока вот что получилось.
Ещё надо придумать как реализовать, чтобы доп гуи открывался только если файлов больше одного.

#NoTrayIcon
#SingleInstance, force
SetTitleMatchMode, 2
DetectHiddenWindows, On
Gui, Color, 000000 
Gui, -SysMenu -ToolWindow -Caption -Border +AlwaysOnTop ; (+E0x20 - клик сквозь)
Gui +LastFound 
hWnd:=WinExist()
DllCall("SetClassLong","UInt",hWnd,"Int",-26,"UInt",0x8)
WinSet, Transparent, 200
WinSet, ExStyle, ^0x80,
Gui, Font, s7 q5, Verdana
Gui, 1:Add, Text, x1 y-1 w1660 h12 Center cf2ee11  BackgroundTrans vProg +0x201 , 
Gui, Add, Text, x792 y-1 w1660 h12 Center cf2ee11  BackgroundTrans vtime +0x201 ,
Gui, Add, Progress, w1678 h1 x0 y12 cBlue vMyProgress
runonce = 0
global dblclk = 0
Global a := 0
global rundblclk = 0

OnMessage(0x201, "WM_LBUTTONDOWN")
OnMessage(0x203,"WM_LBUTTONDBLCLK")
onmessage(0x207,"WM_MBUTTONDOWN")
onmessage(0x204,"WM_RBUTTONDOWN")
OnMessage(0x100, "WM_KEYDOWN")



WM_LBUTTONDBLCLK()
{	
	Global click := 2
   ;ToolTip, % vlc " " urlVlc "?sid=" sid "&file=0"
	;return
	global dblclk = 1 
fold = %folder%\
Gui,2:default
; Create the ListView with two columns, Name and Size:
Gui, 2:Add, ListView, r20 w700 gMyListView, Name|Size (KB)

; Gather a list of file names from a folder and put them into the ListView:
;ToolTip, %folder%\*.* %A_MyDocuments%\*.*

Loop, %folder%\*.*
    LV_Add("", A_LoopFileName, A_LoopFileSizeKB)

LV_ModifyCol()  ; Auto-size each column to fit its contents.
LV_ModifyCol(2, "Integer")  ; For sorting purposes, indicate that column 2 is an integer.
; Display the window and return. The script will be notified whenever the user double clicks a row.
Gui, 2:Show, x1 y537, choose


MyListView:
;KeyWait, LButton, D
;While !(GetKeyState("LButton","P"))
Loop
{
    ToolTip, while a=%a% `n dblclkmylistview = %dblclk% `n rundblclk= %rundblclk%
    sleep 200
    
    
     
	
if rundblclk = 1
{
    Gui,2:default
	RowNumber := LV_GetNext("0")
	Run, % vlc " " urlVlc "?sid=" sid "&file=" RowNumber -1
    ;ToolTip You double-clicked row number %A_EventInfo%. Text: "%RowText%" %b%
	Global a := 1
    ToolTip,  a=%a%
	global rundblclk = 0
	Gui, 2:Destroy
	
}
While (a = 1)
{
    Global a := 0
    return
}
}
return
}

WM_LBUTTONDOWN()
{
	 Global click := 1
   SetTimer, check, -950
   return

   check:
   ToolTip, dblclkcheck = %dblclk% `n click= %click%
   sleep, 1000
   if ((click = 1) & (dblclk = 0))
    run %path1%	
   if ((click = 1) & (dblclk = 1)) 
global rundblclk = 1
      return
	
}






WM_MBUTTONDOWN()
{
    WinGet, utid, ID,  / ahk_exe uTorrent.exe
   
    if state = Загрузка
    {
      DllCall( "PostMessage", UInt,utid, UInt,0x111, UInt,62, Int,0 ) ; pouse https://autohotkey.com/board/topic/46880-utorrent-wm-command-wparam-values-for-menu-items/
      GuiControl, , Prog,  Загрузка останавлливается...
    }
if state = Пауза
    {
 DllCall( "PostMessage", UInt,utid, UInt,0x111, UInt,61, Int,0 ) ; resume
 GuiControl, , Prog,  Загрузка востанавлливается... 
   }
}

WM_RBUTTONDOWN()
{
    winactivate, / ahk_exe uTorrent.exe
	}


Loop
{
Process, Exist, uTorrent.exe
status = %ErrorLevel% 
if status = 0
{
run, "C:\staff\margin\margin hsi.exe" "C:\staff\margin\destroy margin 0.hss" ; убрать кусок отрезаного от приложений экрана
Process, close, uTorrent_osd.exe
}
ip := "127.0.0.1"
port := "8080"
user := "admin"
pass := "pass"
url := "http://" ip ":" port "/gui/"
global vlc := "C:\Program Files\DAUM\PotPlayer\PotPlayerMini64.exe"
global urlVlc := "http://" ip ":" port "/proxy"
tokenUrl := url "token.html"
action := "?list=1"
HTTP := ComObjCreate("WinHTTP.WinHTTPRequest.5.1")
HTTP.Open("GET", tokenUrl, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
token := "&token=" RegExReplace(HTTP.ResponseText, "<.+?>")
HTTP.Open("GET", url action token, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
Body := HTTP.ResponseBody
pArr := ComObjValue(Body)
cBytes := NumGet(pArr+0, A_PtrSize = 8? 24:16, "uint")
pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, "ptr")
;MsgBox, % StrGet(pText, cBytes, "utf-8") 
;msgbox % HTTP.ResponseText
JsonString := StrGet(pText, cBytes, "utf-8")
JS := new ActiveScript("JScript")
JS.eval("delete ActiveXObject; delete GetObject;") 
obj := JS.eval("(" . JsonString . ")").torrents
SetFormat,Float,0.1
{
Loop % obj.length
{
   ;MsgBox % obj[A_Index - 1][4]/10
   global sid := obj[A_Index - 1][22]
   global folder := obj[A_Index - 1][26]
   hash := obj[A_Index - 1][0]
   action := "?action=getfiles&hash=" hash 
   HTTP.Open("GET", url action token, false)
   HTTP.SetCredentials(user, pass, 0)
   HTTP.Send()
   Body := HTTP.ResponseBody
   pArr := ComObjValue(Body)
   cBytes := NumGet(pArr+0, A_PtrSize = 8? 24:16, "uint")
   pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, "ptr")
   JsonString := StrGet(pText, cBytes, "utf-8")
   file := JS.eval("(" . JsonString . ")").files
   
   global state = % obj[A_Index - 1][21]
   p = % obj[A_Index - 1][4]/10
   n = % obj[A_Index - 1][2]
   s = % obj[A_Index - 1][9]/1000000
   size = % obj[A_Index - 1][3]/1000000
   t = % obj[A_Index - 1][10]/60
   loop % file[1].length
   Global path1 := % folder "\" file[1][A_Index-1][0]
   
;Run, % vlc " " urlVlc "?sid=" sid "&file=0" ; A_Index-1
     ; Msgbox play %urlVlc%


var1 := RegExMatch(p, "(.*)\.", match)
if t contains -
{
var2 := RegExMatch(t, "-(.*)", matchh)
t = 
}

IfNotEqual, match1, 100  
{
    if runonce = 0
    {
    runonce = 1
    run, "C:\staff\margin\margin hsi.exe" "C:\staff\margin\margin bottom 15.hss"
    Gui, 1:Show, x1 y1037, uTorrent_osd
    
}

GuiControl,, MyProgress, %p% ;vPRBAR cFF7200

GuiControl, , Prog,  %n% - %size%мб   скорость %s%мб/с   осталось %matchh1%м   завершено %p%`% %state%  ;%path1%
formattime,date,,dd/MM/yy
GuiControl,, Time, %A_Hour%:%A_Min% %A_DDD% %date% 


sleep, 3000
}


/*
 *  ActiveScript for AutoHotkey v1.1
 *
 *  Provides an interface to Active Scripting languages like VBScript and JScript,
 *  without relying on Microsoft's ScriptControl, which is not available to 64-bit
 *  programs.
 *
 *  License: Use, modify and redistribute without limitation, but at your own risk.
 */
class ActiveScript extends ActiveScript._base
{
    __New(Language)
    {
        if this._script := ComObjCreate(Language, ActiveScript.IID)
            this._scriptParse := ComObjQuery(this._script, ActiveScript.IID_Parse)
        if !this._scriptParse
            throw Exception("Invalid language", -1, Language)
        this._site := new ActiveScriptSite(this)
        this._SetScriptSite(this._site.ptr)
        this._InitNew()
        this._objects := {}
        this.Error := ""
        this._dsp := this._GetScriptDispatch()  ; Must be done last.
        try
            if this.ScriptEngine() = "JScript"
                this.SetJScript58()
    }

    SetJScript58()
    {
        static IID_IActiveScriptProperty := "{4954E0D0-FBC7-11D1-8410-006008C3FBFC}"
        if !prop := ComObjQuery(this._script, IID_IActiveScriptProperty)
            return false
        VarSetCapacity(var, 24, 0), NumPut(2, NumPut(3, var, "short") + 6)
        hr := DllCall(NumGet(NumGet(prop+0)+4*A_PtrSize), "ptr", prop, "uint", 0x4000
            , "ptr", 0, "ptr", &var), ObjRelease(prop)
        return hr >= 0
    }
    
    Eval(Code)
    {
        pvar := NumGet(ComObjValue(arr:=ComObjArray(0xC,1)) + 8+A_PtrSize)
        this._ParseScriptText(Code, 0x20, pvar)  ; SCRIPTTEXT_ISEXPRESSION := 0x20
        return arr[0]
    }
    
    Exec(Code)
    {
        this._ParseScriptText(Code, 0x42, 0)  ; SCRIPTTEXT_ISVISIBLE := 2, SCRIPTTEXT_ISPERSISTENT := 0x40
        this._SetScriptState(2)  ; SCRIPTSTATE_CONNECTED := 2
    }
    
    AddObject(Name, DispObj, AddMembers := false)
    {
        static a, supports_dispatch ; Test for built-in IDispatch support.
            := a := ((a:=ComObjArray(0xC,1))[0]:=[42]) && a[0][1]=42
        if IsObject(DispObj) && !(supports_dispatch || ComObjType(DispObj))
            throw Exception("Adding a non-COM object requires AutoHotkey v1.1.17+", -1)
        this._objects[Name] := DispObj
        this._AddNamedItem(Name, AddMembers ? 8 : 2)  ; SCRIPTITEM_ISVISIBLE := 2, SCRIPTITEM_GLOBALMEMBERS := 8
    }
    
    _GetObjectUnk(Name)
    {
        return !IsObject(dsp := this._objects[Name]) ? dsp  ; Pointer
            : ComObjValue(dsp) ? ComObjValue(dsp)  ; ComObject
            : &dsp  ; AutoHotkey object
    }
    
    class _base
    {
        __Call(Method, Params*)
        {
            if ObjHasKey(this, "_dsp")
                try
                    return (this._dsp)[Method](Params*)
                catch e
                    throw Exception(e.Message, -1, e.Extra)
        }
        
        __Get(Property, Params*)
        {
            if ObjHasKey(this, "_dsp")
                try
                    return (this._dsp)[Property, Params*]
                catch e
                    throw Exception(e.Message, -1, e.Extra)
        }
        
        __Set(Property, Params*)
        {
            if ObjHasKey(this, "_dsp")
            {
                Value := Params.Pop()
                try
                    return (this._dsp)[Property, Params*] := Value
                catch e
                    throw Exception(e.Message, -1, e.Extra)
            }
        }
    }
    
    _SetScriptSite(Site)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+3*A_PtrSize), "ptr", p, "ptr", Site)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::SetScriptSite")
    }
    
    _SetScriptState(State)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+5*A_PtrSize), "ptr", p, "int", State)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::SetScriptState")
    }
    
    _AddNamedItem(Name, Flags)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+8*A_PtrSize), "ptr", p, "wstr", Name, "uint", Flags)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::AddNamedItem")
    }
    
    _GetScriptDispatch()
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+10*A_PtrSize), "ptr", p, "ptr", 0, "ptr*", pdsp)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::GetScriptDispatch")
        return ComObject(9, pdsp, 1)
    }
    
    _InitNew()
    {
        hr := DllCall(NumGet(NumGet((p:=this._scriptParse)+0)+3*A_PtrSize), "ptr", p)
        if (hr < 0)
            this._HRFail(hr, "IActiveScriptParse::InitNew")
    }
    
    _ParseScriptText(Code, Flags, pvarResult)
    {
        VarSetCapacity(excp, 8 * A_PtrSize, 0)
        hr := DllCall(NumGet(NumGet((p:=this._scriptParse)+0)+5*A_PtrSize), "ptr", p
            , "wstr", Code, "ptr", 0, "ptr", 0, "ptr", 0, "uptr", 0, "uint", 1
            , "uint", Flags, "ptr", pvarResult, "ptr", 0)
        if (hr < 0)
            this._HRFail(hr, "IActiveScriptParse::ParseScriptText")
    }
    
    _HRFail(hr, what)
    {
        if e := this.Error
        {
            this.Error := ""
            throw Exception("`nError code:`t" this._HRFormat(e.HRESULT)
                . "`nSource:`t`t" e.Source "`nDescription:`t" e.Description
                . "`nLine:`t`t" e.Line "`nColumn:`t`t" e.Column
                . "`nLine text:`t`t" e.LineText, -3)
        }
        throw Exception(what " failed with code " this._HRFormat(hr), -2)
    }
    
    _HRFormat(hr)
    {
        return Format("0x{1:X}", hr & 0xFFFFFFFF)
    }
    
    _OnScriptError(err) ; IActiveScriptError err
    {
        VarSetCapacity(excp, 8 * A_PtrSize, 0)
        DllCall(NumGet(NumGet(err+0)+3*A_PtrSize), "ptr", err, "ptr", &excp) ; GetExceptionInfo
        DllCall(NumGet(NumGet(err+0)+4*A_PtrSize), "ptr", err, "uint*", srcctx, "uint*", srcline, "int*", srccol) ; GetSourcePosition
        DllCall(NumGet(NumGet(err+0)+5*A_PtrSize), "ptr", err, "ptr*", pbstrcode) ; GetSourceLineText
        code := StrGet(pbstrcode, "UTF-16"), DllCall("OleAut32\SysFreeString", "ptr", pbstrcode)
        if fn := NumGet(excp, 6 * A_PtrSize) ; pfnDeferredFillIn
            DllCall(fn, "ptr", &excp)
        wcode := NumGet(excp, 0, "ushort")
        hr := wcode ? 0x80040200 + wcode : NumGet(excp, 7 * A_PtrSize, "uint")
        this.Error := {HRESULT: hr, Line: srcline, Column: srccol, LineText: code}
        static Infos := "Source,Description,HelpFile"
        Loop Parse, % Infos, `,
            if pbstr := NumGet(excp, A_Index * A_PtrSize)
                this.Error[A_LoopField] := StrGet(pbstr, "UTF-16"), DllCall("OleAut32\SysFreeString", "ptr", pbstr)
        return 0x80004001 ; E_NOTIMPL (let Exec/Eval get a fail result)
    }
    
    __Delete()
    {
        if this._script
        {
            DllCall(NumGet(NumGet((p:=this._script)+0)+7*A_PtrSize), "ptr", p)  ; Close
            ObjRelease(this._script)
        }
        if this._scriptParse
            ObjRelease(this._scriptParse)
    }
    
    static IID := "{BB1A2AE1-A4F9-11cf-8F20-00805F2CD064}"
    static IID_Parse := A_PtrSize=8 ? "{C7EF7658-E1EE-480E-97EA-D52CB4D76D17}" : "{BB1A2AE2-A4F9-11cf-8F20-00805F2CD064}"
}

class ActiveScriptSite
{
    __New(Script)
    {
        ObjSetCapacity(this, "_site", 3 * A_PtrSize)
        NumPut(&Script
        , NumPut(ActiveScriptSite._vftable("_vft_w", "31122", 0x100)
        , NumPut(ActiveScriptSite._vftable("_vft", "31125232211", 0)
            , this.ptr := ObjGetAddress(this, "_site"))))
    }
    
    _vftable(Name, PrmCounts, EIBase)
    {
        if p := ObjGetAddress(this, Name)
            return p
        ObjSetCapacity(this, Name, StrLen(PrmCounts) * A_PtrSize)
        p := ObjGetAddress(this, Name)
        Loop Parse, % PrmCounts
        {
            cb := RegisterCallback("_ActiveScriptSite", "F", A_LoopField, A_Index + EIBase)
            NumPut(cb, p + (A_Index-1) * A_PtrSize)
        }
        return p
    }
}

_ActiveScriptSite(this, a1:=0, a2:=0, a3:=0, a4:=0, a5:=0)
{
    Method := A_EventInfo & 0xFF
    if A_EventInfo >= 0x100  ; IActiveScriptSiteWindow
    {
        if Method = 4  ; GetWindow
        {
            NumPut(0, a1+0) ; *phwnd := 0
            return 0 ; S_OK
        }
        if Method = 5  ; EnableModeless
        {
            return 0 ; S_OK
        }
        this -= A_PtrSize     ; Cast to IActiveScriptSite
    }
    ;else: IActiveScriptSite
    if Method = 1  ; QueryInterface
    {
        iid := _AS_GUIDToString(a1)
        if (iid = "{00000000-0000-0000-C000-000000000046}"  ; IUnknown
         || iid = "{DB01A1E3-A42B-11cf-8F20-00805F2CD064}") ; IActiveScriptSite
        {
            NumPut(this, a2+0)
            return 0 ; S_OK
        }
        if (iid = "{D10F6761-83E9-11cf-8F20-00805F2CD064}") ; IActiveScriptSiteWindow
        {
            NumPut(this + A_PtrSize, a2+0)
            return 0 ; S_OK
        }
        NumPut(0, a2+0)
        return 0x80004002 ; E_NOINTERFACE
    }
    if Method = 5  ; GetItemInfo
    {
        a1 := StrGet(a1, "UTF-16")
        , (a3 && NumPut(0, a3+0))  ; *ppiunkItem := NULL
        , (a4 && NumPut(0, a4+0))  ; *ppti := NULL
        if (a2 & 1) ; SCRIPTINFO_IUNKNOWN
        {
            if !(unk := Object(NumGet(this + A_PtrSize*2))._GetObjectUnk(a1))
                return 0x8002802B ; TYPE_E_ELEMENTNOTFOUND
            ObjAddRef(unk), NumPut(unk, a3+0)
        }
        return 0 ; S_OK
    }
    if Method = 9  ; OnScriptError
        return Object(NumGet(this + A_PtrSize*2))._OnScriptError(a1)
    
    ; AddRef and Release don't do anything because we want to avoid circular references.
    ; The site and IActiveScript are both released when the AHK script releases its last
    ; reference to the ActiveScript object.
    
    ; All of the other methods don't require implementations.
    return 0x80004001 ; E_NOTIMPL
}

_AS_GUIDToString(pGUID)
{
    VarSetCapacity(String, 38*2)
    DllCall("ole32\StringFromGUID2", "ptr", pGUID, "str", String, "int", 39)
    return String
}

}

sleep 3000

}

}

return 
GuiEscape:
ExitApp


EncodeInteger( p_value, p_size, p_address, p_offset )
{
	loop, %p_size%
		DllCall( "RtlFillMemory"
			, "uint", p_address+p_offset+A_Index-1
			, "uint", 1
			, "uchar", ( p_value >> ( 8*( A_Index-1 ) ) ) & 0xFF )
}


60 (изменено: OmTatSat, 2016-07-13 15:29:00)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Если судить по MsgBox, % StrGet(pText, cBytes, "utf-8") , то 24ый параметр имеет 0 у раздач с папками и пустой у одно файловых раздач.
Но global multiornot := obj[A_Index - 1][24] возвращает всегда 0 и никогда пустую строку, как можно обойти это?

{"build":28705,"label": [
]
,"torrents": [

["F6A9DEFB16A8E31915BF2C73363844D066D22091",137,"Dark Matter (Season 02) LostFilm",1167075328,904,1059022848,15745024,14,0,0,-1,"",0,302,0,0,58711,1,110936064,"","","[П] Загружается","247f0e4",1468267355,0,"","G:\\TORRENTS\\Dark Matter (Season 02) LostFilm",0,"4AAF6B4E"],
["5D9A342D393F0044C2BC9BF71281D1915450A9C3",136,"Keanu.2016.P.WEB-DLRip.1400MB_KOSHARA.avi",1467449344,1000,1411383296,2031616,1,0,0,0,"",0,0,0,0,65536,-1,0,"","","Завершено","506ef1",1468172169,1468263848,"","G:\\TORRENTS",0,"9EB57A73"],
["247F1E868083C5D1DB8E8AA41ACE9A9353FDC640",136,"Keanu.2016.P.WEB-DLRip.700MB_KOSHARA.avi",734228480,1000,643612672,2048000,3,0,0,0,"",0,0,0,0,65536,-1,0,"","","Завершено","12728f9",1468152926,1468166241,"","G:\\TORRENTS",0,"C3482F5C"],
["5705B75811B1BE5BEAC0F54385661F3EF22E00BB",136,"Tout.en.Haut.du.Monde(2015).avi",1426354176,1000,1426354176,4096000,2,0,0,0,"",0,49,0,0,65536,-1,0,"","","Завершено","23bb627",1468266555,1468351085,"","G:\\TORRENTS",0,"2F1E69E4"],
["C7443ADC19C1ADFC9CEE4722135F1CAA3D6995E5",137,"Life.on.the.Line.2O16.P.HDRip.700MB_KOSHARA.avi",733358080,3,2457600,0,0,0,0,-1,"",0,110,0,1,187,2,730900480,"","","[П] Загружается","17fb38",1468353985,0,"","G:\\TORRENTS",0,"E57B274B"],
["27F5D153E693151A6C9CAEB26FC682FBD04A87DF",201,"The Last Kingdom (Season 01)",5603639296,0,0,0,0,0,0,-1,"",0,149,0,0,0,3,5603639296,"","","Загрузка","27e220f",1468394234,0,"","G:\\TORRENTS\\The Last Kingdom (Season 01)",0,"0B3C3496"]]
,"torrentc": "1440059062"
,"rssfeeds": []
,"rssfilters": []
}

61 (изменено: OmTatSat, 2016-07-13 15:29:16)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Хотя нет, 23ий но после запятой, как его вытянуть?

"27e220f",1468394234,0,"","G:\\TOR

62 (изменено: OmTatSat, 2016-07-13 15:30:08)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Подумал на счёт регекса.

OutputVar := % StrGet(pText, cBytes, "utf-8") 
var1 := RegExMatch(OutputVar, "1468267355,([0-9])", match)
MsgBox % match1 "`n" match2 "`n" match3

И получился заветный 0)
Но как в регекс вставить переменную?

Вариант.

global multiornot := obj[A_Index - 1][23]
    
    OutputVar := % StrGet(pText, cBytes, "utf-8") 

var1 := RegExMatch(OutputVar, "%multiornot%([0-9])", match)

MsgBox % match1 "`n" match2 "`n" match3

Не работает.

63

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

OmTatSat, верните заглавные буквы и точки в свои посты.

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Telegram jollycoder

64

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

teadrinker пишет:

верните заглавные буквы и точки в свои посты.

Вроде вернул.

65

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Если судить по MsgBox, % StrGet(pText, cBytes, "utf-8") , то 24ый параметр имеет 0 у раздач с папками и пустой у одно файловых раздач.

У меня нет такой закономерности. Так что думаю вы ошибаетесь.

Ещё надо придумать как реализовать, чтобы доп гуи открывался только если файлов больше одного.

Тут надо еще учесть, что не просто файлов, а видеофайлов.
Можно так (из 44 поста):

n := 0
loop % file[1].length
{
   If .... ; если у файла нужное нам расширение
      n++
}
msgbox % n

66 (изменено: OmTatSat, 2016-07-13 18:24:12)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Malcev пишет:

У меня нет такой закономерности. Так что думаю вы ошибаетесь.

Ниже поправился, 23ий... Странно, у меня 3 раздачи сериалов, у всех есть параметр "0", и 3 фильма, у всех параметра "0" нету.

"If .... ; если у файла нужное нам расширение" а что за точками?) Через регекс проще всего?

67

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

loop % file[1].length
{
   If RegexMatch(file[1][A_Index-1][0], "\.(avi|mpg|mp4|mkv)$") 
      msgbox видеофайл
}

68

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

OmTatSat пишет:

Ещё надо придумать как реализовать, чтобы доп гуи открывался только если файлов больше одного.

Дело в том, что если доп гуи открывается для торрента с одним файлом, то в гуи загружаются все файлы с корневого каталога загрузок торрента, то-есть много.

69 (изменено: Malcev, 2016-07-13 18:54:03)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

А как вы получаете список файлов?
Список файлов надо получать через парсинг второго json массива, который для каждого торрента отдельный.
Смотрите пост 31.

70

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Нашелся способ идентификации много файловых торрентов.

if RegexMatch(obj[A_Index - 1][26], "\\*\\")

71

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Malcev пишет:

А как вы получаете список файлов?

Loop, %folder%\*.*
    LV_Add("", A_LoopFileName, A_LoopFileSizeKB)

72

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Не правильно.
Еще раз пересмотрите пост номер 31.

73

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Malcev пишет:

парсинг второго json массива

Так?

% obj[A_Index - 1][2]

Но так не получается список файлов торрента, если файл один, то получим его имя, если их много, то получим название папки которая их содержит.

74

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Сори, вот наверное.

loop % file[1].length
      msgbox % folder "\" file[1][A_Index-1][0]

75 (изменено: OmTatSat, 2016-07-13 19:32:45)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Так не получается.

Global path1 := % folder ; "\" file[1][A_Index-1][0]
Loop, % file[1].length
    LV_Add("", path1, A_LoopFileSizeKB)

И так тоже.

Loop, % file[1].length
    LV_Add("", file[1][A_Index-1][0], A_LoopFileSizeKB)

Гуи появляется без списка файлов.

76

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Значит что-то подсократили.
Так должно работать.

Loop, % file[1].length
    LV_Add("", file[1][A_Index-1][0], A_LoopFileSizeKB)

77

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

; Create the ListView with two columns, Name and Size:
Gui, Add, ListView, r20 w700 , Name|Size (KB)
ip := "127.0.0.1"
port := "8080"
user := "log"
pass := "pass"
vlc := "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe"

urlVlc := "http://" ip ":" port "/proxy"
url := "http://" ip ":" port "/gui/"
tokenUrl := url "token.html"
action := "?list=1"
HTTP := ComObjCreate("WinHTTP.WinHTTPRequest.5.1")
HTTP.Open("GET", tokenUrl, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
token := "&token=" RegExReplace(HTTP.ResponseText, "<.+?>")
HTTP.Open("GET", url action token, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
Body := HTTP.ResponseBody
pArr := ComObjValue(Body)
cBytes := NumGet(pArr+0, A_PtrSize = 8? 24:16, "uint")
pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, "ptr")
JsonString := StrGet(pText, cBytes, "utf-8")

JS := new ActiveScript("JScript")
JS.eval("delete ActiveXObject; delete GetObject;") 

obj := JS.eval("(" . JsonString . ")").torrents
Loop % obj.length
{
   sid := obj[A_Index - 1][22]
   hash := obj[A_Index - 1][0]
   action := "?action=getfiles&hash=" hash 
   HTTP.Open("GET", url action token, false)
   HTTP.SetCredentials(user, pass, 0)
   HTTP.Send()
   Body := HTTP.ResponseBody
   pArr := ComObjValue(Body)
   cBytes := NumGet(pArr+0, A_PtrSize = 8? 24:16, "uint")
   pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, "ptr")
   JsonString := StrGet(pText, cBytes, "utf-8")
   file := JS.eval("(" . JsonString . ")").files
   loop % file[1].length
      LV_Add("", file[1][A_Index-1][0] , A_LoopFileSizeKB)
}
Gui, Show

78

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Всё также, пустой список. Может у меня Ahk глюкнул?

79

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Вряд ли.
А Класс ActiveScript вставили?

80

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Malcev пишет:

А Класс ActiveScript вставили?

Это как? Просто скопировал код с вашего сообщения, ввёл логин и пароль.

81

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

В 6 сообщении:

/*
 *  ActiveScript for AutoHotkey v1.1
 *
 *  Provides an interface to Active Scripting languages like VBScript and JScript,
 *  without relying on Microsoft's ScriptControl, which is not available to 64-bit
 *  programs.
 *
 *  License: Use, modify and redistribute without limitation, but at your own risk.
 */
class ActiveScript extends ActiveScript._base
{
    __New(Language)
    {
        if this._script := ComObjCreate(Language, ActiveScript.IID)
            this._scriptParse := ComObjQuery(this._script, ActiveScript.IID_Parse)
        if !this._scriptParse
            throw Exception("Invalid language", -1, Language)
        this._site := new ActiveScriptSite(this)
        this._SetScriptSite(this._site.ptr)
        this._InitNew()
        this._objects := {}
        this.Error := ""
        this._dsp := this._GetScriptDispatch()  ; Must be done last.
        try
            if this.ScriptEngine() = "JScript"
                this.SetJScript58()
    }

    SetJScript58()
    {
        static IID_IActiveScriptProperty := "{4954E0D0-FBC7-11D1-8410-006008C3FBFC}"
        if !prop := ComObjQuery(this._script, IID_IActiveScriptProperty)
            return false
        VarSetCapacity(var, 24, 0), NumPut(2, NumPut(3, var, "short") + 6)
        hr := DllCall(NumGet(NumGet(prop+0)+4*A_PtrSize), "ptr", prop, "uint", 0x4000
            , "ptr", 0, "ptr", &var), ObjRelease(prop)
        return hr >= 0
    }
    
    Eval(Code)
    {
        pvar := NumGet(ComObjValue(arr:=ComObjArray(0xC,1)) + 8+A_PtrSize)
        this._ParseScriptText(Code, 0x20, pvar)  ; SCRIPTTEXT_ISEXPRESSION := 0x20
        return arr[0]
    }
    
    Exec(Code)
    {
        this._ParseScriptText(Code, 0x42, 0)  ; SCRIPTTEXT_ISVISIBLE := 2, SCRIPTTEXT_ISPERSISTENT := 0x40
        this._SetScriptState(2)  ; SCRIPTSTATE_CONNECTED := 2
    }
    
    AddObject(Name, DispObj, AddMembers := false)
    {
        static a, supports_dispatch ; Test for built-in IDispatch support.
            := a := ((a:=ComObjArray(0xC,1))[0]:=[42]) && a[0][1]=42
        if IsObject(DispObj) && !(supports_dispatch || ComObjType(DispObj))
            throw Exception("Adding a non-COM object requires AutoHotkey v1.1.17+", -1)
        this._objects[Name] := DispObj
        this._AddNamedItem(Name, AddMembers ? 8 : 2)  ; SCRIPTITEM_ISVISIBLE := 2, SCRIPTITEM_GLOBALMEMBERS := 8
    }
    
    _GetObjectUnk(Name)
    {
        return !IsObject(dsp := this._objects[Name]) ? dsp  ; Pointer
            : ComObjValue(dsp) ? ComObjValue(dsp)  ; ComObject
            : &dsp  ; AutoHotkey object
    }
    
    class _base
    {
        __Call(Method, Params*)
        {
            if ObjHasKey(this, "_dsp")
                try
                    return (this._dsp)[Method](Params*)
                catch e
                    throw Exception(e.Message, -1, e.Extra)
        }
        
        __Get(Property, Params*)
        {
            if ObjHasKey(this, "_dsp")
                try
                    return (this._dsp)[Property, Params*]
                catch e
                    throw Exception(e.Message, -1, e.Extra)
        }
        
        __Set(Property, Params*)
        {
            if ObjHasKey(this, "_dsp")
            {
                Value := Params.Pop()
                try
                    return (this._dsp)[Property, Params*] := Value
                catch e
                    throw Exception(e.Message, -1, e.Extra)
            }
        }
    }
    
    _SetScriptSite(Site)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+3*A_PtrSize), "ptr", p, "ptr", Site)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::SetScriptSite")
    }
    
    _SetScriptState(State)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+5*A_PtrSize), "ptr", p, "int", State)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::SetScriptState")
    }
    
    _AddNamedItem(Name, Flags)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+8*A_PtrSize), "ptr", p, "wstr", Name, "uint", Flags)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::AddNamedItem")
    }
    
    _GetScriptDispatch()
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+10*A_PtrSize), "ptr", p, "ptr", 0, "ptr*", pdsp)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::GetScriptDispatch")
        return ComObject(9, pdsp, 1)
    }
    
    _InitNew()
    {
        hr := DllCall(NumGet(NumGet((p:=this._scriptParse)+0)+3*A_PtrSize), "ptr", p)
        if (hr < 0)
            this._HRFail(hr, "IActiveScriptParse::InitNew")
    }
    
    _ParseScriptText(Code, Flags, pvarResult)
    {
        VarSetCapacity(excp, 8 * A_PtrSize, 0)
        hr := DllCall(NumGet(NumGet((p:=this._scriptParse)+0)+5*A_PtrSize), "ptr", p
            , "wstr", Code, "ptr", 0, "ptr", 0, "ptr", 0, "uptr", 0, "uint", 1
            , "uint", Flags, "ptr", pvarResult, "ptr", 0)
        if (hr < 0)
            this._HRFail(hr, "IActiveScriptParse::ParseScriptText")
    }
    
    _HRFail(hr, what)
    {
        if e := this.Error
        {
            this.Error := ""
            throw Exception("`nError code:`t" this._HRFormat(e.HRESULT)
                . "`nSource:`t`t" e.Source "`nDescription:`t" e.Description
                . "`nLine:`t`t" e.Line "`nColumn:`t`t" e.Column
                . "`nLine text:`t`t" e.LineText, -3)
        }
        throw Exception(what " failed with code " this._HRFormat(hr), -2)
    }
    
    _HRFormat(hr)
    {
        return Format("0x{1:X}", hr & 0xFFFFFFFF)
    }
    
    _OnScriptError(err) ; IActiveScriptError err
    {
        VarSetCapacity(excp, 8 * A_PtrSize, 0)
        DllCall(NumGet(NumGet(err+0)+3*A_PtrSize), "ptr", err, "ptr", &excp) ; GetExceptionInfo
        DllCall(NumGet(NumGet(err+0)+4*A_PtrSize), "ptr", err, "uint*", srcctx, "uint*", srcline, "int*", srccol) ; GetSourcePosition
        DllCall(NumGet(NumGet(err+0)+5*A_PtrSize), "ptr", err, "ptr*", pbstrcode) ; GetSourceLineText
        code := StrGet(pbstrcode, "UTF-16"), DllCall("OleAut32\SysFreeString", "ptr", pbstrcode)
        if fn := NumGet(excp, 6 * A_PtrSize) ; pfnDeferredFillIn
            DllCall(fn, "ptr", &excp)
        wcode := NumGet(excp, 0, "ushort")
        hr := wcode ? 0x80040200 + wcode : NumGet(excp, 7 * A_PtrSize, "uint")
        this.Error := {HRESULT: hr, Line: srcline, Column: srccol, LineText: code}
        static Infos := "Source,Description,HelpFile"
        Loop Parse, % Infos, `,
            if pbstr := NumGet(excp, A_Index * A_PtrSize)
                this.Error[A_LoopField] := StrGet(pbstr, "UTF-16"), DllCall("OleAut32\SysFreeString", "ptr", pbstr)
        return 0x80004001 ; E_NOTIMPL (let Exec/Eval get a fail result)
    }
    
    __Delete()
    {
        if this._script
        {
            DllCall(NumGet(NumGet((p:=this._script)+0)+7*A_PtrSize), "ptr", p)  ; Close
            ObjRelease(this._script)
        }
        if this._scriptParse
            ObjRelease(this._scriptParse)
    }
    
    static IID := "{BB1A2AE1-A4F9-11cf-8F20-00805F2CD064}"
    static IID_Parse := A_PtrSize=8 ? "{C7EF7658-E1EE-480E-97EA-D52CB4D76D17}" : "{BB1A2AE2-A4F9-11cf-8F20-00805F2CD064}"
}

class ActiveScriptSite
{
    __New(Script)
    {
        ObjSetCapacity(this, "_site", 3 * A_PtrSize)
        NumPut(&Script
        , NumPut(ActiveScriptSite._vftable("_vft_w", "31122", 0x100)
        , NumPut(ActiveScriptSite._vftable("_vft", "31125232211", 0)
            , this.ptr := ObjGetAddress(this, "_site"))))
    }
    
    _vftable(Name, PrmCounts, EIBase)
    {
        if p := ObjGetAddress(this, Name)
            return p
        ObjSetCapacity(this, Name, StrLen(PrmCounts) * A_PtrSize)
        p := ObjGetAddress(this, Name)
        Loop Parse, % PrmCounts
        {
            cb := RegisterCallback("_ActiveScriptSite", "F", A_LoopField, A_Index + EIBase)
            NumPut(cb, p + (A_Index-1) * A_PtrSize)
        }
        return p
    }
}

_ActiveScriptSite(this, a1:=0, a2:=0, a3:=0, a4:=0, a5:=0)
{
    Method := A_EventInfo & 0xFF
    if A_EventInfo >= 0x100  ; IActiveScriptSiteWindow
    {
        if Method = 4  ; GetWindow
        {
            NumPut(0, a1+0) ; *phwnd := 0
            return 0 ; S_OK
        }
        if Method = 5  ; EnableModeless
        {
            return 0 ; S_OK
        }
        this -= A_PtrSize     ; Cast to IActiveScriptSite
    }
    ;else: IActiveScriptSite
    if Method = 1  ; QueryInterface
    {
        iid := _AS_GUIDToString(a1)
        if (iid = "{00000000-0000-0000-C000-000000000046}"  ; IUnknown
         || iid = "{DB01A1E3-A42B-11cf-8F20-00805F2CD064}") ; IActiveScriptSite
        {
            NumPut(this, a2+0)
            return 0 ; S_OK
        }
        if (iid = "{D10F6761-83E9-11cf-8F20-00805F2CD064}") ; IActiveScriptSiteWindow
        {
            NumPut(this + A_PtrSize, a2+0)
            return 0 ; S_OK
        }
        NumPut(0, a2+0)
        return 0x80004002 ; E_NOINTERFACE
    }
    if Method = 5  ; GetItemInfo
    {
        a1 := StrGet(a1, "UTF-16")
        , (a3 && NumPut(0, a3+0))  ; *ppiunkItem := NULL
        , (a4 && NumPut(0, a4+0))  ; *ppti := NULL
        if (a2 & 1) ; SCRIPTINFO_IUNKNOWN
        {
            if !(unk := Object(NumGet(this + A_PtrSize*2))._GetObjectUnk(a1))
                return 0x8002802B ; TYPE_E_ELEMENTNOTFOUND
            ObjAddRef(unk), NumPut(unk, a3+0)
        }
        return 0 ; S_OK
    }
    if Method = 9  ; OnScriptError
        return Object(NumGet(this + A_PtrSize*2))._OnScriptError(a1)
    
    ; AddRef and Release don't do anything because we want to avoid circular references.
    ; The site and IActiveScript are both released when the AHK script releases its last
    ; reference to the ActiveScript object.
    
    ; All of the other methods don't require implementations.
    return 0x80004001 ; E_NOTIMPL
}

_AS_GUIDToString(pGUID)
{
    VarSetCapacity(String, 38*2)
    DllCall("ole32\StringFromGUID2", "ptr", pGUID, "str", String, "int", 39)
    return String
}

82 (изменено: OmTatSat, 2016-07-13 21:35:03)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Так работает.
Вот это да..., походу надо завязывать на сегодня, уже элементарные вещи не замечаю((

И такой код

if RegexMatch(obj[A_Index - 1][26], "\\*\\")

всё таки не работает. Как проверить или в строчке есть 2 слеша?

83

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

А зачем?

84

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Чтобы знать или есть в торрент раздаче папка, если есть, значит в торренте больше одного файла, в этом случае нужен гуи выбора файла. Если файл на раздачу один, то гуи не нужен, пусть сразу запускается стрим.

85 (изменено: OmTatSat, 2016-07-13 21:43:19)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Оказывается, чтобы список добавился в мой код не хватало лишь.

global file := JS.eval("(" . JsonString . ")").files

А точнее global.

86

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Получилась проверка на много файловость.

Global n = % obj[A_Index - 1][2]
   
   Global path1 := % folder ; "\" file[1][A_Index-1][0]
   
   loop % file[1].length
{
   If RegexMatch(file[1][A_Index-1][0], "\.(avi|mpg|mp4|mkv)$") 
      Global video := 1
  }
      
    IfInString, path1, %n%
      Global multivideo := 1 
      
   IfnotInString, path1, %n%
      Global multivideo := 0

87 (изменено: OmTatSat, 2016-07-14 17:49:03)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Доделал доп гуи выбора видео, если кликнуть на пустое место допгуи, то оно закроется и скрипт продолжит работу.
Как ещё бы добавить, чтобы доп гуи закрывалось к примеру если кликнуть вообще на другое окно?

Добавил адаптацию под разные разрешение экранов. И так, по мелочам...

#NoTrayIcon
#NoEnv
#SingleInstance, force


global ip := "127.0.0.1"
global port := "8080"
global user := "admin"
global pass := "pass"

SetTitleMatchMode, 2
DetectHiddenWindows, On
Gui, Color, 000000 
Gui, -SysMenu -ToolWindow -Caption -Border +AlwaysOnTop ; (+E0x20 - клик сквозь)
Gui +LastFound 
hWnd:=WinExist()
DllCall("SetClassLong","UInt",hWnd,"Int",-26,"UInt",0x8)
WinSet, Transparent, 200
WinSet, ExStyle, ^0x80,
Gui, Font, s7 q5, Verdana
SysGet, SsW, 16
SysGet, Ssh, 62
Global ssw := SsW
Global ssh := Ssh
global needy_gui := ssh-17 ; высота гуи
global needh_gui2 := ssh-448
needx_text := Ssw-205 ; расположение даты с часами
;needw_text := SsW-100 ; ширина главного текста 

Gui, 1:Add, Text, x1 y-1 w%ssw% h12 Center cf2ee11  BackgroundTrans vProg +0x201 , 
Gui, Add, Text, x%needx_text% y-1 w200 h12 right cf2ee11  BackgroundTrans vtime +0x201 ,
Gui, Add, Progress, w%SsW% h1 x0 y12 cBlue vMyProgress
global runonce = 0
global dblclk = 0
Global a := 0
global rundblclk = 0
global canceldblclk = 0
 Global video := 0
 Global multivideo := 0
 Global RowNumber = 0
 global reload := 0
OnMessage(0x201, "WM_LBUTTONDOWN")
OnMessage(0x203,"WM_LBUTTONDBLCLK")
onmessage(0x207,"WM_MBUTTONDOWN")
onmessage(0x204,"WM_RBUTTONDOWN")
OnMessage(0x100, "WM_KEYDOWN")

;MsgBox, needw = %needx_text% needh = %needh% h-%ssh%
WM_LBUTTONDBLCLK()
{	
	Global click := 2
   ;ToolTip, % vlc " " urlVlc "?sid=" sid "&file=0"
	;return
      ;MsgBox, multivideo %multivideo% video %video%
  if ((video = 1) & (multivideo = 0)) 
{
   Run, % vlc " " urlVlc "?sid=" sid "&file=0"
    ;MsgBox, multivideo %multivideo% video %video%
    return
}
    
    if ((video = 0) & (multivideo = 0)) 
{
    run, %path1%
        return
}
    if ((video = 0) & (multivideo = 1)) 
{
    run, %path1%
        return
}
    if ((video = 1) & (multivideo = 1)) 
    {
	global dblclk = 1 
fold = %folder%\
Gui,2:default
; Create the ListView with two columns, Name and Size:
Gui, 2:Add, ListView, cf2ee11 Background000000 r23 w600 gMyListView, Выберите файл для Stream просмотра:
Gui, Color, 000000 
Gui, -SysMenu -ToolWindow -Caption -Border +AlwaysOnTop  ; (+E0x20 - клик сквозь)
Gui +LastFound 
WinSet, Transparent, 200
WinSet, ExStyle, ^0x80,
Gui, Font, s7 q5, Verdana
; Gather a list of file names from a folder and put them into the ListView:
;ToolTip, %folder%\*.* %A_MyDocuments%\*.*

 loop % file[1].length

      LV_Add("", file[1][A_Index-1][0])


;LV_ModifyCol()  ; Auto-size each column to fit its contents.
LV_ModifyCol(2, "Integer")  ; For sorting purposes, indicate that column 2 is an integer.
; Display the window and return. The script will be notified whenever the user double clicks a row.
Gui, 2:Show, xcenter y%needh_gui2%
SendMode play
MouseMove, 150, 40, 0, 

}


MyListView:
;KeyWait, LButton, D
;While !(GetKeyState("LButton","P"))
Loop
{
    ;ToolTip, while a=%a% `n dblclkmylistview = %dblclk% `n rundblclk= %rundblclk%
    ;sleep 200
    
    
    if canceldblclk = 1 
    {
       Gui,2:default
	global RowNumber := LV_GetNext("0")
	;MsgBox клик в пустоту %A_EventInfo%. Text: "%RowNumber%" %b%
	Global a := 1
   ; ToolTip,  a=%a%
	global rundblclk = 0
    global canceldblclk = 0
	Gui, 2:Destroy 
    }
	
if rundblclk = 1
{
    Gui,2:default
	global RowNumber := LV_GetNext("0")
	Run, % vlc " " urlVlc "?sid=" sid "&file=" RowNumber -1
    ;MsgBox You clicked row number %A_EventInfo%. Text: "%RowNumber%" %b%
	Global a := 1
   ; ToolTip,  a=%a%
	global rundblclk = 0
	Gui, 2:Destroy
	
}
While (a = 1)
{
    Global a := 0
    return
}
}
return
}

WM_LBUTTONDOWN()
{
	 Global click := 1
   SetTimer, check, -550
   return
 
   check:
     Gui,2:default
global RowNumber := LV_GetNext("0")
   
  
   if ((click = 1) & (dblclk = 0))
    run %path1%	
   if ((click = 1) & (dblclk = 1) & (global RowNumber != 0)) 
global rundblclk = 1
if ((click = 1) & (dblclk = 1) & (global RowNumber = 0)) 
global canceldblclk = 1

   ; MsgBox, dblclkcheck = %dblclk% `n click= %click% `n RowNumber= %RowNumber% `n canceldblclk= %canceldblclk%
      return
  
}






WM_MBUTTONDOWN()
{
    WinGet, utid, ID,  / ahk_exe uTorrent.exe
   ;ToolTip, %state%
    global reload := 1
    if state = Загрузка
    {
      DllCall( "PostMessage", UInt,utid, UInt,0x111, UInt,62, Int,0 ) ; pouse https://autohotkey.com/board/topic/46880-utorrent-wm-command-wparam-values-for-menu-items/
      GuiControl, , Prog,  Загрузка останавлливается...
      
    }
    if state = [П] Загружается
    {
      DllCall( "PostMessage", UInt,utid, UInt,0x111, UInt,62, Int,0 ) ; pouse https://autohotkey.com/board/topic/46880-utorrent-wm-command-wparam-values-for-menu-items/
      GuiControl, , Prog,  Загрузка останавлливается...
      
    }
if state = Пауза
    {
 DllCall( "PostMessage", UInt,utid, UInt,0x111, UInt,61, Int,0 ) ; resume
 GuiControl, , Prog,  Загрузка востанавлливается... 
 
   }
}

WM_RBUTTONDOWN()
{
   
    winactivate, / ahk_exe uTorrent.exe
    WinGetpos, utx, uty, , , / ahk_exe uTorrent.exe
    MouseMove, utx+100, uty+100, 0
	}


Loop
{


url := "http://" ip ":" port "/gui/"
global vlc := "C:\Program Files\DAUM\PotPlayer\PotPlayerMini64.exe"
global urlVlc := "http://" ip ":" port "/proxy"
tokenUrl := url "token.html"
action := "?list=1"
HTTP := ComObjCreate("WinHTTP.WinHTTPRequest.5.1")

Process, Exist, uTorrent.exe
status = %ErrorLevel% 
if status = 0
   {
run, "C:\staff\margin\margin hsi.exe" "C:\staff\margin\destroy margin 0.hss" ; убрать кусок отрезаного от приложений экрана
Process, close, uTorrent_osd.exe
ExitApp
}

HTTP.Open("GET", tokenUrl, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
token := "&token=" RegExReplace(HTTP.ResponseText, "<.+?>")
HTTP.Open("GET", url action token, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
Body := HTTP.ResponseBody
pArr := ComObjValue(Body)
cBytes := NumGet(pArr+0, A_PtrSize = 8? 24:16, "uint")
pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, "ptr")
;MsgBox, % StrGet(pText, cBytes, "utf-8") 
;msgbox % HTTP.ResponseText
JsonString := StrGet(pText, cBytes, "utf-8")
JS := new ActiveScript("JScript")
JS.eval("delete ActiveXObject; delete GetObject;") 
obj := JS.eval("(" . JsonString . ")").torrents
SetFormat,Float,0.1
{
    
    
   
    
Loop % obj.length
{
    
        Global video := 0
        
        if reload = 1
        {
            ;MsgBox, reload 1
        global reload := 0
            break
        }

;global multiornot := % obj[A_Index - 1][23]   ; ([a-zA-Z0-9{7}])'', match)
  ;  global mm := % multiornot ",([0-9])"
  ;  ToolTip, mm = %mm%
  ;  OutputVar := % StrGet(pText, cBytes, "utf-8") 
;OutputVar := "12.456 h/ 5673 567-"
;var1 := RegExMatch(OutputVar, mm, mattch)
;var1 := RegExMatch(OutputVar, "%mm%([a-zA-Z0-9{7}])", match)
;if (match2 != "М" && match1 < 10)
;MsgBox % mattch1 "`n" mattch "`n" mattch3 "`n var1=" var1 "`n" mm

    
   ;MsgBox % obj[A_Index - 1][2]
   global sid := obj[A_Index - 1][22]
   global folder := obj[A_Index - 1][26]
   hash := obj[A_Index - 1][0]
   action := "?action=getfiles&hash=" hash 
   
   Process, Exist, uTorrent.exe
status = %ErrorLevel% 
if status = 0
   {
run, "C:\staff\margin\margin hsi.exe" "C:\staff\margin\destroy margin 0.hss" ; убрать кусок отрезаного от приложений экрана
Process, close, uTorrent_osd.exe
ExitApp
}
   
   
   HTTP.Open("GET", url action token, false)
   HTTP.SetCredentials(user, pass, 0)
   HTTP.Send()
   Body := HTTP.ResponseBody
   pArr := ComObjValue(Body)
   cBytes := NumGet(pArr+0, A_PtrSize = 8? 24:16, "uint")
   pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, "ptr")
   JsonString := StrGet(pText, cBytes, "utf-8")
   global file := JS.eval("(" . JsonString . ")").files
   
   
   
   global state = % obj[A_Index - 1][21]
   p = % obj[A_Index - 1][4]/10
   Global n = % obj[A_Index - 1][2]
   s = % obj[A_Index - 1][9]/1000000
   size = % obj[A_Index - 1][3]/1000000
   t = % obj[A_Index - 1][10]/60
   loop % file[1].length
   Global path1 := % folder ; "\" file[1][A_Index-1][0]
   
   loop % file[1].length
{
   If RegexMatch(file[1][A_Index-1][0], "\.(avi|mpg|mp4|mkv)$") 
      Global video := 1
  }
      
    IfInString, path1, %n%
      Global multivideo := 1 
      
   IfnotInString, path1, %n%
      Global multivideo := 0
   
  
   
;Run, % vlc " " urlVlc "?sid=" sid "&file=0" ; A_Index-1
     ; Msgbox play %urlVlc%


var1 := RegExMatch(p, "(.*)\.", match)
if t contains -
{
var2 := RegExMatch(t, "-(.*)", matchh)
t = 
}

IfNotEqual, match1, 100  
{
    if runonce = 0
    {
    runonce = 1
    
global needy_gui := A_ScreenHeight-17 ; высота гуи
   
    Gui, Show, x1 y%needy_gui%, uTorrent_osd
     run, "C:\staff\margin\margin hsi.exe" "C:\staff\margin\margin bottom 15.hss"
    
}

GuiControl,, MyProgress, %p% ;vPRBAR cFF7200

GuiControl, , Prog,  %n% - %size%мб   скорость %s%мб/с   осталось %matchh1%%t%м   завершено %p%`% %state% ; video= %video% multiornot %multivideo% - %file% %path1%
formattime,date,,dd/MM/yy
GuiControl,, Time, %A_Hour%:%A_Min% %A_DDD% %date% 
;ToolTip, %mattch1%

if reload = 1
        {
        global reload = 0
            break
        }
sleep, 3000
}


/*
 *  ActiveScript for AutoHotkey v1.1
 *
 *  Provides an interface to Active Scripting languages like VBScript and JScript,
 *  without relying on Microsoft's ScriptControl, which is not available to 64-bit
 *  programs.
 *
 *  License: Use, modify and redistribute without limitation, but at your own risk.
 */
class ActiveScript extends ActiveScript._base
{
    __New(Language)
    {
        if this._script := ComObjCreate(Language, ActiveScript.IID)
            this._scriptParse := ComObjQuery(this._script, ActiveScript.IID_Parse)
        if !this._scriptParse
            throw Exception("Invalid language", -1, Language)
        this._site := new ActiveScriptSite(this)
        this._SetScriptSite(this._site.ptr)
        this._InitNew()
        this._objects := {}
        this.Error := ""
        this._dsp := this._GetScriptDispatch()  ; Must be done last.
        try
            if this.ScriptEngine() = "JScript"
                this.SetJScript58()
    }

    SetJScript58()
    {
        static IID_IActiveScriptProperty := "{4954E0D0-FBC7-11D1-8410-006008C3FBFC}"
        if !prop := ComObjQuery(this._script, IID_IActiveScriptProperty)
            return false
        VarSetCapacity(var, 24, 0), NumPut(2, NumPut(3, var, "short") + 6)
        hr := DllCall(NumGet(NumGet(prop+0)+4*A_PtrSize), "ptr", prop, "uint", 0x4000
            , "ptr", 0, "ptr", &var), ObjRelease(prop)
        return hr >= 0
    }
    
    Eval(Code)
    {
        pvar := NumGet(ComObjValue(arr:=ComObjArray(0xC,1)) + 8+A_PtrSize)
        this._ParseScriptText(Code, 0x20, pvar)  ; SCRIPTTEXT_ISEXPRESSION := 0x20
        return arr[0]
    }
    
    Exec(Code)
    {
        this._ParseScriptText(Code, 0x42, 0)  ; SCRIPTTEXT_ISVISIBLE := 2, SCRIPTTEXT_ISPERSISTENT := 0x40
        this._SetScriptState(2)  ; SCRIPTSTATE_CONNECTED := 2
    }
    
    AddObject(Name, DispObj, AddMembers := false)
    {
        static a, supports_dispatch ; Test for built-in IDispatch support.
            := a := ((a:=ComObjArray(0xC,1))[0]:=[42]) && a[0][1]=42
        if IsObject(DispObj) && !(supports_dispatch || ComObjType(DispObj))
            throw Exception("Adding a non-COM object requires AutoHotkey v1.1.17+", -1)
        this._objects[Name] := DispObj
        this._AddNamedItem(Name, AddMembers ? 8 : 2)  ; SCRIPTITEM_ISVISIBLE := 2, SCRIPTITEM_GLOBALMEMBERS := 8
    }
    
    _GetObjectUnk(Name)
    {
        return !IsObject(dsp := this._objects[Name]) ? dsp  ; Pointer
            : ComObjValue(dsp) ? ComObjValue(dsp)  ; ComObject
            : &dsp  ; AutoHotkey object
    }
    
    class _base
    {
        __Call(Method, Params*)
        {
            if ObjHasKey(this, "_dsp")
                try
                    return (this._dsp)[Method](Params*)
                catch e
                    throw Exception(e.Message, -1, e.Extra)
        }
        
        __Get(Property, Params*)
        {
            if ObjHasKey(this, "_dsp")
                try
                    return (this._dsp)[Property, Params*]
                catch e
                    throw Exception(e.Message, -1, e.Extra)
        }
        
        __Set(Property, Params*)
        {
            if ObjHasKey(this, "_dsp")
            {
                Value := Params.Pop()
                try
                    return (this._dsp)[Property, Params*] := Value
                catch e
                    throw Exception(e.Message, -1, e.Extra)
            }
        }
    }
    
    _SetScriptSite(Site)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+3*A_PtrSize), "ptr", p, "ptr", Site)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::SetScriptSite")
    }
    
    _SetScriptState(State)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+5*A_PtrSize), "ptr", p, "int", State)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::SetScriptState")
    }
    
    _AddNamedItem(Name, Flags)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+8*A_PtrSize), "ptr", p, "wstr", Name, "uint", Flags)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::AddNamedItem")
    }
    
    _GetScriptDispatch()
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+10*A_PtrSize), "ptr", p, "ptr", 0, "ptr*", pdsp)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::GetScriptDispatch")
        return ComObject(9, pdsp, 1)
    }
    
    _InitNew()
    {
        hr := DllCall(NumGet(NumGet((p:=this._scriptParse)+0)+3*A_PtrSize), "ptr", p)
        if (hr < 0)
            this._HRFail(hr, "IActiveScriptParse::InitNew")
    }
    
    _ParseScriptText(Code, Flags, pvarResult)
    {
        VarSetCapacity(excp, 8 * A_PtrSize, 0)
        hr := DllCall(NumGet(NumGet((p:=this._scriptParse)+0)+5*A_PtrSize), "ptr", p
            , "wstr", Code, "ptr", 0, "ptr", 0, "ptr", 0, "uptr", 0, "uint", 1
            , "uint", Flags, "ptr", pvarResult, "ptr", 0)
        if (hr < 0)
            this._HRFail(hr, "IActiveScriptParse::ParseScriptText")
    }
    
    _HRFail(hr, what)
    {
        if e := this.Error
        {
            this.Error := ""
            throw Exception("`nError code:`t" this._HRFormat(e.HRESULT)
                . "`nSource:`t`t" e.Source "`nDescription:`t" e.Description
                . "`nLine:`t`t" e.Line "`nColumn:`t`t" e.Column
                . "`nLine text:`t`t" e.LineText, -3)
        }
        throw Exception(what " failed with code " this._HRFormat(hr), -2)
    }
    
    _HRFormat(hr)
    {
        return Format("0x{1:X}", hr & 0xFFFFFFFF)
    }
    
    _OnScriptError(err) ; IActiveScriptError err
    {
        VarSetCapacity(excp, 8 * A_PtrSize, 0)
        DllCall(NumGet(NumGet(err+0)+3*A_PtrSize), "ptr", err, "ptr", &excp) ; GetExceptionInfo
        DllCall(NumGet(NumGet(err+0)+4*A_PtrSize), "ptr", err, "uint*", srcctx, "uint*", srcline, "int*", srccol) ; GetSourcePosition
        DllCall(NumGet(NumGet(err+0)+5*A_PtrSize), "ptr", err, "ptr*", pbstrcode) ; GetSourceLineText
        code := StrGet(pbstrcode, "UTF-16"), DllCall("OleAut32\SysFreeString", "ptr", pbstrcode)
        if fn := NumGet(excp, 6 * A_PtrSize) ; pfnDeferredFillIn
            DllCall(fn, "ptr", &excp)
        wcode := NumGet(excp, 0, "ushort")
        hr := wcode ? 0x80040200 + wcode : NumGet(excp, 7 * A_PtrSize, "uint")
        this.Error := {HRESULT: hr, Line: srcline, Column: srccol, LineText: code}
        static Infos := "Source,Description,HelpFile"
        Loop Parse, % Infos, `,
            if pbstr := NumGet(excp, A_Index * A_PtrSize)
                this.Error[A_LoopField] := StrGet(pbstr, "UTF-16"), DllCall("OleAut32\SysFreeString", "ptr", pbstr)
        return 0x80004001 ; E_NOTIMPL (let Exec/Eval get a fail result)
    }
    
    __Delete()
    {
        if this._script
        {
            DllCall(NumGet(NumGet((p:=this._script)+0)+7*A_PtrSize), "ptr", p)  ; Close
            ObjRelease(this._script)
        }
        if this._scriptParse
            ObjRelease(this._scriptParse)
    }
    
    static IID := "{BB1A2AE1-A4F9-11cf-8F20-00805F2CD064}"
    static IID_Parse := A_PtrSize=8 ? "{C7EF7658-E1EE-480E-97EA-D52CB4D76D17}" : "{BB1A2AE2-A4F9-11cf-8F20-00805F2CD064}"
}

class ActiveScriptSite
{
    __New(Script)
    {
        ObjSetCapacity(this, "_site", 3 * A_PtrSize)
        NumPut(&Script
        , NumPut(ActiveScriptSite._vftable("_vft_w", "31122", 0x100)
        , NumPut(ActiveScriptSite._vftable("_vft", "31125232211", 0)
            , this.ptr := ObjGetAddress(this, "_site"))))
    }
    
    _vftable(Name, PrmCounts, EIBase)
    {
        if p := ObjGetAddress(this, Name)
            return p
        ObjSetCapacity(this, Name, StrLen(PrmCounts) * A_PtrSize)
        p := ObjGetAddress(this, Name)
        Loop Parse, % PrmCounts
        {
            cb := RegisterCallback("_ActiveScriptSite", "F", A_LoopField, A_Index + EIBase)
            NumPut(cb, p + (A_Index-1) * A_PtrSize)
        }
        return p
    }
}

_ActiveScriptSite(this, a1:=0, a2:=0, a3:=0, a4:=0, a5:=0)
{
    Method := A_EventInfo & 0xFF
    if A_EventInfo >= 0x100  ; IActiveScriptSiteWindow
    {
        if Method = 4  ; GetWindow
        {
            NumPut(0, a1+0) ; *phwnd := 0
            return 0 ; S_OK
        }
        if Method = 5  ; EnableModeless
        {
            return 0 ; S_OK
        }
        this -= A_PtrSize     ; Cast to IActiveScriptSite
    }
    ;else: IActiveScriptSite
    if Method = 1  ; QueryInterface
    {
        iid := _AS_GUIDToString(a1)
        if (iid = "{00000000-0000-0000-C000-000000000046}"  ; IUnknown
         || iid = "{DB01A1E3-A42B-11cf-8F20-00805F2CD064}") ; IActiveScriptSite
        {
            NumPut(this, a2+0)
            return 0 ; S_OK
        }
        if (iid = "{D10F6761-83E9-11cf-8F20-00805F2CD064}") ; IActiveScriptSiteWindow
        {
            NumPut(this + A_PtrSize, a2+0)
            return 0 ; S_OK
        }
        NumPut(0, a2+0)
        return 0x80004002 ; E_NOINTERFACE
    }
    if Method = 5  ; GetItemInfo
    {
        a1 := StrGet(a1, "UTF-16")
        , (a3 && NumPut(0, a3+0))  ; *ppiunkItem := NULL
        , (a4 && NumPut(0, a4+0))  ; *ppti := NULL
        if (a2 & 1) ; SCRIPTINFO_IUNKNOWN
        {
            if !(unk := Object(NumGet(this + A_PtrSize*2))._GetObjectUnk(a1))
                return 0x8002802B ; TYPE_E_ELEMENTNOTFOUND
            ObjAddRef(unk), NumPut(unk, a3+0)
        }
        return 0 ; S_OK
    }
    if Method = 9  ; OnScriptError
        return Object(NumGet(this + A_PtrSize*2))._OnScriptError(a1)
    
    ; AddRef and Release don't do anything because we want to avoid circular references.
    ; The site and IActiveScript are both released when the AHK script releases its last
    ; reference to the ActiveScript object.
    
    ; All of the other methods don't require implementations.
    return 0x80004001 ; E_NOTIMPL
}

_AS_GUIDToString(pGUID)
{
    VarSetCapacity(String, 38*2)
    DllCall("ole32\StringFromGUID2", "ptr", pGUID, "str", String, "int", 39)
    return String
}

}

sleep 3000

}

}

return 



EncodeInteger( p_value, p_size, p_address, p_offset )
{
	loop, %p_size%
		DllCall( "RtlFillMemory"
			, "uint", p_address+p_offset+A_Index-1
			, "uint", 1
			, "uchar", ( p_value >> ( 8*( A_Index-1 ) ) ) & 0xFF )
}


88 (изменено: OmTatSat, 2016-08-03 10:52:01)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Настройки торрента для просмотра онлайн:
> Preferences > Advanced > bt.prio_first_last_piece - true
Зажать Shift+f2 > Preferences > Advanced > bt.sequential_download - true http://blog.ruzzz.com/2010/02/utorrent- … nload.html
Может кто-то знает ещё настройки для оптимизации просмотра онлайн?

; Допгуи будет сразу автоскрываться если имя скрипта отлично от uTorrent_osd.exe или uTorrent_osd.ahk, ниже вид отвечающего кода
;WinGetActiveTitle, OutputVar
;exe = 1
;ahk = 1
;if OutputVar != uTorrent_osd.exe
;    exe = 0
;if OutputVar != uTorrent_osd.ahk
;    ahk = 0
;activeornot = % exe+ahk
;if activeornot = 0
;global canceldblclk = 1
;
; Прогресс бар запустится только если есть не до конца скачанная загрузка.
; LMB - открыть путь для мульти файловых торрентов и открыть файл для однофайловых. 
; DLMB - запустить stream если один видео файл, открыть допгуи выбора файла если мульти видео файл, если не видео - открыть путь к файл(у|ам). 
; Перемотка в Steam бывает работает не с первого запуска, наверное связано с тем, что не хватает каких-то "служебных" данных видео. 
; Так как программа uTorrent запускает Stream в 2 этапа: 1 нажатие - запускается таймер с надписью "готово через ..." 
; после истечения времени таймера, кнопка "поток" заново появляется. 2 нажатие - запуск stream. DLMB запускает второй этап минуя первый.
; upd. УСТРАНЯЕТСЯ УСТАНОВКОЙ POTPLAYER 1.6.62377 - индексирует недокачанный файл как гомплеер и перемотка работает!)
; RMB - открыть окно программы uTorrent и переместить мышь в окно.
; DRMB - перезагрузить uTorrent (если раздача плохо качается - бывает помогает)
; MMB - пауза/запуск всех торрентов

#NoTrayIcon
#NoEnv
#SingleInstance, force
ComObjError(false) ; убрать вывод ошибок типа HTTP.Send() когда utorrent выключился

global ip := "127.0.0.1"
global port := "8080"
global user := "admin"
global pass := "pass"





SetTitleMatchMode, 2
DetectHiddenWindows, On
Gui, Color, 000000 
Gui, -SysMenu -ToolWindow -Caption -Border +AlwaysOnTop ; (+E0x20 - клик сквозь)
Gui +LastFound 
hWnd:=WinExist()
DllCall("SetClassLong","UInt",hWnd,"Int",-26,"UInt",0x8)
WinSet, Transparent, 200
WinSet, ExStyle, ^0x80,
Gui, Font, s7 q5, Verdana
SysGet, SsW, 16
SysGet, Ssh, 62
Global ssw := SsW
Global ssh := Ssh
global needy_gui := A_ScreenHeight-13 ; высота гуи
global needh_gui2 := A_ScreenHeight-444
needx_text := Ssw-205 ; расположение даты с часами
;needw_text := SsW-100 ; ширина главного текста 

Gui, 1:Add, Text, x1 y-1 w%ssw% h12 Center cf2ee11  BackgroundTrans vProg +0x201, 
Gui, Add, Text, x%needx_text% y-1 w200 h12 right cf2ee11 +0x200 +BackgroundTrans vtime +0x201 ,
Gui, Add, Progress, w%SsW% h1 x0 y11 cBlue vMyProgress +E0x20 
global runonce = 0
global dblclk = 0
Global a := 0
global rundblclk = 0
global canceldblclk = 0
 Global video := 0
 Global multivideo := 0
 Global RowNumber = 0
 global reload := 0
 Global rclick := 0
OnMessage(0x201, "WM_LBUTTONDOWN")
OnMessage(0x203,"WM_LBUTTONDBLCLK")
onmessage(0x207,"WM_MBUTTONDOWN")
onmessage(0x204,"WM_RBUTTONDOWN")
OnMessage(0x206,"WM_RBUTTONDBLCLK")
OnMessage(0x100, "WM_KEYDOWN")

;MsgBox, needw = %needx_text% needh = %needh% h-%ssh%
WM_LBUTTONDBLCLK()
{	
	Global click := 2
    global canceldblclk = 0
   ;ToolTip, % vlc " " urlVlc "?sid=" sid "&file=0"
	;return
      ;MsgBox, multivideo %multivideo% video %video%
  if ((video = 1) & (multivideo = 0)) 
{
   Run, % vlc " " urlVlc "?sid=" sid "&file=0"
   GuiControl, , Prog,  uTorrent буфферизирует видео... 
    Loop
    {
        ;MsgBox, lop
       While (a = 1)
        {
            ;MsgBox, в while
            Global a := 0
           ;Global reload = 1
            return
        }
    ;ToolTip после слипа2
       sleep, 5000
       Run, % vlc " " urlVlc "?sid=" sid "&file=0"

       a = 1
       
    }
    ;MsgBox, multivideo %multivideo% video %video%
    return
}
    
    if ((video = 0) & (multivideo = 0)) 
{
    run, %path1%
        return
}
    if ((video = 0) & (multivideo = 1)) 
{
    run, %path1%
        return
}
    if ((video = 1) & (multivideo = 1)) 
    {
	global dblclk = 1 
fold = %folder%\
Gui,2:default
; Create the ListView with two columns, Name and Size:
Gui, 2:Add, ListView, cf2ee11 Background000000 r23 w600 gMyListView , Выберите файл для Stream просмотра:
Gui, Color, 000000 
Gui, -SysMenu -ToolWindow -Caption -Border +AlwaysOnTop  ; (+E0x20 - клик сквозь)
Gui +LastFound 
WinSet, Transparent, 230
WinSet, ExStyle, ^0x80,
Gui, Font, s7 q5, Verdana
; Gather a list of file names from a folder and put them into the ListView:
;ToolTip, %folder%\*.* %A_MyDocuments%\*.*

 loop % file1[1].length

      LV_Add("", file1[1][A_Index-1][0])


LV_ModifyCol(1, "Sort")  ; 
;LV_ModifyCol(2, "Integer")  ; For sorting purposes, indicate that column 2 is an integer.
; Display the window and return. The script will be notified whenever the user double clicks a row.
Gui, 2:Show, xcenter y%needh_gui2%
SendMode play
MouseMove, 150, 40, 0, 

}


MyListView:
;KeyWait, LButton, D
;While !(GetKeyState("LButton","P"))
Loop
{
    ;ToolTip, canceldblclk %canceldblclk% while a=%a% `n dblclkmylistview = %dblclk% `n rundblclk= %rundblclk% `n ahk %ahk% exe %exe% activeornot %activeornot%
    sleep 100
    
    
    if canceldblclk = 1 
    {
       Gui,2:default
	global RowNumber := LV_GetNext("0")
	;MsgBox клик в пустоту %A_EventInfo%. Text: "%RowNumber%" %b%
	Global a := 1
   ; ToolTip,  a=%a%
	global rundblclk = 0
    global canceldblclk = 0
	Gui, 2:Destroy 
    }
    global canceldblclk = 0
	
    if rundblclk = 1
{
    Gui,2:default
	global RowNumber := LV_GetNext("0")
	Run, % vlc " " urlVlc "?sid=" sid "&file=" RowNumber -1
    ;MsgBox You clicked row number %A_EventInfo%. Text: "%RowNumber%" %b%
	Global a := 1
   ; ToolTip,  a=%a%
	global rundblclk = 0
	Gui, 2:Destroy
	
}
WinGetActiveTitle, OutputVar
exe = 1
ahk = 1
if OutputVar != uTorrent_osd.exe
    exe = 0
if OutputVar != uTorrent_osd.ahk
ahk = 0
activeornot = % exe+ahk
;ToolTip, ahk %ahk% exe %exe% activeornot %activeornot%
if activeornot = 0
global canceldblclk = 1





While (a = 1)
{
    Global a := 0
    return
}
}
return
}

WM_LBUTTONDOWN()
{
	 Global click := 1
   SetTimer, check, -550
   return
 
   check:
   SetTimer, check, off
     Gui,2:default
global RowNumber := LV_GetNext("0")
   
  
   if ((click = 1) & (dblclk = 0) & (multivideo = 0)) 
    run %path%	
     if ((click = 1) & (dblclk = 0) & (multivideo = 1)) 
    run %path1%	
    
   if ((click = 1) & (dblclk = 1) & (global RowNumber != 0)) 
global rundblclk = 1
;if ((click = 1) & (dblclk = 1) & (global RowNumber = 0)) 
;global canceldblclk = 1

   ; MsgBox, dblclkcheck = %dblclk% `n click= %click% `n RowNumber= %RowNumber% `n canceldblclk= %canceldblclk%
      return
  
}






WM_MBUTTONDOWN()
{
    global reload = 1
    WinGet, utid, ID,  / ahk_exe uTorrent.exe
   ;ToolTip, %state%
       if state = Загрузка
    {
      DllCall( "PostMessage", UInt,utid, UInt,0x111, UInt,62, Int,0 ) ; pause https://autohotkey.com/board/topic/46880-utorrent-wm-command-wparam-values-for-menu-items/
      GuiControl, , Prog,  Загрузка останавлливается...
      
    }
    if state = [П] Загружается
    {
      DllCall( "PostMessage", UInt,utid, UInt,0x111, UInt,62, Int,0 ) ; pause https://autohotkey.com/board/topic/46880-utorrent-wm-command-wparam-values-for-menu-items/
      GuiControl, , Prog,  Загрузка останавлливается...
      
    }
if state = Пауза
    {
 DllCall( "PostMessage", UInt,utid, UInt,0x111, UInt,61, Int,0 ) ; resume
 GuiControl, , Prog,  Загрузка востанавлливается... 
 
   }
}


WM_RBUTTONDBLCLK()
{
Global rclick = 2
if (rclick = 2)
{
    GuiControl, , Prog,  uTorrent перезагружается... 
    WinMenuSelectItem, ahk_class µTorrent4823DF041B09,, Файл, Выход
    Loop
    {
        
       While (a = 1)
        {
            
            Global a := 0
           Global reload = 1
            return
        }
    ;ToolTip после слипа2
       sleep, 15000
       run, C:\Program Files (x86)\uTorrent\uTorrent.exe /MINIMIZED
       sleep, 7000
       a = 1
       rclick = 0
    }

}
    
}


WM_RBUTTONDOWN()
{
   Global rclick = 1
   SetTimer, checkr, 250
   return
 
   checkr:
   SetTimer, checkr, off
 ;MsgBox, %rclick%

   if (rclick = 1)
    {
       winactivate, / ahk_exe uTorrent.exe
    WinGetpos, utx, uty, , , / ahk_exe uTorrent.exe
    MouseMove, utx+100, uty+100, 0
    rclick = 0
}
return

	}


Loop
{


url := "http://" ip ":" port "/gui/"
global vlc := "C:\Program Files\DAUM\PotPlayer\PotPlayerMini64.exe"
;global vlc := "C:\Program Files (x86)\PotPlayer\PotPlayerMini.exe"
global urlVlc := "http://" ip ":" port "/proxy"
tokenUrl := url "token.html"
action := "?list=1"
HTTP := ComObjCreate("WinHTTP.WinHTTPRequest.5.1")

Process, Exist, uTorrent.exe
status = %ErrorLevel% 
if status = 0
   {
run, "C:\staff\margin\margin hsi.exe" "C:\staff\margin\destroy margin 0.hss" ; убрать кусок отрезаного от приложений экрана
Process, close, uTorrent_osd.exe
ExitApp
}

HTTP.Open("GET", tokenUrl, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
token := "&token=" RegExReplace(HTTP.ResponseText, "<.+?>")
HTTP.Open("GET", url action token, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
Body := HTTP.ResponseBody
pArr := ComObjValue(Body)
cBytes := NumGet(pArr+0, A_PtrSize = 8? 24:16, "uint")
pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, "ptr")
;MsgBox, % StrGet(pText, cBytes, "utf-8") 
;msgbox % HTTP.ResponseText
JsonString := StrGet(pText, cBytes, "utf-8")
JS := new ActiveScript("JScript")
JS.eval("delete ActiveXObject; delete GetObject;") 
ComObjError(false)
obj := JS.eval("(" . JsonString . ")").torrents
SetFormat,Float,0.1
{
    
    
   
    
Loop % obj.length
{
            
        Global video := 0
        ;ToolTip, reload %reload%
        ;Sleep, 1000
        if reload = 1
        {
            global reload := 0
            break
        }
        

;global multiornot := % obj[A_Index - 1][23]   ; ([a-zA-Z0-9{7}])'', match)
  ;  global mm := % multiornot ",([0-9])"
  ;  ToolTip, mm = %mm%
  ;  OutputVar := % StrGet(pText, cBytes, "utf-8") 
;OutputVar := "12.456 h/ 5673 567-"
;var1 := RegExMatch(OutputVar, mm, mattch)
;var1 := RegExMatch(OutputVar, "%mm%([a-zA-Z0-9{7}])", match)
;if (match2 != "М" && match1 < 10)
;MsgBox % mattch1 "`n" mattch "`n" mattch3 "`n var1=" var1 "`n" mm

    
   ;MsgBox % obj[A_Index - 1][2]
   global sid := obj[A_Index - 1][22]
   global folder := obj[A_Index - 1][26]
   hash := obj[A_Index - 1][0]
   action := "?action=getfiles&hash=" hash 
   
   Process, Exist, uTorrent.exe
status = %ErrorLevel% 
if status = 0
   {
run, "C:\staff\margin\margin hsi.exe" "C:\staff\margin\destroy margin 0.hss" ; убрать кусок отрезаного от приложений экрана
Process, close, uTorrent_osd.exe
ExitApp
   }
    
   
   HTTP.Open("GET", url action token, false)
   HTTP.SetCredentials(user, pass, 0)
   HTTP.Send()
   Body := HTTP.ResponseBody
   pArr := ComObjValue(Body)
   cBytes := NumGet(pArr+0, A_PtrSize = 8? 24:16, "uint")
   pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, "ptr")
   JsonString := StrGet(pText, cBytes, "utf-8")
   file := JS.eval("(" . JsonString . ")").files
    global file1 := JS.eval("(" . JsonString . ")").files
    p = % obj[A_Index - 1][4]/10
   
   
   IfNotEqual, p, 100.0  ; отображение только недокачанных торрентов
{
   global state = % obj[A_Index - 1][21]
  
   Global n = % obj[A_Index - 1][2]
 
   size = % obj[A_Index - 1][3]/1000000 "мб"
   t = % obj[A_Index - 1][10]/60
   loop % file[1].length
{
   Global path1 := % folder ; "\" file[1][A_Index-1][0]
   Global path := % folder "\" file[1][A_Index-1][0]
}

   loop % file[1].length
{
   If RegexMatch(file[1][A_Index-1][0], "\.(avi|mpg|mp4|mkv)$") 
      Global video := 1
  }
      
    IfInString, path1, %n%
      Global multivideo := 1 
      
   IfnotInString, path1, %n%
      Global multivideo := 0
   
  
   
;Run, % vlc " " urlVlc "?sid=" sid "&file=0" ; A_Index-1
     ; Msgbox play %urlVlc%


;var1 := RegExMatch(p, "(.*)\.", match)
;if t contains -


;IfInString, t, -
;{
;var2 := RegExMatch(t, "-(.*)", matchh)
;t = 
;}
;IfNotInString, t, -
;  matchh1 =   
;IfNotEqual, match1, 100 




;tnorm := RegExReplace(t, "\D")

;MsgBox % var

;MsgBox % NewVar




     
        if runonce = 0
        {
        runonce = 1
        ;global needy_gui := A_ScreenHeight-13 ; высота гуи
       
        Gui, Show, x1 y%needy_gui%, uTorrent_osd
         run, "C:\staff\margin\margin hsi.exe" "C:\staff\margin\margin bottom 15.hss"
        
        }
;-------------------------------------
;-----------------------------размер
SetFormat, FloatFast, 0.2
if size > 1000
    mbgb = % obj[A_Index - 1][3]/1000000000  "гб"
else
    mbgb = % obj[A_Index - 1][3]/1000000 "мб"
;-------------------------------------
;------------------------------------

;-------------------------------------
;-----------------------------осталось
SetFormat, FloatFast, 0.2
RegExMatch(t, "\d+", tnorm)



        If tnorm > 60
        {
            hournotnorm = % tnorm/60
            RegExMatch(hournotnorm, "(.*)\.", hour)
            hour = % hour1 ":"
        SetFormat, FloatFast, 0.2
        RegExMatch(tnorm/60, "\.(\d+)", minnogood)

        minn = % minnogood*60/100
        RegExMatch(minn, "\.(..)", min)
        ;MsgBox, = %min1%
        
       ; ToolTip, hournotnorm %hournotnorm% hour %hour% hour1 %hour1% tnorm %tnorm% tnotnorm %tnotnorm% tnorm %tnorm% minnogood1 %minnogood1%
        }
    else
    {
        hour =
        RegExMatch(t, "\d+", tnorm)
   ; SetFormat, FloatFast, 0.2
    RegExMatch(tnorm/60, "\.([0-9])", minnogood)
;ToolTip tnorm %tnorm% minnogood %minnogood%
    min1 = % tnorm
    ;RegExMatch(minn, "\.(..)", min)
  ;  ToolTip, min %min1%
   ; ToolTip, hournotnorm %hournotnorm% hour %hour% hour1 %hour1% tnorm1 %tnorm1% tnotnorm %tnotnorm%
    }
    ;---------------------------------------------------------------------------------------
    ;-----------------------------осталось--------------------------------------------------   
    
    
     ;---------------------------------------------------------------------------------------
    ;-----------------------------скорость--------------------------------------------------
   ; s = % obj[A_Index - 1][9]/1000000
   SetFormat, FloatFast, 0.2
   s = % obj[A_Index - 1][9]/1000000 "мб/с"
   if s < 1
    {
    SetFormat, FloatFast, 0.0
    s = % obj[A_Index - 1][9]/1000 "кб/с"
    }
    ; ---------------------------------------------------------Защита от зависания скачки
    
    if ((s = "0кб/с") & (state != "Пауза"))
    {
        ;MsgBox
        RunWait, ping.exe www.microsoft.com,, Hide UseErrorlevel
        if !Errorlevel = 1
            ;ToolTip, % !Errorlevel
        prepare_to_reload += 1
       }
    
    
    if s != 0кб/с
        ;MsgBox
        prepare_to_reload = 0
    
    if prepare_to_reload = 50
        {
    GuiControl, , Prog,  uTorrent перезагружается... 
    WinMenuSelectItem, ahk_class µTorrent4823DF041B09,, Файл, Выход
    prepare_to_reload = 0
    Loop
    {
        
       While (a = 1)
        {
           ; ToolTip после слипа2
            Global a = 0
           ; ToolTip, a %a%
          reload
            return
        }
    ;ToolTip после слипа2
       sleep, 15000
       run, C:\Program Files (x86)\uTorrent\uTorrent.exe /MINIMIZED
       sleep, 7000
       global a = 1
       ;ToolTip, a %a%
       ;Sleep, 1000
       
        
    }
}
        
 ;ToolTip, s = %s% prepare_to_reload %prepare_to_reload% state %state%
    ; --------------------------------------------------------------------------------
SetFormat, FloatFast, 0.1
GuiControl,, MyProgress, %p% ;vPRBAR cFF7200
 
GuiControl, , Prog,  %n% - %mbgb%  скорость %s%   осталось %hour%%min1%м  завершено %p%`% %state%  ; video= %video% multiornot %multivideo% - %file% %path1%
formattime,date,,dd/MM/yy
GuiControl,, Time, %A_Hour%:%A_Min% %A_DDD% %date% 
;ToolTip, %mattch1%


      if reload = 1
        {
            ;MsgBox, reload 1
        global reload := 0
            break
        }  
 
sleep, 2000

Process, Exist, uTorrent.exe
status = %ErrorLevel% 
if status = 0
   {
run, "C:\staff\margin\margin hsi.exe" "C:\staff\margin\destroy margin 0.hss" ; убрать кусок отрезаного от приложений экрана
Process, close, uTorrent_osd.exe
ExitApp
}
;}




















/*
 *  ActiveScript for AutoHotkey v1.1
 *
 *  Provides an interface to Active Scripting languages like VBScript and JScript,
 *  without relying on Microsoft's ScriptControl, which is not available to 64-bit
 *  programs.
 *
 *  License: Use, modify and redistribute without limitation, but at your own risk.
 */
class ActiveScript extends ActiveScript._base
{
    __New(Language)
    {
        if this._script := ComObjCreate(Language, ActiveScript.IID)
            this._scriptParse := ComObjQuery(this._script, ActiveScript.IID_Parse)
        if !this._scriptParse
            throw Exception("Invalid language", -1, Language)
        this._site := new ActiveScriptSite(this)
        this._SetScriptSite(this._site.ptr)
        this._InitNew()
        this._objects := {}
        this.Error := ""
        this._dsp := this._GetScriptDispatch()  ; Must be done last.
        try
            if this.ScriptEngine() = "JScript"
                this.SetJScript58()
    }

    SetJScript58()
    {
        static IID_IActiveScriptProperty := "{4954E0D0-FBC7-11D1-8410-006008C3FBFC}"
        if !prop := ComObjQuery(this._script, IID_IActiveScriptProperty)
            return false
        VarSetCapacity(var, 24, 0), NumPut(2, NumPut(3, var, "short") + 6)
        hr := DllCall(NumGet(NumGet(prop+0)+4*A_PtrSize), "ptr", prop, "uint", 0x4000
            , "ptr", 0, "ptr", &var), ObjRelease(prop)
        return hr >= 0
    }
    
    Eval(Code)
    {
        pvar := NumGet(ComObjValue(arr:=ComObjArray(0xC,1)) + 8+A_PtrSize)
        this._ParseScriptText(Code, 0x20, pvar)  ; SCRIPTTEXT_ISEXPRESSION := 0x20
        return arr[0]
    }
    
    Exec(Code)
    {
        this._ParseScriptText(Code, 0x42, 0)  ; SCRIPTTEXT_ISVISIBLE := 2, SCRIPTTEXT_ISPERSISTENT := 0x40
        this._SetScriptState(2)  ; SCRIPTSTATE_CONNECTED := 2
    }
    
    AddObject(Name, DispObj, AddMembers := false)
    {
        static a, supports_dispatch ; Test for built-in IDispatch support.
            := a := ((a:=ComObjArray(0xC,1))[0]:=[42]) && a[0][1]=42
        if IsObject(DispObj) && !(supports_dispatch || ComObjType(DispObj))
            throw Exception("Adding a non-COM object requires AutoHotkey v1.1.17+", -1)
        this._objects[Name] := DispObj
        this._AddNamedItem(Name, AddMembers ? 8 : 2)  ; SCRIPTITEM_ISVISIBLE := 2, SCRIPTITEM_GLOBALMEMBERS := 8
    }
    
    _GetObjectUnk(Name)
    {
        return !IsObject(dsp := this._objects[Name]) ? dsp  ; Pointer
            : ComObjValue(dsp) ? ComObjValue(dsp)  ; ComObject
            : &dsp  ; AutoHotkey object
    }
    
    class _base
    {
        __Call(Method, Params*)
        {
            if ObjHasKey(this, "_dsp")
                try
                    return (this._dsp)[Method](Params*)
                catch e
                    throw Exception(e.Message, -1, e.Extra)
        }
        
        __Get(Property, Params*)
        {
            if ObjHasKey(this, "_dsp")
                try
                    return (this._dsp)[Property, Params*]
                catch e
                    throw Exception(e.Message, -1, e.Extra)
        }
        
        __Set(Property, Params*)
        {
            if ObjHasKey(this, "_dsp")
            {
                Value := Params.Pop()
                try
                    return (this._dsp)[Property, Params*] := Value
                catch e
                    throw Exception(e.Message, -1, e.Extra)
            }
        }
    }
    
    _SetScriptSite(Site)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+3*A_PtrSize), "ptr", p, "ptr", Site)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::SetScriptSite")
    }
    
    _SetScriptState(State)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+5*A_PtrSize), "ptr", p, "int", State)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::SetScriptState")
    }
    
    _AddNamedItem(Name, Flags)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+8*A_PtrSize), "ptr", p, "wstr", Name, "uint", Flags)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::AddNamedItem")
    }
    
    _GetScriptDispatch()
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+10*A_PtrSize), "ptr", p, "ptr", 0, "ptr*", pdsp)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::GetScriptDispatch")
        return ComObject(9, pdsp, 1)
    }
    
    _InitNew()
    {
        hr := DllCall(NumGet(NumGet((p:=this._scriptParse)+0)+3*A_PtrSize), "ptr", p)
        if (hr < 0)
            this._HRFail(hr, "IActiveScriptParse::InitNew")
    }
    
    _ParseScriptText(Code, Flags, pvarResult)
    {
        VarSetCapacity(excp, 8 * A_PtrSize, 0)
        hr := DllCall(NumGet(NumGet((p:=this._scriptParse)+0)+5*A_PtrSize), "ptr", p
            , "wstr", Code, "ptr", 0, "ptr", 0, "ptr", 0, "uptr", 0, "uint", 1
            , "uint", Flags, "ptr", pvarResult, "ptr", 0)
        if (hr < 0)
            this._HRFail(hr, "IActiveScriptParse::ParseScriptText")
    }
    
    _HRFail(hr, what)
    {
        if e := this.Error
        {
            this.Error := ""
            throw Exception("`nError code:`t" this._HRFormat(e.HRESULT)
                . "`nSource:`t`t" e.Source "`nDescription:`t" e.Description
                . "`nLine:`t`t" e.Line "`nColumn:`t`t" e.Column
                . "`nLine text:`t`t" e.LineText, -3)
        }
        throw Exception(what " failed with code " this._HRFormat(hr), -2)
    }
    
    _HRFormat(hr)
    {
        return Format("0x{1:X}", hr & 0xFFFFFFFF)
    }
    
    _OnScriptError(err) ; IActiveScriptError err
    {
        VarSetCapacity(excp, 8 * A_PtrSize, 0)
        DllCall(NumGet(NumGet(err+0)+3*A_PtrSize), "ptr", err, "ptr", &excp) ; GetExceptionInfo
        DllCall(NumGet(NumGet(err+0)+4*A_PtrSize), "ptr", err, "uint*", srcctx, "uint*", srcline, "int*", srccol) ; GetSourcePosition
        DllCall(NumGet(NumGet(err+0)+5*A_PtrSize), "ptr", err, "ptr*", pbstrcode) ; GetSourceLineText
        code := StrGet(pbstrcode, "UTF-16"), DllCall("OleAut32\SysFreeString", "ptr", pbstrcode)
        if fn := NumGet(excp, 6 * A_PtrSize) ; pfnDeferredFillIn
            DllCall(fn, "ptr", &excp)
        wcode := NumGet(excp, 0, "ushort")
        hr := wcode ? 0x80040200 + wcode : NumGet(excp, 7 * A_PtrSize, "uint")
        this.Error := {HRESULT: hr, Line: srcline, Column: srccol, LineText: code}
        static Infos := "Source,Description,HelpFile"
        Loop Parse, % Infos, `,
            if pbstr := NumGet(excp, A_Index * A_PtrSize)
                this.Error[A_LoopField] := StrGet(pbstr, "UTF-16"), DllCall("OleAut32\SysFreeString", "ptr", pbstr)
        return 0x80004001 ; E_NOTIMPL (let Exec/Eval get a fail result)
    }
    
    __Delete()
    {
        if this._script
        {
            DllCall(NumGet(NumGet((p:=this._script)+0)+7*A_PtrSize), "ptr", p)  ; Close
            ObjRelease(this._script)
        }
        if this._scriptParse
            ObjRelease(this._scriptParse)
    }
    
    static IID := "{BB1A2AE1-A4F9-11cf-8F20-00805F2CD064}"
    static IID_Parse := A_PtrSize=8 ? "{C7EF7658-E1EE-480E-97EA-D52CB4D76D17}" : "{BB1A2AE2-A4F9-11cf-8F20-00805F2CD064}"
}

class ActiveScriptSite
{
    __New(Script)
    {
        ObjSetCapacity(this, "_site", 3 * A_PtrSize)
        NumPut(&Script
        , NumPut(ActiveScriptSite._vftable("_vft_w", "31122", 0x100)
        , NumPut(ActiveScriptSite._vftable("_vft", "31125232211", 0)
            , this.ptr := ObjGetAddress(this, "_site"))))
    }
    
    _vftable(Name, PrmCounts, EIBase)
    {
        if p := ObjGetAddress(this, Name)
            return p
        ObjSetCapacity(this, Name, StrLen(PrmCounts) * A_PtrSize)
        p := ObjGetAddress(this, Name)
        Loop Parse, % PrmCounts
        {
            cb := RegisterCallback("_ActiveScriptSite", "F", A_LoopField, A_Index + EIBase)
            NumPut(cb, p + (A_Index-1) * A_PtrSize)
        }
        return p
    }
}

_ActiveScriptSite(this, a1:=0, a2:=0, a3:=0, a4:=0, a5:=0)
{
    Method := A_EventInfo & 0xFF
    if A_EventInfo >= 0x100  ; IActiveScriptSiteWindow
    {
        if Method = 4  ; GetWindow
        {
            NumPut(0, a1+0) ; *phwnd := 0
            return 0 ; S_OK
        }
        if Method = 5  ; EnableModeless
        {
            return 0 ; S_OK
        }
        this -= A_PtrSize     ; Cast to IActiveScriptSite
    }
    ;else: IActiveScriptSite
    if Method = 1  ; QueryInterface
    {
        iid := _AS_GUIDToString(a1)
        if (iid = "{00000000-0000-0000-C000-000000000046}"  ; IUnknown
         || iid = "{DB01A1E3-A42B-11cf-8F20-00805F2CD064}") ; IActiveScriptSite
        {
            NumPut(this, a2+0)
            return 0 ; S_OK
        }
        if (iid = "{D10F6761-83E9-11cf-8F20-00805F2CD064}") ; IActiveScriptSiteWindow
        {
            NumPut(this + A_PtrSize, a2+0)
            return 0 ; S_OK
        }
        NumPut(0, a2+0)
        return 0x80004002 ; E_NOINTERFACE
    }
    if Method = 5  ; GetItemInfo
    {
        a1 := StrGet(a1, "UTF-16")
        , (a3 && NumPut(0, a3+0))  ; *ppiunkItem := NULL
        , (a4 && NumPut(0, a4+0))  ; *ppti := NULL
        if (a2 & 1) ; SCRIPTINFO_IUNKNOWN
        {
            if !(unk := Object(NumGet(this + A_PtrSize*2))._GetObjectUnk(a1))
                return 0x8002802B ; TYPE_E_ELEMENTNOTFOUND
            ObjAddRef(unk), NumPut(unk, a3+0)
        }
        return 0 ; S_OK
    }
    if Method = 9  ; OnScriptError
        return Object(NumGet(this + A_PtrSize*2))._OnScriptError(a1)
    
    ; AddRef and Release don't do anything because we want to avoid circular references.
    ; The site and IActiveScript are both released when the AHK script releases its last
    ; reference to the ActiveScript object.
    
    ; All of the other methods don't require implementations.
    return 0x80004001 ; E_NOTIMPL
}

_AS_GUIDToString(pGUID)
{
    VarSetCapacity(String, 38*2)
    DllCall("ole32\StringFromGUID2", "ptr", pGUID, "str", String, "int", 39)
    return String
}

}

;sleep 1000

}

}
} ;
return 



EncodeInteger( p_value, p_size, p_address, p_offset )
{
	loop, %p_size%
		DllCall( "RtlFillMemory"
			, "uint", p_address+p_offset+A_Index-1
			, "uint", 1
			, "uchar", ( p_value >> ( 8*( A_Index-1 ) ) ) & 0xFF )
}


#IfWinActive  ahk_exe uTorrent.exe
~LButton::
;if GetTextUnderMouse() = Выход
{
CoordMode, Mouse, Screen
MouseGetPos, m_x, m_y, m_hw_target
SendMessage, 0x84,, ( m_y << 16 )|m_x,, ahk_id %m_hw_target%
;ToolTip, % errorlevel
if errorlevel = 1
{
    ;MsgBox, % GetTextUnderMouse()
   
    if GetTextUnderMouse() = "Выход"
    {
         run, "C:\staff\margin\margin hsi.exe" "C:\staff\margin\destroy margin 0.hss" ; убрать кусок отрезаного от приложений экрана
      WinMenuSelectItem, ahk_class µTorrent4823DF041B09,, Файл, Выход
          exitapp  
    }
    
	GetTextUnderMouse() {
	Acc := Acc_ObjectFromPoint(child)
	try value := Acc.accValue(child)
	if Not value
		try value := Acc.accName(child)
	return value
    
    
}
    
    
    
    
   
}

}


























































; http://www.autohotkey.com/board/topic/77303-acc-library-ahk-l-updated-09272012/
; https://dl.dropbox.com/u/47573473/Web%20Server/AHK_L/Acc.ahk
;------------------------------------------------------------------------------
; Acc.ahk Standard Library
; by Sean
; Updated by jethrow:
; 	Modified ComObjEnwrap params from (9,pacc) --> (9,pacc,1)
; 	Changed ComObjUnwrap to ComObjValue in order to avoid AddRef (thanks fincs)
; 	Added Acc_GetRoleText & Acc_GetStateText
; 	Added additional functions - commented below
; 	Removed original Acc_Children function
; last updated 2/25/2010
;------------------------------------------------------------------------------

Acc_Init()
{
	Static	h
	If Not	h
		h:=DllCall("LoadLibrary","Str","oleacc","Ptr")
}
Acc_ObjectFromEvent(ByRef _idChild_, hWnd, idObject, idChild)
{
	Acc_Init()
	If	DllCall("oleacc\AccessibleObjectFromEvent", "Ptr", hWnd, "UInt", idObject, "UInt", idChild, "Ptr*", pacc, "Ptr", VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&varChild)=0
	Return	ComObjEnwrap(9,pacc,1), _idChild_:=NumGet(varChild,8,"UInt")
}

Acc_ObjectFromPoint(ByRef _idChild_ = "", x = "", y = "")
{
	Acc_Init()
	If	DllCall("oleacc\AccessibleObjectFromPoint", "Int64", x==""||y==""?0*DllCall("GetCursorPos","Int64*",pt)+pt:x&0xFFFFFFFF|y<<32, "Ptr*", pacc, "Ptr", VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&varChild)=0
	Return	ComObjEnwrap(9,pacc,1), _idChild_:=NumGet(varChild,8,"UInt")
}

Acc_ObjectFromWindow(hWnd, idObject = -4)
{
	Acc_Init()
	If	DllCall("oleacc\AccessibleObjectFromWindow", "Ptr", hWnd, "UInt", idObject&=0xFFFFFFFF, "Ptr", -VarSetCapacity(IID,16)+NumPut(idObject==0xFFFFFFF0?0x46000000000000C0:0x719B3800AA000C81,NumPut(idObject==0xFFFFFFF0?0x0000000000020400:0x11CF3C3D618736E0,IID,"Int64"),"Int64"), "Ptr*", pacc)=0
	Return	ComObjEnwrap(9,pacc,1)
}

Acc_WindowFromObject(pacc)
{
	If	DllCall("oleacc\WindowFromAccessibleObject", "Ptr", IsObject(pacc)?ComObjValue(pacc):pacc, "Ptr*", hWnd)=0
	Return	hWnd
}

Acc_GetRoleText(nRole)
{
	nSize := DllCall("oleacc\GetRoleText", "Uint", nRole, "Ptr", 0, "Uint", 0)
	VarSetCapacity(sRole, (A_IsUnicode?2:1)*nSize)
	DllCall("oleacc\GetRoleText", "Uint", nRole, "str", sRole, "Uint", nSize+1)
	Return	sRole
}

Acc_GetStateText(nState)
{
	nSize := DllCall("oleacc\GetStateText", "Uint", nState, "Ptr", 0, "Uint", 0)
	VarSetCapacity(sState, (A_IsUnicode?2:1)*nSize)
	DllCall("oleacc\GetStateText", "Uint", nState, "str", sState, "Uint", nSize+1)
	Return	sState
}

Acc_SetWinEventHook(eventMin, eventMax, pCallback)
{
	Return	DllCall("SetWinEventHook", "Uint", eventMin, "Uint", eventMax, "Uint", 0, "Ptr", pCallback, "Uint", 0, "Uint", 0, "Uint", 0)
}

Acc_UnhookWinEvent(hHook)
{
	Return	DllCall("UnhookWinEvent", "Ptr", hHook)
}
/*	Win Events:
	pCallback := RegisterCallback("WinEventProc")
	WinEventProc(hHook, event, hWnd, idObject, idChild, eventThread, eventTime)
	{
		Critical
		Acc := Acc_ObjectFromEvent(_idChild_, hWnd, idObject, idChild)
		; Code Here:
	}
*/

; Written by jethrow
Acc_Role(Acc, ChildId=0) {
	try return ComObjType(Acc,"Name")="IAccessible"?Acc_GetRoleText(Acc.accRole(ChildId)):"invalid object"
}
Acc_State(Acc, ChildId=0) {
	try return ComObjType(Acc,"Name")="IAccessible"?Acc_GetStateText(Acc.accState(ChildId)):"invalid object"
}
Acc_Location(Acc, ChildId=0, byref Position="") { ; adapted from Sean's code
	try Acc.accLocation(ComObj(0x4003,&x:=0), ComObj(0x4003,&y:=0), ComObj(0x4003,&w:=0), ComObj(0x4003,&h:=0), ChildId)
	catch
		return
	Position := "x" NumGet(x,0,"int") " y" NumGet(y,0,"int") " w" NumGet(w,0,"int") " h" NumGet(h,0,"int")
	return	{x:NumGet(x,0,"int"), y:NumGet(y,0,"int"), w:NumGet(w,0,"int"), h:NumGet(h,0,"int")}
}
Acc_Parent(Acc) { 
	try parent:=Acc.accParent
	return parent?Acc_Query(parent):
}
Acc_Child(Acc, ChildId=0) {
	try child:=Acc.accChild(ChildId)
	return child?Acc_Query(child):
}
Acc_Query(Acc) { ; thanks Lexikos - www.autohotkey.com/forum/viewtopic.php?t=81731&p=509530#509530
	try return ComObj(9, ComObjQuery(Acc,"{618736e0-3c3d-11cf-810c-00aa00389b71}"), 1)
}
Acc_Error(p="") {
	static setting:=0
	return p=""?setting:setting:=p
}
Acc_Children(Acc) {
	if ComObjType(Acc,"Name") != "IAccessible"
		ErrorLevel := "Invalid IAccessible Object"
	else {
		Acc_Init(), cChildren:=Acc.accChildCount, Children:=[]
		if DllCall("oleacc\AccessibleChildren", "Ptr",ComObjValue(Acc), "Int",0, "Int",cChildren, "Ptr",VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&varChildren, "Int*",cChildren)=0 {
			Loop %cChildren%
				i:=(A_Index-1)*(A_PtrSize*2+8)+8, child:=NumGet(varChildren,i), Children.Insert(NumGet(varChildren,i-8)=9?Acc_Query(child):child), NumGet(varChildren,i-8)=9?ObjRelease(child):
			return Children.MaxIndex()?Children:
		} else
			ErrorLevel := "AccessibleChildren DllCall Failed"
	}
	if Acc_Error()
		throw Exception(ErrorLevel,-1)
}
Acc_ChildrenByRole(Acc, Role) {
	if ComObjType(Acc,"Name")!="IAccessible"
		ErrorLevel := "Invalid IAccessible Object"
	else {
		Acc_Init(), cChildren:=Acc.accChildCount, Children:=[]
		if DllCall("oleacc\AccessibleChildren", "Ptr",ComObjValue(Acc), "Int",0, "Int",cChildren, "Ptr",VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&varChildren, "Int*",cChildren)=0 {
			Loop %cChildren% {
				i:=(A_Index-1)*(A_PtrSize*2+8)+8, child:=NumGet(varChildren,i)
				if NumGet(varChildren,i-8)=9
					AccChild:=Acc_Query(child), ObjRelease(child), Acc_Role(AccChild)=Role?Children.Insert(AccChild):
				else
					Acc_Role(Acc, child)=Role?Children.Insert(child):
			}
			return Children.MaxIndex()?Children:, ErrorLevel:=0
		} else
			ErrorLevel := "AccessibleChildren DllCall Failed"
	}
	if Acc_Error()
		throw Exception(ErrorLevel,-1)
}
Acc_Get(Cmd, ChildPath="", ChildID=0, WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	static properties := {Action:"DefaultAction", DoAction:"DoDefaultAction", Keyboard:"KeyboardShortcut"}
	AccObj :=   IsObject(WinTitle)? WinTitle
			:   Acc_ObjectFromWindow( WinExist(WinTitle, WinText, ExcludeTitle, ExcludeText), 0 )
	if ComObjType(AccObj, "Name") != "IAccessible"
		ErrorLevel := "Could not access an IAccessible Object"
	else {
		StringReplace, ChildPath, ChildPath, _, %A_Space%, All
		AccError:=Acc_Error(), Acc_Error(true)
		Loop Parse, ChildPath, ., %A_Space%
			try {
				if A_LoopField is digit
					Children:=Acc_Children(AccObj), m2:=A_LoopField ; mimic "m2" output in else-statement
				else
					RegExMatch(A_LoopField, "(\D*)(\d*)", m), Children:=Acc_ChildrenByRole(AccObj, m1), m2:=(m2?m2:1)
				if Not Children.HasKey(m2)
					throw
				AccObj := Children[m2]
			} catch {
				ErrorLevel:="Cannot access ChildPath Item #" A_Index " -> " A_LoopField, Acc_Error(AccError)
				if Acc_Error()
					throw Exception("Cannot access ChildPath Item", -1, "Item #" A_Index " -> " A_LoopField)
				return
			}
		Acc_Error(AccError)
		StringReplace, Cmd, Cmd, %A_Space%, , All
		properties.HasKey(Cmd)? Cmd:=properties[Cmd]:
		try {
			if (Cmd = "Location")
				AccObj.accLocation(ComObj(0x4003,&x:=0), ComObj(0x4003,&y:=0), ComObj(0x4003,&w:=0), ComObj(0x4003,&h:=0), ChildId)
			  , ret_val := "x" NumGet(x,0,"int") " y" NumGet(y,0,"int") " w" NumGet(w,0,"int") " h" NumGet(h,0,"int")
			else if (Cmd = "Object")
				ret_val := AccObj
			else if Cmd in Role,State
				ret_val := Acc_%Cmd%(AccObj, ChildID+0)
			else if Cmd in ChildCount,Selection,Focus
				ret_val := AccObj["acc" Cmd]
			else
				ret_val := AccObj["acc" Cmd](ChildID+0)
		} catch {
			ErrorLevel := """" Cmd """ Cmd Not Implemented"
			if Acc_Error()
				throw Exception("Cmd Not Implemented", -1, Cmd)
			return
		}
		return ret_val, ErrorLevel:=0
	}
	if Acc_Error()
		throw Exception(ErrorLevel,-1)
}

uTorrent положить в C:\Program Files (x86)\uTorrent\ http://forum.script-coding.com/misc.php … download=1
margin распаковать в C:\staff\margin\

Post's attachments

margin.rar 24.7 kb, 2 downloads since 2016-07-18 

You don't have the permssions to download the attachments of this post.

89

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Есть проблема, если в раздаче есть субтитры то номер строки не равняется номеру этого файла в торрент раздаче, может есть идеи как это можно побороть? Может можно как-то получить номер файла в раздаче?

90

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Код из 31 поста должен показывать всё правильно.

91 (изменено: OmTatSat, 2016-08-03 17:04:25)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Malcev, попробовал код с 31ого, то-есть поправил код на LV_Add("", folder "\" file1[1][A_Index-1][0]) было  LV_Add("", file1[1][A_Index-1][0])
Ничего не поменялось, очередность осталась прежней но в списке появились не только названия файлов но и полный путь.
Похоже скрипт добавляет файлы в алфавитном порядке, а в торренте они получают номера вне алфавитного порядка
Вот к примеру раздача https://rutracker.org/forum/viewtopic.php?t=5020380
Попробуйте.
Открываю через торрент первую серию, номер у файла 20. Открываю через скрипт первую серию, номер у файла 0. Если бы название сериала начиналось не с "P" а с буквы после "S" то наверно файлы с папки "subs" были бы первыми, и всё было бы в рабочем виде а так перепуталось всё.

92 (изменено: Malcev, 2016-08-03 16:42:08)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Ну так код из 31 поста это и показывает.
Замените его 2 последние строчки:

   loop % file[1].length
      msgbox % folder "\" file[1][A_Index-1][0] "`nномер " A_Index-1

Во время тестирования вы сразу не поправляйте свой код, а возьмите только мой.
И если с ним всё ок, то ищите ошибку уже в вашем коде.
ЗЫ Ссылка у вас не оформлена.

93

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

OmTatSat проставьте заглавные буквы и точки. Обрамите ссылку кодом URL.

94

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Malcev, действительно ошибка была в использовании

LV_ModifyCol(1, "Sort") 

за комментировал и вроде ок. Спасибо.

95

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

Может возможно скрыть строки в которых не видео файлы, и сохранить правильные номера файлов?

96

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

   loop % file[1].length
   {
      fileName := file[1][A_Index-1][0]
      If RegexMatch(fileName, "\.(avi|mpg|mp4|mkv)$") 
         msgbox % folder "\" fileName "`nномер " A_Index-1
   }

97 (изменено: OmTatSat, 2016-08-04 00:01:52)

Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent

День пытаюсь задать соответствие номера строки и номера файла.
То-есть я щелкаю по 5ой строке, а в ней файл который имеет к примеру 22ой номер, и мне нужно получить 22, причём не хотелось бы чтобы 22 было в названии а чтобы где-то хранилось невидимо для глаза.

Что-то типа:
row1 = 22
row2 = 23
row3 = 26
...


Если использовать

row%A_Index% = %filenumber%

То код не работает если его поместить в if. Пытался добавить global но тогда вообще ругается на

row%A_Index% = %filenumber%


Как можно решить вопрос?

Нашлось решение, запихнул номера в отдельную колонку и скрыл её, чего раньше не додумался.

; Допгуи будет сразу автоскрываться если имя скрипта отлично от uTorrent_osd.exe или uTorrent_osd.ahk, ниже вид отвечающего кода
;WinGetActiveTitle, OutputVar
;exe = 1
;ahk = 1
;if OutputVar != uTorrent_osd.exe
;    exe = 0
;if OutputVar != uTorrent_osd.ahk
;    ahk = 0
;activeornot = % exe+ahk
;if activeornot = 0
;global canceldblclk = 1
;
; Прогресс бар запустится только если есть не до конца скачанная загрузка.
; LMB - открыть путь для мульти файловых торрентов и открыть файл для однофайловых. 
; DLMB - запустить stream если один видео файл, открыть допгуи выбора файла если мульти видео файл, если не видео - открыть путь к файл(у|ам). 
; Перемотка в Steam бывает работает не с первого запуска, наверное связано с тем, что не хватает каких-то "служебных" данных видео. 
; Так как программа uTorrent запускает Stream в 2 этапа: 1 нажатие - запускается таймер с надписью "готово через ..." 
; после истечения времени таймера, кнопка "поток" заново появляется. 2 нажатие - запуск stream. DLMB запускает второй этап минуя первый.
; upd. УСТРАНЯЕТСЯ УСТАНОВКОЙ POTPLAYER 1.6.62377 - индексирует недокачанный файл как гомплеер и перемотка работает!)
; RMB - открыть окно программы uTorrent и переместить мышь в окно.
; DRMB - перезагрузить uTorrent (если раздача плохо качается - бывает помогает)
; MMB - пауза/запуск всех торрентов

#NoTrayIcon
#NoEnv
#SingleInstance, force
ComObjError(false) ; убрать вывод ошибок типа HTTP.Send() когда utorrent выключился

global ip := "127.0.0.1"
global port := "8080"
global user := "admin"
global pass := "pass"





SetTitleMatchMode, 2
DetectHiddenWindows, On
Gui, Color, 000000 
Gui, -SysMenu -ToolWindow -Caption -Border +AlwaysOnTop ; (+E0x20 - клик сквозь)
Gui +LastFound 
hWnd:=WinExist()
DllCall("SetClassLong","UInt",hWnd,"Int",-26,"UInt",0x8)
WinSet, Transparent, 200
WinSet, ExStyle, ^0x80,
Gui, Font, s7 q5, Verdana
SysGet, SsW, 16
SysGet, Ssh, 62
Global ssw := SsW
Global ssh := Ssh
global needy_gui := A_ScreenHeight-13 ; высота гуи
global needh_gui2 := A_ScreenHeight-444
needx_text := Ssw-205 ; расположение даты с часами
;needw_text := SsW-100 ; ширина главного текста 

Gui, 1:Add, Text, x1 y-1 w%ssw% h12 Center cf2ee11  BackgroundTrans vProg +0x201, 
Gui, Add, Text, x%needx_text% y-1 w200 h12 right cf2ee11 +0x200 +BackgroundTrans vtime +0x201 ,
Gui, Add, Progress, w%SsW% h1 x0 y11 cBlue vMyProgress +E0x20 
global runonce = 0
global dblclk = 0
Global a := 0
global rundblclk = 0
global canceldblclk = 0
 Global video := 0
 Global multivideo := 0
 Global RowNumber = 0
 global reload := 0
 Global rclick := 0
OnMessage(0x201, "WM_LBUTTONDOWN")
OnMessage(0x203,"WM_LBUTTONDBLCLK")
onmessage(0x207,"WM_MBUTTONDOWN")
onmessage(0x204,"WM_RBUTTONDOWN")
OnMessage(0x206,"WM_RBUTTONDBLCLK")
OnMessage(0x100, "WM_KEYDOWN")

;MsgBox, needw = %needx_text% needh = %needh% h-%ssh%
WM_LBUTTONDBLCLK()
{	
	Global click := 2
    global canceldblclk = 0
   ;ToolTip, % vlc " " urlVlc "?sid=" sid "&file=0"
	;return
      ;MsgBox, multivideo %multivideo% video %video%
  if ((video = 1) & (multivideo = 0)) 
{
   Run, % vlc " " urlVlc "?sid=" sid "&file=0"
   GuiControl, , Prog,  uTorrent буфферизирует видео... 
    Loop
    {
        ;MsgBox, lop
       While (a = 1)
        {
            ;MsgBox, в while
            Global a := 0
           ;Global reload = 1
            return
        }
    ;ToolTip после слипа2
       sleep, 5000
       Run, % vlc " " urlVlc "?sid=" sid "&file=0"

       a = 1
       
    }
    ;MsgBox, multivideo %multivideo% video %video%
    return
}
    
    if ((video = 0) & (multivideo = 0)) 
{
    run, %path1%
        return
}
    if ((video = 0) & (multivideo = 1)) 
{
    run, %path1%
        return
}
    if ((video = 1) & (multivideo = 1)) 
    {
	global dblclk = 1 
fold = %folder%\
Gui,2:default
; Create the ListView with two columns, Name and Size:
Gui, 2:Add, ListView, cf2ee11 Background000000 r23 w600 gMyListView , номер файла | Выберите файл для Stream просмотра: ;| тест
Gui, Color, 000000 
Gui, -SysMenu -ToolWindow -Caption -Border +AlwaysOnTop  ; (+E0x20 - клик сквозь)
Gui +LastFound 
WinSet, Transparent, 230
WinSet, ExStyle, ^0x80,
Gui, Font, s7 q5, Verdana
; Gather a list of file names from a folder and put them into the ListView:
;ToolTip, %folder%\*.* %A_MyDocuments%\*.*

 

 loop % file[1].length
   {
          fileName := file[1][A_Index-1][0]
      global filenumber := A_Index-1
      If RegexMatch(fileName, "\.(avi|mpg|mp4|mkv)$") 
     {
         LV_Add("", filenumber, file[1][A_Index-1][0])
         ;global row := A_Index-1
         ;row%A_Index% = %filenumber%
       }
      ; MsgBox, r3%row3% r4%row4% 11 "LV_GetNex" LV_GetNext("0")
       ;MsgBox, row LV_GetNext("0")
       ;MsgBox, %row% %fileName%
      ; MsgBox,  rown = %row% %A_Index%-1 %fileName%
   }

       
LV_ModifyCol(1, 0)
;LV_ModifyCol(2, 0)
;LV_ModifyCol(1, "Sort")  ; 
;LV_ModifyCol(2, "Integer")  ; For sorting purposes, indicate that column 2 is an integer.
; Display the window and return. The script will be notified whenever the user double clicks a row.
Gui, 2:Show, xcenter y%needh_gui2%
SendMode play
MouseMove, 150, 40, 0, 

}


MyListView:
;KeyWait, LButton, D
;While !(GetKeyState("LButton","P"))
Loop
{
    ;ToolTip, canceldblclk %canceldblclk% while a=%a% `n dblclkmylistview = %dblclk% `n rundblclk= %rundblclk% `n ahk %ahk% exe %exe% activeornot %activeornot%
    sleep 100
    
    
    if canceldblclk = 1 
    {
       Gui,2:default
	;;;global RowNumber := LV_GetNext("0")
	;MsgBox клик в пустоту %A_EventInfo%. Text: "%RowNumber%" %b%
	Global a := 1
   ; ToolTip,  a=%a%
	global rundblclk = 0
    global canceldblclk = 0
	Gui, 2:Destroy 
    }
    global canceldblclk = 0
	
    if rundblclk = 1
{
    Gui,2:default
	;;;global RowNumber := LV_GetNext("0")
    LV_GetText(RowText, LV_GetNext("0"), 1)
   ; MsgBox, % RowText
	Run, % vlc " " urlVlc "?sid=" sid "&file=" RowText ;%row LV_GetNext("0")%
    ;MsgBox You clicked row number %A_EventInfo%. Text: "%RowNumber%" %b%
	Global a := 1
   ; ToolTip,  a=%a%
	global rundblclk = 0
	Gui, 2:Destroy
	
}
WinGetActiveTitle, OutputVar
exe = 1
ahk = 1
if OutputVar != uTorrent_osd.exe
    exe = 0
if OutputVar != uTorrent_osd.ahk
ahk = 0
activeornot = % exe+ahk
;ToolTip, ahk %ahk% exe %exe% activeornot %activeornot%
if activeornot = 0
global canceldblclk = 1





While (a = 1)
{
    Global a := 0
    return
}
}
return
}

WM_LBUTTONDOWN()
{
	 Global click := 1
   SetTimer, check, -550
   return
 
   check:
   SetTimer, check, off
     Gui,2:default
global RowNumber := LV_GetNext("0")
   
  
   if ((click = 1) & (dblclk = 0) & (multivideo = 0)) 
    run %path%	
     if ((click = 1) & (dblclk = 0) & (multivideo = 1)) 
    run %path1%	
    
   if ((click = 1) & (dblclk = 1) & (global RowNumber != 0)) 
global rundblclk = 1
;if ((click = 1) & (dblclk = 1) & (global RowNumber = 0)) 
;global canceldblclk = 1

   ; MsgBox, dblclkcheck = %dblclk% `n click= %click% `n RowNumber= %RowNumber% `n canceldblclk= %canceldblclk%
      return
  
}






WM_MBUTTONDOWN()
{
    global reload = 1
    WinGet, utid, ID,  / ahk_exe uTorrent.exe
   ;ToolTip, %state%
       if state = Загрузка
    {
      DllCall( "PostMessage", UInt,utid, UInt,0x111, UInt,62, Int,0 ) ; pause https://autohotkey.com/board/topic/46880-utorrent-wm-command-wparam-values-for-menu-items/
      GuiControl, , Prog,  Загрузка останавлливается...
      
    }
    if state = [П] Загружается
    {
      DllCall( "PostMessage", UInt,utid, UInt,0x111, UInt,62, Int,0 ) ; pause https://autohotkey.com/board/topic/46880-utorrent-wm-command-wparam-values-for-menu-items/
      GuiControl, , Prog,  Загрузка останавлливается...
      
    }
if state = Пауза
    {
 DllCall( "PostMessage", UInt,utid, UInt,0x111, UInt,61, Int,0 ) ; resume
 GuiControl, , Prog,  Загрузка востанавлливается... 
 
   }
}


WM_RBUTTONDBLCLK()
{
Global rclick = 2
if (rclick = 2)
{
    GuiControl, , Prog,  uTorrent перезагружается... 
    WinMenuSelectItem, ahk_class µTorrent4823DF041B09,, Файл, Выход
    Loop
    {
        
       While (a = 1)
        {
            
            Global a := 0
           Global reload = 1
            return
        }
    ;ToolTip после слипа2
       sleep, 15000
       run, C:\Program Files (x86)\uTorrent\uTorrent.exe /MINIMIZED
       sleep, 7000
       a = 1
       rclick = 0
    }

}
    
}


WM_RBUTTONDOWN()
{
   Global rclick = 1
   SetTimer, checkr, 250
   return
 
   checkr:
   SetTimer, checkr, off
 ;MsgBox, %rclick%

   if (rclick = 1)
    {
       winactivate, / ahk_exe uTorrent.exe
    WinGetpos, utx, uty, , , / ahk_exe uTorrent.exe
    MouseMove, utx+100, uty+100, 0
    rclick = 0
}
return

	}


Loop
{


url := "http://" ip ":" port "/gui/"
global vlc := "C:\Program Files\DAUM\PotPlayer\PotPlayerMini64.exe"
;global vlc := "C:\Program Files (x86)\PotPlayer\PotPlayerMini.exe"
global urlVlc := "http://" ip ":" port "/proxy"
tokenUrl := url "token.html"
action := "?list=1"
HTTP := ComObjCreate("WinHTTP.WinHTTPRequest.5.1")

Process, Exist, uTorrent.exe
status = %ErrorLevel% 
if status = 0
   {
run, "C:\staff\margin\margin hsi.exe" "C:\staff\margin\destroy margin 0.hss" ; убрать кусок отрезаного от приложений экрана
Process, close, uTorrent_osd.exe
ExitApp
}

HTTP.Open("GET", tokenUrl, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
token := "&token=" RegExReplace(HTTP.ResponseText, "<.+?>")
HTTP.Open("GET", url action token, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
Body := HTTP.ResponseBody
pArr := ComObjValue(Body)
cBytes := NumGet(pArr+0, A_PtrSize = 8? 24:16, "uint")
pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, "ptr")
;MsgBox, % StrGet(pText, cBytes, "utf-8") 
;msgbox % HTTP.ResponseText
JsonString := StrGet(pText, cBytes, "utf-8")
JS := new ActiveScript("JScript")
JS.eval("delete ActiveXObject; delete GetObject;") 
ComObjError(false)
obj := JS.eval("(" . JsonString . ")").torrents
SetFormat,Float,0.1
{
    
    
   
    
Loop % obj.length
{
            
        Global video := 0
        ;ToolTip, reload %reload%
        ;Sleep, 1000
        if reload = 1
        {
            global reload := 0
            break
        }
        

;global multiornot := % obj[A_Index - 1][23]   ; ([a-zA-Z0-9{7}])'', match)
  ;  global mm := % multiornot ",([0-9])"
  ;  ToolTip, mm = %mm%
  ;  OutputVar := % StrGet(pText, cBytes, "utf-8") 
;OutputVar := "12.456 h/ 5673 567-"
;var1 := RegExMatch(OutputVar, mm, mattch)
;var1 := RegExMatch(OutputVar, "%mm%([a-zA-Z0-9{7}])", match)
;if (match2 != "М" && match1 < 10)
;MsgBox % mattch1 "`n" mattch "`n" mattch3 "`n var1=" var1 "`n" mm

    
   ;MsgBox % obj[A_Index - 1][2]
   global sid := obj[A_Index - 1][22]
   global folder := obj[A_Index - 1][26]
   hash := obj[A_Index - 1][0]
   action := "?action=getfiles&hash=" hash 
   
   Process, Exist, uTorrent.exe
status = %ErrorLevel% 
if status = 0
   {
run, "C:\staff\margin\margin hsi.exe" "C:\staff\margin\destroy margin 0.hss" ; убрать кусок отрезаного от приложений экрана
Process, close, uTorrent_osd.exe
ExitApp
   }
    
   
   HTTP.Open("GET", url action token, false)
   HTTP.SetCredentials(user, pass, 0)
   HTTP.Send()
   Body := HTTP.ResponseBody
   pArr := ComObjValue(Body)
   cBytes := NumGet(pArr+0, A_PtrSize = 8? 24:16, "uint")
   pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, "ptr")
   JsonString := StrGet(pText, cBytes, "utf-8")
  global file := JS.eval("(" . JsonString . ")").files
    global file1 := JS.eval("(" . JsonString . ")").files
    p = % obj[A_Index - 1][4]/10
   
   
   IfNotEqual, p, 100.0  ; отображение только недокачанных торрентов
{
   global state = % obj[A_Index - 1][21]
  
   Global n = % obj[A_Index - 1][2]
 
   size = % obj[A_Index - 1][3]/1000000 "мб"
   t = % obj[A_Index - 1][10]/60
   loop % file[1].length
{
   Global path1 := % folder ; "\" file[1][A_Index-1][0]
   Global path := % folder "\" file[1][A_Index-1][0]
}

   loop % file[1].length
{
   If RegexMatch(file[1][A_Index-1][0], "\.(avi|mpg|mp4|mkv)$") 
      Global video := 1
  }
      
    IfInString, path1, %n%
      Global multivideo := 1 
      
   IfnotInString, path1, %n%
      Global multivideo := 0
   
  
   
;Run, % vlc " " urlVlc "?sid=" sid "&file=0" ; A_Index-1
     ; Msgbox play %urlVlc%


;var1 := RegExMatch(p, "(.*)\.", match)
;if t contains -


;IfInString, t, -
;{
;var2 := RegExMatch(t, "-(.*)", matchh)
;t = 
;}
;IfNotInString, t, -
;  matchh1 =   
;IfNotEqual, match1, 100 




;tnorm := RegExReplace(t, "\D")

;MsgBox % var

;MsgBox % NewVar




     
        if runonce = 0
        {
        runonce = 1
        ;global needy_gui := A_ScreenHeight-13 ; высота гуи
       
        Gui, Show, x1 y%needy_gui%, uTorrent_osd
         run, "C:\staff\margin\margin hsi.exe" "C:\staff\margin\margin bottom 15.hss"
        
        }
;-------------------------------------
;-----------------------------размер
SetFormat, FloatFast, 0.2
if size > 1000
    mbgb = % obj[A_Index - 1][3]/1000000000  "гб"
else
    mbgb = % obj[A_Index - 1][3]/1000000 "мб"
;-------------------------------------
;------------------------------------

;-------------------------------------
;-----------------------------осталось
SetFormat, FloatFast, 0.2
RegExMatch(t, "\d+", tnorm)



        If tnorm > 60
        {
            hournotnorm = % tnorm/60
            RegExMatch(hournotnorm, "(.*)\.", hour)
            hour = % hour1 ":"
        SetFormat, FloatFast, 0.2
        RegExMatch(tnorm/60, "\.(\d+)", minnogood)

        minn = % minnogood*60/100
        RegExMatch(minn, "\.(..)", min)
        ;MsgBox, = %min1%
        
       ; ToolTip, hournotnorm %hournotnorm% hour %hour% hour1 %hour1% tnorm %tnorm% tnotnorm %tnotnorm% tnorm %tnorm% minnogood1 %minnogood1%
        }
    else
    {
        hour =
        RegExMatch(t, "\d+", tnorm)
   ; SetFormat, FloatFast, 0.2
    RegExMatch(tnorm/60, "\.([0-9])", minnogood)
;ToolTip tnorm %tnorm% minnogood %minnogood%
    min1 = % tnorm
    ;RegExMatch(minn, "\.(..)", min)
  ;  ToolTip, min %min1%
   ; ToolTip, hournotnorm %hournotnorm% hour %hour% hour1 %hour1% tnorm1 %tnorm1% tnotnorm %tnotnorm%
    }
    ;---------------------------------------------------------------------------------------
    ;-----------------------------осталось--------------------------------------------------   
    
    
     ;---------------------------------------------------------------------------------------
    ;-----------------------------скорость--------------------------------------------------
   ; s = % obj[A_Index - 1][9]/1000000
   SetFormat, FloatFast, 0.2
   s = % obj[A_Index - 1][9]/1000000 "мб/с"
   if s < 1
    {
    SetFormat, FloatFast, 0.0
    s = % obj[A_Index - 1][9]/1000 "кб/с"
    }
    ; ---------------------------------------------------------Защита от зависания скачки
    
    if ((s = "0кб/с") & (state != "Пауза"))
    {
        ;MsgBox
        RunWait, ping.exe www.microsoft.com,, Hide UseErrorlevel
        if !Errorlevel = 1
            ;ToolTip, % !Errorlevel
        prepare_to_reload += 1
       }
    
    
    if s != 0кб/с
        ;MsgBox
        prepare_to_reload = 0
    
    if prepare_to_reload = 50
        {
    GuiControl, , Prog,  uTorrent перезагружается... 
    WinMenuSelectItem, ahk_class µTorrent4823DF041B09,, Файл, Выход
    prepare_to_reload = 0
    Loop
    {
        
       While (a = 1)
        {
           ; ToolTip после слипа2
            Global a = 0
           ; ToolTip, a %a%
          reload
            return
        }
    ;ToolTip после слипа2
       sleep, 15000
       run, C:\Program Files (x86)\uTorrent\uTorrent.exe /MINIMIZED
       sleep, 7000
       global a = 1
       ;ToolTip, a %a%
       ;Sleep, 1000
       
        
    }
}
        
 ;ToolTip, s = %s% prepare_to_reload %prepare_to_reload% state %state%
    ; --------------------------------------------------------------------------------
SetFormat, FloatFast, 0.1
GuiControl,, MyProgress, %p% ;vPRBAR cFF7200
 
GuiControl, , Prog,  %n% - %mbgb%  скорость %s%   осталось %hour%%min1%м  завершено %p%`% %state%  ; video= %video% multiornot %multivideo% - %file% %path1%
formattime,date,,dd/MM/yy
GuiControl,, Time, %A_Hour%:%A_Min% %A_DDD% %date% 
;ToolTip, %mattch1%


      if reload = 1
        {
            ;MsgBox, reload 1
        global reload := 0
            break
        }  
 
sleep, 2000

Process, Exist, uTorrent.exe
status = %ErrorLevel% 
if status = 0
   {
run, "C:\staff\margin\margin hsi.exe" "C:\staff\margin\destroy margin 0.hss" ; убрать кусок отрезаного от приложений экрана
Process, close, uTorrent_osd.exe
ExitApp
}
;}




















/*
 *  ActiveScript for AutoHotkey v1.1
 *
 *  Provides an interface to Active Scripting languages like VBScript and JScript,
 *  without relying on Microsoft's ScriptControl, which is not available to 64-bit
 *  programs.
 *
 *  License: Use, modify and redistribute without limitation, but at your own risk.
 */
class ActiveScript extends ActiveScript._base
{
    __New(Language)
    {
        if this._script := ComObjCreate(Language, ActiveScript.IID)
            this._scriptParse := ComObjQuery(this._script, ActiveScript.IID_Parse)
        if !this._scriptParse
            throw Exception("Invalid language", -1, Language)
        this._site := new ActiveScriptSite(this)
        this._SetScriptSite(this._site.ptr)
        this._InitNew()
        this._objects := {}
        this.Error := ""
        this._dsp := this._GetScriptDispatch()  ; Must be done last.
        try
            if this.ScriptEngine() = "JScript"
                this.SetJScript58()
    }

    SetJScript58()
    {
        static IID_IActiveScriptProperty := "{4954E0D0-FBC7-11D1-8410-006008C3FBFC}"
        if !prop := ComObjQuery(this._script, IID_IActiveScriptProperty)
            return false
        VarSetCapacity(var, 24, 0), NumPut(2, NumPut(3, var, "short") + 6)
        hr := DllCall(NumGet(NumGet(prop+0)+4*A_PtrSize), "ptr", prop, "uint", 0x4000
            , "ptr", 0, "ptr", &var), ObjRelease(prop)
        return hr >= 0
    }
    
    Eval(Code)
    {
        pvar := NumGet(ComObjValue(arr:=ComObjArray(0xC,1)) + 8+A_PtrSize)
        this._ParseScriptText(Code, 0x20, pvar)  ; SCRIPTTEXT_ISEXPRESSION := 0x20
        return arr[0]
    }
    
    Exec(Code)
    {
        this._ParseScriptText(Code, 0x42, 0)  ; SCRIPTTEXT_ISVISIBLE := 2, SCRIPTTEXT_ISPERSISTENT := 0x40
        this._SetScriptState(2)  ; SCRIPTSTATE_CONNECTED := 2
    }
    
    AddObject(Name, DispObj, AddMembers := false)
    {
        static a, supports_dispatch ; Test for built-in IDispatch support.
            := a := ((a:=ComObjArray(0xC,1))[0]:=[42]) && a[0][1]=42
        if IsObject(DispObj) && !(supports_dispatch || ComObjType(DispObj))
            throw Exception("Adding a non-COM object requires AutoHotkey v1.1.17+", -1)
        this._objects[Name] := DispObj
        this._AddNamedItem(Name, AddMembers ? 8 : 2)  ; SCRIPTITEM_ISVISIBLE := 2, SCRIPTITEM_GLOBALMEMBERS := 8
    }
    
    _GetObjectUnk(Name)
    {
        return !IsObject(dsp := this._objects[Name]) ? dsp  ; Pointer
            : ComObjValue(dsp) ? ComObjValue(dsp)  ; ComObject
            : &dsp  ; AutoHotkey object
    }
    
    class _base
    {
        __Call(Method, Params*)
        {
            if ObjHasKey(this, "_dsp")
                try
                    return (this._dsp)[Method](Params*)
                catch e
                    throw Exception(e.Message, -1, e.Extra)
        }
        
        __Get(Property, Params*)
        {
            if ObjHasKey(this, "_dsp")
                try
                    return (this._dsp)[Property, Params*]
                catch e
                    throw Exception(e.Message, -1, e.Extra)
        }
        
        __Set(Property, Params*)
        {
            if ObjHasKey(this, "_dsp")
            {
                Value := Params.Pop()
                try
                    return (this._dsp)[Property, Params*] := Value
                catch e
                    throw Exception(e.Message, -1, e.Extra)
            }
        }
    }
    
    _SetScriptSite(Site)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+3*A_PtrSize), "ptr", p, "ptr", Site)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::SetScriptSite")
    }
    
    _SetScriptState(State)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+5*A_PtrSize), "ptr", p, "int", State)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::SetScriptState")
    }
    
    _AddNamedItem(Name, Flags)
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+8*A_PtrSize), "ptr", p, "wstr", Name, "uint", Flags)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::AddNamedItem")
    }
    
    _GetScriptDispatch()
    {
        hr := DllCall(NumGet(NumGet((p:=this._script)+0)+10*A_PtrSize), "ptr", p, "ptr", 0, "ptr*", pdsp)
        if (hr < 0)
            this._HRFail(hr, "IActiveScript::GetScriptDispatch")
        return ComObject(9, pdsp, 1)
    }
    
    _InitNew()
    {
        hr := DllCall(NumGet(NumGet((p:=this._scriptParse)+0)+3*A_PtrSize), "ptr", p)
        if (hr < 0)
            this._HRFail(hr, "IActiveScriptParse::InitNew")
    }
    
    _ParseScriptText(Code, Flags, pvarResult)
    {
        VarSetCapacity(excp, 8 * A_PtrSize, 0)
        hr := DllCall(NumGet(NumGet((p:=this._scriptParse)+0)+5*A_PtrSize), "ptr", p
            , "wstr", Code, "ptr", 0, "ptr", 0, "ptr", 0, "uptr", 0, "uint", 1
            , "uint", Flags, "ptr", pvarResult, "ptr", 0)
        if (hr < 0)
            this._HRFail(hr, "IActiveScriptParse::ParseScriptText")
    }
    
    _HRFail(hr, what)
    {
        if e := this.Error
        {
            this.Error := ""
            throw Exception("`nError code:`t" this._HRFormat(e.HRESULT)
                . "`nSource:`t`t" e.Source "`nDescription:`t" e.Description
                . "`nLine:`t`t" e.Line "`nColumn:`t`t" e.Column
                . "`nLine text:`t`t" e.LineText, -3)
        }
        throw Exception(what " failed with code " this._HRFormat(hr), -2)
    }
    
    _HRFormat(hr)
    {
        return Format("0x{1:X}", hr & 0xFFFFFFFF)
    }
    
    _OnScriptError(err) ; IActiveScriptError err
    {
        VarSetCapacity(excp, 8 * A_PtrSize, 0)
        DllCall(NumGet(NumGet(err+0)+3*A_PtrSize), "ptr", err, "ptr", &excp) ; GetExceptionInfo
        DllCall(NumGet(NumGet(err+0)+4*A_PtrSize), "ptr", err, "uint*", srcctx, "uint*", srcline, "int*", srccol) ; GetSourcePosition
        DllCall(NumGet(NumGet(err+0)+5*A_PtrSize), "ptr", err, "ptr*", pbstrcode) ; GetSourceLineText
        code := StrGet(pbstrcode, "UTF-16"), DllCall("OleAut32\SysFreeString", "ptr", pbstrcode)
        if fn := NumGet(excp, 6 * A_PtrSize) ; pfnDeferredFillIn
            DllCall(fn, "ptr", &excp)
        wcode := NumGet(excp, 0, "ushort")
        hr := wcode ? 0x80040200 + wcode : NumGet(excp, 7 * A_PtrSize, "uint")
        this.Error := {HRESULT: hr, Line: srcline, Column: srccol, LineText: code}
        static Infos := "Source,Description,HelpFile"
        Loop Parse, % Infos, `,
            if pbstr := NumGet(excp, A_Index * A_PtrSize)
                this.Error[A_LoopField] := StrGet(pbstr, "UTF-16"), DllCall("OleAut32\SysFreeString", "ptr", pbstr)
        return 0x80004001 ; E_NOTIMPL (let Exec/Eval get a fail result)
    }
    
    __Delete()
    {
        if this._script
        {
            DllCall(NumGet(NumGet((p:=this._script)+0)+7*A_PtrSize), "ptr", p)  ; Close
            ObjRelease(this._script)
        }
        if this._scriptParse
            ObjRelease(this._scriptParse)
    }
    
    static IID := "{BB1A2AE1-A4F9-11cf-8F20-00805F2CD064}"
    static IID_Parse := A_PtrSize=8 ? "{C7EF7658-E1EE-480E-97EA-D52CB4D76D17}" : "{BB1A2AE2-A4F9-11cf-8F20-00805F2CD064}"
}

class ActiveScriptSite
{
    __New(Script)
    {
        ObjSetCapacity(this, "_site", 3 * A_PtrSize)
        NumPut(&Script
        , NumPut(ActiveScriptSite._vftable("_vft_w", "31122", 0x100)
        , NumPut(ActiveScriptSite._vftable("_vft", "31125232211", 0)
            , this.ptr := ObjGetAddress(this, "_site"))))
    }
    
    _vftable(Name, PrmCounts, EIBase)
    {
        if p := ObjGetAddress(this, Name)
            return p
        ObjSetCapacity(this, Name, StrLen(PrmCounts) * A_PtrSize)
        p := ObjGetAddress(this, Name)
        Loop Parse, % PrmCounts
        {
            cb := RegisterCallback("_ActiveScriptSite", "F", A_LoopField, A_Index + EIBase)
            NumPut(cb, p + (A_Index-1) * A_PtrSize)
        }
        return p
    }
}

_ActiveScriptSite(this, a1:=0, a2:=0, a3:=0, a4:=0, a5:=0)
{
    Method := A_EventInfo & 0xFF
    if A_EventInfo >= 0x100  ; IActiveScriptSiteWindow
    {
        if Method = 4  ; GetWindow
        {
            NumPut(0, a1+0) ; *phwnd := 0
            return 0 ; S_OK
        }
        if Method = 5  ; EnableModeless
        {
            return 0 ; S_OK
        }
        this -= A_PtrSize     ; Cast to IActiveScriptSite
    }
    ;else: IActiveScriptSite
    if Method = 1  ; QueryInterface
    {
        iid := _AS_GUIDToString(a1)
        if (iid = "{00000000-0000-0000-C000-000000000046}"  ; IUnknown
         || iid = "{DB01A1E3-A42B-11cf-8F20-00805F2CD064}") ; IActiveScriptSite
        {
            NumPut(this, a2+0)
            return 0 ; S_OK
        }
        if (iid = "{D10F6761-83E9-11cf-8F20-00805F2CD064}") ; IActiveScriptSiteWindow
        {
            NumPut(this + A_PtrSize, a2+0)
            return 0 ; S_OK
        }
        NumPut(0, a2+0)
        return 0x80004002 ; E_NOINTERFACE
    }
    if Method = 5  ; GetItemInfo
    {
        a1 := StrGet(a1, "UTF-16")
        , (a3 && NumPut(0, a3+0))  ; *ppiunkItem := NULL
        , (a4 && NumPut(0, a4+0))  ; *ppti := NULL
        if (a2 & 1) ; SCRIPTINFO_IUNKNOWN
        {
            if !(unk := Object(NumGet(this + A_PtrSize*2))._GetObjectUnk(a1))
                return 0x8002802B ; TYPE_E_ELEMENTNOTFOUND
            ObjAddRef(unk), NumPut(unk, a3+0)
        }
        return 0 ; S_OK
    }
    if Method = 9  ; OnScriptError
        return Object(NumGet(this + A_PtrSize*2))._OnScriptError(a1)
    
    ; AddRef and Release don't do anything because we want to avoid circular references.
    ; The site and IActiveScript are both released when the AHK script releases its last
    ; reference to the ActiveScript object.
    
    ; All of the other methods don't require implementations.
    return 0x80004001 ; E_NOTIMPL
}

_AS_GUIDToString(pGUID)
{
    VarSetCapacity(String, 38*2)
    DllCall("ole32\StringFromGUID2", "ptr", pGUID, "str", String, "int", 39)
    return String
}

}

;sleep 1000

}

}
} ;
return 



EncodeInteger( p_value, p_size, p_address, p_offset )
{
	loop, %p_size%
		DllCall( "RtlFillMemory"
			, "uint", p_address+p_offset+A_Index-1
			, "uint", 1
			, "uchar", ( p_value >> ( 8*( A_Index-1 ) ) ) & 0xFF )
}


#IfWinActive  ahk_exe uTorrent.exe
~LButton::
;if GetTextUnderMouse() = Выход
{
CoordMode, Mouse, Screen
MouseGetPos, m_x, m_y, m_hw_target
SendMessage, 0x84,, ( m_y << 16 )|m_x,, ahk_id %m_hw_target%
;ToolTip, % errorlevel
if errorlevel = 1
{
    ;MsgBox, % GetTextUnderMouse()
   
    if GetTextUnderMouse() = "Выход"
    {
         run, "C:\staff\margin\margin hsi.exe" "C:\staff\margin\destroy margin 0.hss" ; убрать кусок отрезаного от приложений экрана
      WinMenuSelectItem, ahk_class µTorrent4823DF041B09,, Файл, Выход
          exitapp  
    }
    
	GetTextUnderMouse() {
	Acc := Acc_ObjectFromPoint(child)
	try value := Acc.accValue(child)
	if Not value
		try value := Acc.accName(child)
	return value
    
    
}
    
    
    
    
   
}

}


























































; http://www.autohotkey.com/board/topic/77303-acc-library-ahk-l-updated-09272012/
; https://dl.dropbox.com/u/47573473/Web%20Server/AHK_L/Acc.ahk
;------------------------------------------------------------------------------
; Acc.ahk Standard Library
; by Sean
; Updated by jethrow:
; 	Modified ComObjEnwrap params from (9,pacc) --> (9,pacc,1)
; 	Changed ComObjUnwrap to ComObjValue in order to avoid AddRef (thanks fincs)
; 	Added Acc_GetRoleText & Acc_GetStateText
; 	Added additional functions - commented below
; 	Removed original Acc_Children function
; last updated 2/25/2010
;------------------------------------------------------------------------------

Acc_Init()
{
	Static	h
	If Not	h
		h:=DllCall("LoadLibrary","Str","oleacc","Ptr")
}
Acc_ObjectFromEvent(ByRef _idChild_, hWnd, idObject, idChild)
{
	Acc_Init()
	If	DllCall("oleacc\AccessibleObjectFromEvent", "Ptr", hWnd, "UInt", idObject, "UInt", idChild, "Ptr*", pacc, "Ptr", VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&varChild)=0
	Return	ComObjEnwrap(9,pacc,1), _idChild_:=NumGet(varChild,8,"UInt")
}

Acc_ObjectFromPoint(ByRef _idChild_ = "", x = "", y = "")
{
	Acc_Init()
	If	DllCall("oleacc\AccessibleObjectFromPoint", "Int64", x==""||y==""?0*DllCall("GetCursorPos","Int64*",pt)+pt:x&0xFFFFFFFF|y<<32, "Ptr*", pacc, "Ptr", VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&varChild)=0
	Return	ComObjEnwrap(9,pacc,1), _idChild_:=NumGet(varChild,8,"UInt")
}

Acc_ObjectFromWindow(hWnd, idObject = -4)
{
	Acc_Init()
	If	DllCall("oleacc\AccessibleObjectFromWindow", "Ptr", hWnd, "UInt", idObject&=0xFFFFFFFF, "Ptr", -VarSetCapacity(IID,16)+NumPut(idObject==0xFFFFFFF0?0x46000000000000C0:0x719B3800AA000C81,NumPut(idObject==0xFFFFFFF0?0x0000000000020400:0x11CF3C3D618736E0,IID,"Int64"),"Int64"), "Ptr*", pacc)=0
	Return	ComObjEnwrap(9,pacc,1)
}

Acc_WindowFromObject(pacc)
{
	If	DllCall("oleacc\WindowFromAccessibleObject", "Ptr", IsObject(pacc)?ComObjValue(pacc):pacc, "Ptr*", hWnd)=0
	Return	hWnd
}

Acc_GetRoleText(nRole)
{
	nSize := DllCall("oleacc\GetRoleText", "Uint", nRole, "Ptr", 0, "Uint", 0)
	VarSetCapacity(sRole, (A_IsUnicode?2:1)*nSize)
	DllCall("oleacc\GetRoleText", "Uint", nRole, "str", sRole, "Uint", nSize+1)
	Return	sRole
}

Acc_GetStateText(nState)
{
	nSize := DllCall("oleacc\GetStateText", "Uint", nState, "Ptr", 0, "Uint", 0)
	VarSetCapacity(sState, (A_IsUnicode?2:1)*nSize)
	DllCall("oleacc\GetStateText", "Uint", nState, "str", sState, "Uint", nSize+1)
	Return	sState
}

Acc_SetWinEventHook(eventMin, eventMax, pCallback)
{
	Return	DllCall("SetWinEventHook", "Uint", eventMin, "Uint", eventMax, "Uint", 0, "Ptr", pCallback, "Uint", 0, "Uint", 0, "Uint", 0)
}

Acc_UnhookWinEvent(hHook)
{
	Return	DllCall("UnhookWinEvent", "Ptr", hHook)
}
/*	Win Events:
	pCallback := RegisterCallback("WinEventProc")
	WinEventProc(hHook, event, hWnd, idObject, idChild, eventThread, eventTime)
	{
		Critical
		Acc := Acc_ObjectFromEvent(_idChild_, hWnd, idObject, idChild)
		; Code Here:
	}
*/

; Written by jethrow
Acc_Role(Acc, ChildId=0) {
	try return ComObjType(Acc,"Name")="IAccessible"?Acc_GetRoleText(Acc.accRole(ChildId)):"invalid object"
}
Acc_State(Acc, ChildId=0) {
	try return ComObjType(Acc,"Name")="IAccessible"?Acc_GetStateText(Acc.accState(ChildId)):"invalid object"
}
Acc_Location(Acc, ChildId=0, byref Position="") { ; adapted from Sean's code
	try Acc.accLocation(ComObj(0x4003,&x:=0), ComObj(0x4003,&y:=0), ComObj(0x4003,&w:=0), ComObj(0x4003,&h:=0), ChildId)
	catch
		return
	Position := "x" NumGet(x,0,"int") " y" NumGet(y,0,"int") " w" NumGet(w,0,"int") " h" NumGet(h,0,"int")
	return	{x:NumGet(x,0,"int"), y:NumGet(y,0,"int"), w:NumGet(w,0,"int"), h:NumGet(h,0,"int")}
}
Acc_Parent(Acc) { 
	try parent:=Acc.accParent
	return parent?Acc_Query(parent):
}
Acc_Child(Acc, ChildId=0) {
	try child:=Acc.accChild(ChildId)
	return child?Acc_Query(child):
}
Acc_Query(Acc) { ; thanks Lexikos - www.autohotkey.com/forum/viewtopic.php?t=81731&p=509530#509530
	try return ComObj(9, ComObjQuery(Acc,"{618736e0-3c3d-11cf-810c-00aa00389b71}"), 1)
}
Acc_Error(p="") {
	static setting:=0
	return p=""?setting:setting:=p
}
Acc_Children(Acc) {
	if ComObjType(Acc,"Name") != "IAccessible"
		ErrorLevel := "Invalid IAccessible Object"
	else {
		Acc_Init(), cChildren:=Acc.accChildCount, Children:=[]
		if DllCall("oleacc\AccessibleChildren", "Ptr",ComObjValue(Acc), "Int",0, "Int",cChildren, "Ptr",VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&varChildren, "Int*",cChildren)=0 {
			Loop %cChildren%
				i:=(A_Index-1)*(A_PtrSize*2+8)+8, child:=NumGet(varChildren,i), Children.Insert(NumGet(varChildren,i-8)=9?Acc_Query(child):child), NumGet(varChildren,i-8)=9?ObjRelease(child):
			return Children.MaxIndex()?Children:
		} else
			ErrorLevel := "AccessibleChildren DllCall Failed"
	}
	if Acc_Error()
		throw Exception(ErrorLevel,-1)
}
Acc_ChildrenByRole(Acc, Role) {
	if ComObjType(Acc,"Name")!="IAccessible"
		ErrorLevel := "Invalid IAccessible Object"
	else {
		Acc_Init(), cChildren:=Acc.accChildCount, Children:=[]
		if DllCall("oleacc\AccessibleChildren", "Ptr",ComObjValue(Acc), "Int",0, "Int",cChildren, "Ptr",VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&varChildren, "Int*",cChildren)=0 {
			Loop %cChildren% {
				i:=(A_Index-1)*(A_PtrSize*2+8)+8, child:=NumGet(varChildren,i)
				if NumGet(varChildren,i-8)=9
					AccChild:=Acc_Query(child), ObjRelease(child), Acc_Role(AccChild)=Role?Children.Insert(AccChild):
				else
					Acc_Role(Acc, child)=Role?Children.Insert(child):
			}
			return Children.MaxIndex()?Children:, ErrorLevel:=0
		} else
			ErrorLevel := "AccessibleChildren DllCall Failed"
	}
	if Acc_Error()
		throw Exception(ErrorLevel,-1)
}
Acc_Get(Cmd, ChildPath="", ChildID=0, WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	static properties := {Action:"DefaultAction", DoAction:"DoDefaultAction", Keyboard:"KeyboardShortcut"}
	AccObj :=   IsObject(WinTitle)? WinTitle
			:   Acc_ObjectFromWindow( WinExist(WinTitle, WinText, ExcludeTitle, ExcludeText), 0 )
	if ComObjType(AccObj, "Name") != "IAccessible"
		ErrorLevel := "Could not access an IAccessible Object"
	else {
		StringReplace, ChildPath, ChildPath, _, %A_Space%, All
		AccError:=Acc_Error(), Acc_Error(true)
		Loop Parse, ChildPath, ., %A_Space%
			try {
				if A_LoopField is digit
					Children:=Acc_Children(AccObj), m2:=A_LoopField ; mimic "m2" output in else-statement
				else
					RegExMatch(A_LoopField, "(\D*)(\d*)", m), Children:=Acc_ChildrenByRole(AccObj, m1), m2:=(m2?m2:1)
				if Not Children.HasKey(m2)
					throw
				AccObj := Children[m2]
			} catch {
				ErrorLevel:="Cannot access ChildPath Item #" A_Index " -> " A_LoopField, Acc_Error(AccError)
				if Acc_Error()
					throw Exception("Cannot access ChildPath Item", -1, "Item #" A_Index " -> " A_LoopField)
				return
			}
		Acc_Error(AccError)
		StringReplace, Cmd, Cmd, %A_Space%, , All
		properties.HasKey(Cmd)? Cmd:=properties[Cmd]:
		try {
			if (Cmd = "Location")
				AccObj.accLocation(ComObj(0x4003,&x:=0), ComObj(0x4003,&y:=0), ComObj(0x4003,&w:=0), ComObj(0x4003,&h:=0), ChildId)
			  , ret_val := "x" NumGet(x,0,"int") " y" NumGet(y,0,"int") " w" NumGet(w,0,"int") " h" NumGet(h,0,"int")
			else if (Cmd = "Object")
				ret_val := AccObj
			else if Cmd in Role,State
				ret_val := Acc_%Cmd%(AccObj, ChildID+0)
			else if Cmd in ChildCount,Selection,Focus
				ret_val := AccObj["acc" Cmd]
			else
				ret_val := AccObj["acc" Cmd](ChildID+0)
		} catch {
			ErrorLevel := """" Cmd """ Cmd Not Implemented"
			if Acc_Error()
				throw Exception("Cmd Not Implemented", -1, Cmd)
			return
		}
		return ret_val, ErrorLevel:=0
	}
	if Acc_Error()
		throw Exception(ErrorLevel,-1)
}