<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Прогресс бар скачивания торрент файла с программы uTorrent]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=11795</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=11795&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Прогресс бар скачивания торрент файла с программы uTorrent».]]></description>
		<lastBuildDate>Wed, 03 Aug 2016 18:58:01 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106582#p106582</link>
			<description><![CDATA[<p>День пытаюсь задать соответствие номера строки и номера файла.<br />То-есть я щелкаю по 5ой строке, а в ней файл который имеет к примеру 22ой номер, и мне нужно получить 22, причём не хотелось бы чтобы 22 было в названии а чтобы где-то хранилось невидимо для глаза.</p><p>Что-то типа:<br />row1 = 22<br />row2 = 23<br />row3 = 26<br />...</p><br /><p>Если использовать </p><div class="codebox"><pre><code>row%A_Index% = %filenumber%</code></pre></div><p>То код не работает если его поместить в if. Пытался добавить global но тогда вообще ругается на </p><div class="codebox"><pre><code>row%A_Index% = %filenumber%</code></pre></div><p> <br />Как можно решить вопрос?</p><p>Нашлось решение, запихнул номера в отдельную колонку и скрыл её, чего раньше не додумался.</p><div class="codebox"><pre><code>; Допгуи будет сразу автоскрываться если имя скрипта отлично от 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 бывает работает не с первого запуска, наверное связано с тем, что не хватает каких-то &quot;служебных&quot; данных видео. 
; Так как программа uTorrent запускает Stream в 2 этапа: 1 нажатие - запускается таймер с надписью &quot;готово через ...&quot; 
; после истечения времени таймера, кнопка &quot;поток&quot; заново появляется. 2 нажатие - запуск stream. DLMB запускает второй этап минуя первый.
; upd. УСТРАНЯЕТСЯ УСТАНОВКОЙ POTPLAYER 1.6.62377 - индексирует недокачанный файл как гомплеер и перемотка работает!)
; RMB - открыть окно программы uTorrent и переместить мышь в окно.
; DRMB - перезагрузить uTorrent (если раздача плохо качается - бывает помогает)
; MMB - пауза/запуск всех торрентов

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

global ip := &quot;127.0.0.1&quot;
global port := &quot;8080&quot;
global user := &quot;admin&quot;
global pass := &quot;pass&quot;





SetTitleMatchMode, 2
DetectHiddenWindows, On
Gui, Color, 000000 
Gui, -SysMenu -ToolWindow -Caption -Border +AlwaysOnTop ; (+E0x20 - клик сквозь)
Gui +LastFound 
hWnd:=WinExist()
DllCall(&quot;SetClassLong&quot;,&quot;UInt&quot;,hWnd,&quot;Int&quot;,-26,&quot;UInt&quot;,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, &quot;WM_LBUTTONDOWN&quot;)
OnMessage(0x203,&quot;WM_LBUTTONDBLCLK&quot;)
onmessage(0x207,&quot;WM_MBUTTONDOWN&quot;)
onmessage(0x204,&quot;WM_RBUTTONDOWN&quot;)
OnMessage(0x206,&quot;WM_RBUTTONDBLCLK&quot;)
OnMessage(0x100, &quot;WM_KEYDOWN&quot;)

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

       a = 1
       
    }
    ;MsgBox, multivideo %multivideo% video %video%
    return
}
    
    if ((video = 0) &amp; (multivideo = 0)) 
{
    run, %path1%
        return
}
    if ((video = 0) &amp; (multivideo = 1)) 
{
    run, %path1%
        return
}
    if ((video = 1) &amp; (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, &quot;\.(avi|mpg|mp4|mkv)$&quot;) 
     {
         LV_Add(&quot;&quot;, filenumber, file[1][A_Index-1][0])
         ;global row := A_Index-1
         ;row%A_Index% = %filenumber%
       }
      ; MsgBox, r3%row3% r4%row4% 11 &quot;LV_GetNex&quot; LV_GetNext(&quot;0&quot;)
       ;MsgBox, row LV_GetNext(&quot;0&quot;)
       ;MsgBox, %row% %fileName%
      ; MsgBox,  rown = %row% %A_Index%-1 %fileName%
   }

       
LV_ModifyCol(1, 0)
;LV_ModifyCol(2, 0)
;LV_ModifyCol(1, &quot;Sort&quot;)  ; 
;LV_ModifyCol(2, &quot;Integer&quot;)  ; 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(&quot;LButton&quot;,&quot;P&quot;))
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(&quot;0&quot;)
	;MsgBox клик в пустоту %A_EventInfo%. Text: &quot;%RowNumber%&quot; %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(&quot;0&quot;)
    LV_GetText(RowText, LV_GetNext(&quot;0&quot;), 1)
   ; MsgBox, % RowText
	Run, % vlc &quot; &quot; urlVlc &quot;?sid=&quot; sid &quot;&amp;file=&quot; RowText ;%row LV_GetNext(&quot;0&quot;)%
    ;MsgBox You clicked row number %A_EventInfo%. Text: &quot;%RowNumber%&quot; %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(&quot;0&quot;)
   
  
   if ((click = 1) &amp; (dblclk = 0) &amp; (multivideo = 0)) 
    run %path%	
     if ((click = 1) &amp; (dblclk = 0) &amp; (multivideo = 1)) 
    run %path1%	
    
   if ((click = 1) &amp; (dblclk = 1) &amp; (global RowNumber != 0)) 
global rundblclk = 1
;if ((click = 1) &amp; (dblclk = 1) &amp; (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( &quot;PostMessage&quot;, 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( &quot;PostMessage&quot;, 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( &quot;PostMessage&quot;, 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 := &quot;http://&quot; ip &quot;:&quot; port &quot;/gui/&quot;
global vlc := &quot;C:\Program Files\DAUM\PotPlayer\PotPlayerMini64.exe&quot;
;global vlc := &quot;C:\Program Files (x86)\PotPlayer\PotPlayerMini.exe&quot;
global urlVlc := &quot;http://&quot; ip &quot;:&quot; port &quot;/proxy&quot;
tokenUrl := url &quot;token.html&quot;
action := &quot;?list=1&quot;
HTTP := ComObjCreate(&quot;WinHTTP.WinHTTPRequest.5.1&quot;)

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

HTTP.Open(&quot;GET&quot;, tokenUrl, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
token := &quot;&amp;token=&quot; RegExReplace(HTTP.ResponseText, &quot;&lt;.+?&gt;&quot;)
HTTP.Open(&quot;GET&quot;, 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, &quot;uint&quot;)
pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, &quot;ptr&quot;)
;MsgBox, % StrGet(pText, cBytes, &quot;utf-8&quot;) 
;msgbox % HTTP.ResponseText
JsonString := StrGet(pText, cBytes, &quot;utf-8&quot;)
JS := new ActiveScript(&quot;JScript&quot;)
JS.eval(&quot;delete ActiveXObject; delete GetObject;&quot;) 
ComObjError(false)
obj := JS.eval(&quot;(&quot; . JsonString . &quot;)&quot;).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}])&#039;&#039;, match)
  ;  global mm := % multiornot &quot;,([0-9])&quot;
  ;  ToolTip, mm = %mm%
  ;  OutputVar := % StrGet(pText, cBytes, &quot;utf-8&quot;) 
;OutputVar := &quot;12.456 h/ 5673 567-&quot;
;var1 := RegExMatch(OutputVar, mm, mattch)
;var1 := RegExMatch(OutputVar, &quot;%mm%([a-zA-Z0-9{7}])&quot;, match)
;if (match2 != &quot;М&quot; &amp;&amp; match1 &lt; 10)
;MsgBox % mattch1 &quot;`n&quot; mattch &quot;`n&quot; mattch3 &quot;`n var1=&quot; var1 &quot;`n&quot; 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 := &quot;?action=getfiles&amp;hash=&quot; hash 
   
   Process, Exist, uTorrent.exe
status = %ErrorLevel% 
if status = 0
   {
run, &quot;C:\staff\margin\margin hsi.exe&quot; &quot;C:\staff\margin\destroy margin 0.hss&quot; ; убрать кусок отрезаного от приложений экрана
Process, close, uTorrent_osd.exe
ExitApp
   }
    
   
   HTTP.Open(&quot;GET&quot;, 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, &quot;uint&quot;)
   pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, &quot;ptr&quot;)
   JsonString := StrGet(pText, cBytes, &quot;utf-8&quot;)
  global file := JS.eval(&quot;(&quot; . JsonString . &quot;)&quot;).files
    global file1 := JS.eval(&quot;(&quot; . JsonString . &quot;)&quot;).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 &quot;мб&quot;
   t = % obj[A_Index - 1][10]/60
   loop % file[1].length
{
   Global path1 := % folder ; &quot;\&quot; file[1][A_Index-1][0]
   Global path := % folder &quot;\&quot; file[1][A_Index-1][0]
}

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


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


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




;tnorm := RegExReplace(t, &quot;\D&quot;)

;MsgBox % var

;MsgBox % NewVar




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

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



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

        minn = % minnogood*60/100
        RegExMatch(minn, &quot;\.(..)&quot;, min)
        ;MsgBox, = %min1%
        
       ; ToolTip, hournotnorm %hournotnorm% hour %hour% hour1 %hour1% tnorm %tnorm% tnotnorm %tnotnorm% tnorm %tnorm% minnogood1 %minnogood1%
        }
    else
    {
        hour =
        RegExMatch(t, &quot;\d+&quot;, tnorm)
   ; SetFormat, FloatFast, 0.2
    RegExMatch(tnorm/60, &quot;\.([0-9])&quot;, minnogood)
;ToolTip tnorm %tnorm% minnogood %minnogood%
    min1 = % tnorm
    ;RegExMatch(minn, &quot;\.(..)&quot;, 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 &quot;мб/с&quot;
   if s &lt; 1
    {
    SetFormat, FloatFast, 0.0
    s = % obj[A_Index - 1][9]/1000 &quot;кб/с&quot;
    }
    ; ---------------------------------------------------------Защита от зависания скачки
    
    if ((s = &quot;0кб/с&quot;) &amp; (state != &quot;Пауза&quot;))
    {
        ;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, &quot;C:\staff\margin\margin hsi.exe&quot; &quot;C:\staff\margin\destroy margin 0.hss&quot; ; убрать кусок отрезаного от приложений экрана
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&#039;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(&quot;Invalid language&quot;, -1, Language)
        this._site := new ActiveScriptSite(this)
        this._SetScriptSite(this._site.ptr)
        this._InitNew()
        this._objects := {}
        this.Error := &quot;&quot;
        this._dsp := this._GetScriptDispatch()  ; Must be done last.
        try
            if this.ScriptEngine() = &quot;JScript&quot;
                this.SetJScript58()
    }

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

class ActiveScriptSite
{
    __New(Script)
    {
        ObjSetCapacity(this, &quot;_site&quot;, 3 * A_PtrSize)
        NumPut(&amp;Script
        , NumPut(ActiveScriptSite._vftable(&quot;_vft_w&quot;, &quot;31122&quot;, 0x100)
        , NumPut(ActiveScriptSite._vftable(&quot;_vft&quot;, &quot;31125232211&quot;, 0)
            , this.ptr := ObjGetAddress(this, &quot;_site&quot;))))
    }
    
    _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(&quot;_ActiveScriptSite&quot;, &quot;F&quot;, 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 &amp; 0xFF
    if A_EventInfo &gt;= 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 = &quot;{00000000-0000-0000-C000-000000000046}&quot;  ; IUnknown
         || iid = &quot;{DB01A1E3-A42B-11cf-8F20-00805F2CD064}&quot;) ; IActiveScriptSite
        {
            NumPut(this, a2+0)
            return 0 ; S_OK
        }
        if (iid = &quot;{D10F6761-83E9-11cf-8F20-00805F2CD064}&quot;) ; 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, &quot;UTF-16&quot;)
        , (a3 &amp;&amp; NumPut(0, a3+0))  ; *ppiunkItem := NULL
        , (a4 &amp;&amp; NumPut(0, a4+0))  ; *ppti := NULL
        if (a2 &amp; 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&#039;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&#039;t require implementations.
    return 0x80004001 ; E_NOTIMPL
}

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

}

;sleep 1000

}

}
} ;
return 



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


#IfWinActive  ahk_exe uTorrent.exe
~LButton::
;if GetTextUnderMouse() = Выход
{
CoordMode, Mouse, Screen
MouseGetPos, m_x, m_y, m_hw_target
SendMessage, 0x84,, ( m_y &lt;&lt; 16 )|m_x,, ahk_id %m_hw_target%
;ToolTip, % errorlevel
if errorlevel = 1
{
    ;MsgBox, % GetTextUnderMouse()
   
    if GetTextUnderMouse() = &quot;Выход&quot;
    {
         run, &quot;C:\staff\margin\margin hsi.exe&quot; &quot;C:\staff\margin\destroy margin 0.hss&quot; ; убрать кусок отрезаного от приложений экрана
      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) --&gt; (9,pacc,1)
; 	Changed ComObjUnwrap to ComObjValue in order to avoid AddRef (thanks fincs)
; 	Added Acc_GetRoleText &amp; 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(&quot;LoadLibrary&quot;,&quot;Str&quot;,&quot;oleacc&quot;,&quot;Ptr&quot;)
}
Acc_ObjectFromEvent(ByRef _idChild_, hWnd, idObject, idChild)
{
	Acc_Init()
	If	DllCall(&quot;oleacc\AccessibleObjectFromEvent&quot;, &quot;Ptr&quot;, hWnd, &quot;UInt&quot;, idObject, &quot;UInt&quot;, idChild, &quot;Ptr*&quot;, pacc, &quot;Ptr&quot;, VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&amp;varChild)=0
	Return	ComObjEnwrap(9,pacc,1), _idChild_:=NumGet(varChild,8,&quot;UInt&quot;)
}

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

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

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

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

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

Acc_SetWinEventHook(eventMin, eventMax, pCallback)
{
	Return	DllCall(&quot;SetWinEventHook&quot;, &quot;Uint&quot;, eventMin, &quot;Uint&quot;, eventMax, &quot;Uint&quot;, 0, &quot;Ptr&quot;, pCallback, &quot;Uint&quot;, 0, &quot;Uint&quot;, 0, &quot;Uint&quot;, 0)
}

Acc_UnhookWinEvent(hHook)
{
	Return	DllCall(&quot;UnhookWinEvent&quot;, &quot;Ptr&quot;, hHook)
}
/*	Win Events:
	pCallback := RegisterCallback(&quot;WinEventProc&quot;)
	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,&quot;Name&quot;)=&quot;IAccessible&quot;?Acc_GetRoleText(Acc.accRole(ChildId)):&quot;invalid object&quot;
}
Acc_State(Acc, ChildId=0) {
	try return ComObjType(Acc,&quot;Name&quot;)=&quot;IAccessible&quot;?Acc_GetStateText(Acc.accState(ChildId)):&quot;invalid object&quot;
}
Acc_Location(Acc, ChildId=0, byref Position=&quot;&quot;) { ; adapted from Sean&#039;s code
	try Acc.accLocation(ComObj(0x4003,&amp;x:=0), ComObj(0x4003,&amp;y:=0), ComObj(0x4003,&amp;w:=0), ComObj(0x4003,&amp;h:=0), ChildId)
	catch
		return
	Position := &quot;x&quot; NumGet(x,0,&quot;int&quot;) &quot; y&quot; NumGet(y,0,&quot;int&quot;) &quot; w&quot; NumGet(w,0,&quot;int&quot;) &quot; h&quot; NumGet(h,0,&quot;int&quot;)
	return	{x:NumGet(x,0,&quot;int&quot;), y:NumGet(y,0,&quot;int&quot;), w:NumGet(w,0,&quot;int&quot;), h:NumGet(h,0,&quot;int&quot;)}
}
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&amp;p=509530#509530
	try return ComObj(9, ComObjQuery(Acc,&quot;{618736e0-3c3d-11cf-810c-00aa00389b71}&quot;), 1)
}
Acc_Error(p=&quot;&quot;) {
	static setting:=0
	return p=&quot;&quot;?setting:setting:=p
}
Acc_Children(Acc) {
	if ComObjType(Acc,&quot;Name&quot;) != &quot;IAccessible&quot;
		ErrorLevel := &quot;Invalid IAccessible Object&quot;
	else {
		Acc_Init(), cChildren:=Acc.accChildCount, Children:=[]
		if DllCall(&quot;oleacc\AccessibleChildren&quot;, &quot;Ptr&quot;,ComObjValue(Acc), &quot;Int&quot;,0, &quot;Int&quot;,cChildren, &quot;Ptr&quot;,VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&amp;varChildren, &quot;Int*&quot;,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 := &quot;AccessibleChildren DllCall Failed&quot;
	}
	if Acc_Error()
		throw Exception(ErrorLevel,-1)
}
Acc_ChildrenByRole(Acc, Role) {
	if ComObjType(Acc,&quot;Name&quot;)!=&quot;IAccessible&quot;
		ErrorLevel := &quot;Invalid IAccessible Object&quot;
	else {
		Acc_Init(), cChildren:=Acc.accChildCount, Children:=[]
		if DllCall(&quot;oleacc\AccessibleChildren&quot;, &quot;Ptr&quot;,ComObjValue(Acc), &quot;Int&quot;,0, &quot;Int&quot;,cChildren, &quot;Ptr&quot;,VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&amp;varChildren, &quot;Int*&quot;,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 := &quot;AccessibleChildren DllCall Failed&quot;
	}
	if Acc_Error()
		throw Exception(ErrorLevel,-1)
}
Acc_Get(Cmd, ChildPath=&quot;&quot;, ChildID=0, WinTitle=&quot;&quot;, WinText=&quot;&quot;, ExcludeTitle=&quot;&quot;, ExcludeText=&quot;&quot;) {
	static properties := {Action:&quot;DefaultAction&quot;, DoAction:&quot;DoDefaultAction&quot;, Keyboard:&quot;KeyboardShortcut&quot;}
	AccObj :=   IsObject(WinTitle)? WinTitle
			:   Acc_ObjectFromWindow( WinExist(WinTitle, WinText, ExcludeTitle, ExcludeText), 0 )
	if ComObjType(AccObj, &quot;Name&quot;) != &quot;IAccessible&quot;
		ErrorLevel := &quot;Could not access an IAccessible Object&quot;
	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 &quot;m2&quot; output in else-statement
				else
					RegExMatch(A_LoopField, &quot;(\D*)(\d*)&quot;, m), Children:=Acc_ChildrenByRole(AccObj, m1), m2:=(m2?m2:1)
				if Not Children.HasKey(m2)
					throw
				AccObj := Children[m2]
			} catch {
				ErrorLevel:=&quot;Cannot access ChildPath Item #&quot; A_Index &quot; -&gt; &quot; A_LoopField, Acc_Error(AccError)
				if Acc_Error()
					throw Exception(&quot;Cannot access ChildPath Item&quot;, -1, &quot;Item #&quot; A_Index &quot; -&gt; &quot; A_LoopField)
				return
			}
		Acc_Error(AccError)
		StringReplace, Cmd, Cmd, %A_Space%, , All
		properties.HasKey(Cmd)? Cmd:=properties[Cmd]:
		try {
			if (Cmd = &quot;Location&quot;)
				AccObj.accLocation(ComObj(0x4003,&amp;x:=0), ComObj(0x4003,&amp;y:=0), ComObj(0x4003,&amp;w:=0), ComObj(0x4003,&amp;h:=0), ChildId)
			  , ret_val := &quot;x&quot; NumGet(x,0,&quot;int&quot;) &quot; y&quot; NumGet(y,0,&quot;int&quot;) &quot; w&quot; NumGet(w,0,&quot;int&quot;) &quot; h&quot; NumGet(h,0,&quot;int&quot;)
			else if (Cmd = &quot;Object&quot;)
				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[&quot;acc&quot; Cmd]
			else
				ret_val := AccObj[&quot;acc&quot; Cmd](ChildID+0)
		} catch {
			ErrorLevel := &quot;&quot;&quot;&quot; Cmd &quot;&quot;&quot; Cmd Not Implemented&quot;
			if Acc_Error()
				throw Exception(&quot;Cmd Not Implemented&quot;, -1, Cmd)
			return
		}
		return ret_val, ErrorLevel:=0
	}
	if Acc_Error()
		throw Exception(ErrorLevel,-1)
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Wed, 03 Aug 2016 18:58:01 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106582#p106582</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106555#p106555</link>
			<description><![CDATA[<div class="codebox"><pre><code>   loop % file[1].length
   {
      fileName := file[1][A_Index-1][0]
      If RegexMatch(fileName, &quot;\.(avi|mpg|mp4|mkv)$&quot;) 
         msgbox % folder &quot;\&quot; fileName &quot;`nномер &quot; A_Index-1
   }</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Wed, 03 Aug 2016 13:22:48 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106555#p106555</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106554#p106554</link>
			<description><![CDATA[<p>Может возможно скрыть строки в которых не видео файлы, и сохранить правильные номера файлов?</p>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Wed, 03 Aug 2016 13:14:32 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106554#p106554</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106553#p106553</link>
			<description><![CDATA[<p><strong>Malcev</strong>, действительно ошибка была в использовании </p><div class="codebox"><pre><code>LV_ModifyCol(1, &quot;Sort&quot;) </code></pre></div><p> за комментировал и вроде ок. Спасибо.</p>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Wed, 03 Aug 2016 13:11:13 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106553#p106553</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106549#p106549</link>
			<description><![CDATA[<p><span style="color: green"><strong>OmTatSat</strong> проставьте заглавные буквы и точки. Обрамите ссылку кодом URL.</span></p>]]></description>
			<author><![CDATA[null@example.com (ypppu)]]></author>
			<pubDate>Wed, 03 Aug 2016 12:42:51 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106549#p106549</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106548#p106548</link>
			<description><![CDATA[<p>Ну так код из 31 поста это и показывает.<br />Замените его 2 последние строчки:<br /></p><div class="codebox"><pre><code>   loop % file[1].length
      msgbox % folder &quot;\&quot; file[1][A_Index-1][0] &quot;`nномер &quot; A_Index-1</code></pre></div><p>Во время тестирования вы сразу не поправляйте свой код, а возьмите только мой.<br />И если с ним всё ок, то ищите ошибку уже в вашем коде.<br />ЗЫ Ссылка у вас не оформлена.</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Wed, 03 Aug 2016 12:35:18 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106548#p106548</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106541#p106541</link>
			<description><![CDATA[<p><strong>Malcev</strong>, попробовал код с 31ого, то-есть поправил код на LV_Add(&quot;&quot;, folder &quot;\&quot; file1[1][A_Index-1][0]) было&nbsp; LV_Add(&quot;&quot;, file1[1][A_Index-1][0])<br />Ничего не поменялось, очередность осталась прежней но в списке появились не только названия файлов но и полный путь.<br />Похоже скрипт добавляет файлы в алфавитном порядке, а в торренте они получают номера вне алфавитного порядка<br />Вот к примеру раздача <a href="https://rutracker.org/forum/viewtopic.php?t=5020380">https://rutracker.org/forum/viewtopic.php?t=5020380</a><br />Попробуйте.<br />Открываю через торрент первую серию, номер у файла 20. Открываю через скрипт первую серию, номер у файла 0. Если бы название сериала начиналось не с &quot;P&quot; а с буквы после &quot;S&quot; то наверно файлы с папки &quot;subs&quot; были бы первыми, и всё было бы в рабочем виде а так перепуталось всё.</p>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Wed, 03 Aug 2016 12:00:30 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106541#p106541</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106534#p106534</link>
			<description><![CDATA[<p>Код из 31 поста должен показывать всё правильно.</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Wed, 03 Aug 2016 10:43:00 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106534#p106534</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106527#p106527</link>
			<description><![CDATA[<p>Есть проблема, если в раздаче есть субтитры то номер строки не равняется номеру этого файла в торрент раздаче, может есть идеи как это можно побороть? Может можно как-то получить номер файла в раздаче?</p>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Wed, 03 Aug 2016 06:51:04 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106527#p106527</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106136#p106136</link>
			<description><![CDATA[<p>Настройки торрента для просмотра онлайн:<br />&gt; Preferences &gt; Advanced &gt; bt.prio_first_last_piece - true<br />Зажать Shift+f2 &gt; Preferences &gt; Advanced &gt; bt.sequential_download - true <a href="http://blog.ruzzz.com/2010/02/utorrent-sequential-download.html">http://blog.ruzzz.com/2010/02/utorrent- … nload.html</a><br />Может кто-то знает ещё настройки для оптимизации просмотра онлайн?<br /></p><div class="codebox"><pre><code>; Допгуи будет сразу автоскрываться если имя скрипта отлично от 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 бывает работает не с первого запуска, наверное связано с тем, что не хватает каких-то &quot;служебных&quot; данных видео. 
; Так как программа uTorrent запускает Stream в 2 этапа: 1 нажатие - запускается таймер с надписью &quot;готово через ...&quot; 
; после истечения времени таймера, кнопка &quot;поток&quot; заново появляется. 2 нажатие - запуск stream. DLMB запускает второй этап минуя первый.
; upd. УСТРАНЯЕТСЯ УСТАНОВКОЙ POTPLAYER 1.6.62377 - индексирует недокачанный файл как гомплеер и перемотка работает!)
; RMB - открыть окно программы uTorrent и переместить мышь в окно.
; DRMB - перезагрузить uTorrent (если раздача плохо качается - бывает помогает)
; MMB - пауза/запуск всех торрентов

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

global ip := &quot;127.0.0.1&quot;
global port := &quot;8080&quot;
global user := &quot;admin&quot;
global pass := &quot;pass&quot;





SetTitleMatchMode, 2
DetectHiddenWindows, On
Gui, Color, 000000 
Gui, -SysMenu -ToolWindow -Caption -Border +AlwaysOnTop ; (+E0x20 - клик сквозь)
Gui +LastFound 
hWnd:=WinExist()
DllCall(&quot;SetClassLong&quot;,&quot;UInt&quot;,hWnd,&quot;Int&quot;,-26,&quot;UInt&quot;,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, &quot;WM_LBUTTONDOWN&quot;)
OnMessage(0x203,&quot;WM_LBUTTONDBLCLK&quot;)
onmessage(0x207,&quot;WM_MBUTTONDOWN&quot;)
onmessage(0x204,&quot;WM_RBUTTONDOWN&quot;)
OnMessage(0x206,&quot;WM_RBUTTONDBLCLK&quot;)
OnMessage(0x100, &quot;WM_KEYDOWN&quot;)

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

       a = 1
       
    }
    ;MsgBox, multivideo %multivideo% video %video%
    return
}
    
    if ((video = 0) &amp; (multivideo = 0)) 
{
    run, %path1%
        return
}
    if ((video = 0) &amp; (multivideo = 1)) 
{
    run, %path1%
        return
}
    if ((video = 1) &amp; (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(&quot;&quot;, file1[1][A_Index-1][0])


LV_ModifyCol(1, &quot;Sort&quot;)  ; 
;LV_ModifyCol(2, &quot;Integer&quot;)  ; 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(&quot;LButton&quot;,&quot;P&quot;))
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(&quot;0&quot;)
	;MsgBox клик в пустоту %A_EventInfo%. Text: &quot;%RowNumber%&quot; %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(&quot;0&quot;)
	Run, % vlc &quot; &quot; urlVlc &quot;?sid=&quot; sid &quot;&amp;file=&quot; RowNumber -1
    ;MsgBox You clicked row number %A_EventInfo%. Text: &quot;%RowNumber%&quot; %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(&quot;0&quot;)
   
  
   if ((click = 1) &amp; (dblclk = 0) &amp; (multivideo = 0)) 
    run %path%	
     if ((click = 1) &amp; (dblclk = 0) &amp; (multivideo = 1)) 
    run %path1%	
    
   if ((click = 1) &amp; (dblclk = 1) &amp; (global RowNumber != 0)) 
global rundblclk = 1
;if ((click = 1) &amp; (dblclk = 1) &amp; (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( &quot;PostMessage&quot;, 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( &quot;PostMessage&quot;, 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( &quot;PostMessage&quot;, 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 := &quot;http://&quot; ip &quot;:&quot; port &quot;/gui/&quot;
global vlc := &quot;C:\Program Files\DAUM\PotPlayer\PotPlayerMini64.exe&quot;
;global vlc := &quot;C:\Program Files (x86)\PotPlayer\PotPlayerMini.exe&quot;
global urlVlc := &quot;http://&quot; ip &quot;:&quot; port &quot;/proxy&quot;
tokenUrl := url &quot;token.html&quot;
action := &quot;?list=1&quot;
HTTP := ComObjCreate(&quot;WinHTTP.WinHTTPRequest.5.1&quot;)

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

HTTP.Open(&quot;GET&quot;, tokenUrl, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
token := &quot;&amp;token=&quot; RegExReplace(HTTP.ResponseText, &quot;&lt;.+?&gt;&quot;)
HTTP.Open(&quot;GET&quot;, 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, &quot;uint&quot;)
pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, &quot;ptr&quot;)
;MsgBox, % StrGet(pText, cBytes, &quot;utf-8&quot;) 
;msgbox % HTTP.ResponseText
JsonString := StrGet(pText, cBytes, &quot;utf-8&quot;)
JS := new ActiveScript(&quot;JScript&quot;)
JS.eval(&quot;delete ActiveXObject; delete GetObject;&quot;) 
ComObjError(false)
obj := JS.eval(&quot;(&quot; . JsonString . &quot;)&quot;).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}])&#039;&#039;, match)
  ;  global mm := % multiornot &quot;,([0-9])&quot;
  ;  ToolTip, mm = %mm%
  ;  OutputVar := % StrGet(pText, cBytes, &quot;utf-8&quot;) 
;OutputVar := &quot;12.456 h/ 5673 567-&quot;
;var1 := RegExMatch(OutputVar, mm, mattch)
;var1 := RegExMatch(OutputVar, &quot;%mm%([a-zA-Z0-9{7}])&quot;, match)
;if (match2 != &quot;М&quot; &amp;&amp; match1 &lt; 10)
;MsgBox % mattch1 &quot;`n&quot; mattch &quot;`n&quot; mattch3 &quot;`n var1=&quot; var1 &quot;`n&quot; 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 := &quot;?action=getfiles&amp;hash=&quot; hash 
   
   Process, Exist, uTorrent.exe
status = %ErrorLevel% 
if status = 0
   {
run, &quot;C:\staff\margin\margin hsi.exe&quot; &quot;C:\staff\margin\destroy margin 0.hss&quot; ; убрать кусок отрезаного от приложений экрана
Process, close, uTorrent_osd.exe
ExitApp
   }
    
   
   HTTP.Open(&quot;GET&quot;, 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, &quot;uint&quot;)
   pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, &quot;ptr&quot;)
   JsonString := StrGet(pText, cBytes, &quot;utf-8&quot;)
   file := JS.eval(&quot;(&quot; . JsonString . &quot;)&quot;).files
    global file1 := JS.eval(&quot;(&quot; . JsonString . &quot;)&quot;).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 &quot;мб&quot;
   t = % obj[A_Index - 1][10]/60
   loop % file[1].length
{
   Global path1 := % folder ; &quot;\&quot; file[1][A_Index-1][0]
   Global path := % folder &quot;\&quot; file[1][A_Index-1][0]
}

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


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


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




;tnorm := RegExReplace(t, &quot;\D&quot;)

;MsgBox % var

;MsgBox % NewVar




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

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



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

        minn = % minnogood*60/100
        RegExMatch(minn, &quot;\.(..)&quot;, min)
        ;MsgBox, = %min1%
        
       ; ToolTip, hournotnorm %hournotnorm% hour %hour% hour1 %hour1% tnorm %tnorm% tnotnorm %tnotnorm% tnorm %tnorm% minnogood1 %minnogood1%
        }
    else
    {
        hour =
        RegExMatch(t, &quot;\d+&quot;, tnorm)
   ; SetFormat, FloatFast, 0.2
    RegExMatch(tnorm/60, &quot;\.([0-9])&quot;, minnogood)
;ToolTip tnorm %tnorm% minnogood %minnogood%
    min1 = % tnorm
    ;RegExMatch(minn, &quot;\.(..)&quot;, 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 &quot;мб/с&quot;
   if s &lt; 1
    {
    SetFormat, FloatFast, 0.0
    s = % obj[A_Index - 1][9]/1000 &quot;кб/с&quot;
    }
    ; ---------------------------------------------------------Защита от зависания скачки
    
    if ((s = &quot;0кб/с&quot;) &amp; (state != &quot;Пауза&quot;))
    {
        ;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, &quot;C:\staff\margin\margin hsi.exe&quot; &quot;C:\staff\margin\destroy margin 0.hss&quot; ; убрать кусок отрезаного от приложений экрана
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&#039;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(&quot;Invalid language&quot;, -1, Language)
        this._site := new ActiveScriptSite(this)
        this._SetScriptSite(this._site.ptr)
        this._InitNew()
        this._objects := {}
        this.Error := &quot;&quot;
        this._dsp := this._GetScriptDispatch()  ; Must be done last.
        try
            if this.ScriptEngine() = &quot;JScript&quot;
                this.SetJScript58()
    }

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

class ActiveScriptSite
{
    __New(Script)
    {
        ObjSetCapacity(this, &quot;_site&quot;, 3 * A_PtrSize)
        NumPut(&amp;Script
        , NumPut(ActiveScriptSite._vftable(&quot;_vft_w&quot;, &quot;31122&quot;, 0x100)
        , NumPut(ActiveScriptSite._vftable(&quot;_vft&quot;, &quot;31125232211&quot;, 0)
            , this.ptr := ObjGetAddress(this, &quot;_site&quot;))))
    }
    
    _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(&quot;_ActiveScriptSite&quot;, &quot;F&quot;, 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 &amp; 0xFF
    if A_EventInfo &gt;= 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 = &quot;{00000000-0000-0000-C000-000000000046}&quot;  ; IUnknown
         || iid = &quot;{DB01A1E3-A42B-11cf-8F20-00805F2CD064}&quot;) ; IActiveScriptSite
        {
            NumPut(this, a2+0)
            return 0 ; S_OK
        }
        if (iid = &quot;{D10F6761-83E9-11cf-8F20-00805F2CD064}&quot;) ; 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, &quot;UTF-16&quot;)
        , (a3 &amp;&amp; NumPut(0, a3+0))  ; *ppiunkItem := NULL
        , (a4 &amp;&amp; NumPut(0, a4+0))  ; *ppti := NULL
        if (a2 &amp; 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&#039;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&#039;t require implementations.
    return 0x80004001 ; E_NOTIMPL
}

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

}

;sleep 1000

}

}
} ;
return 



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


#IfWinActive  ahk_exe uTorrent.exe
~LButton::
;if GetTextUnderMouse() = Выход
{
CoordMode, Mouse, Screen
MouseGetPos, m_x, m_y, m_hw_target
SendMessage, 0x84,, ( m_y &lt;&lt; 16 )|m_x,, ahk_id %m_hw_target%
;ToolTip, % errorlevel
if errorlevel = 1
{
    ;MsgBox, % GetTextUnderMouse()
   
    if GetTextUnderMouse() = &quot;Выход&quot;
    {
         run, &quot;C:\staff\margin\margin hsi.exe&quot; &quot;C:\staff\margin\destroy margin 0.hss&quot; ; убрать кусок отрезаного от приложений экрана
      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) --&gt; (9,pacc,1)
; 	Changed ComObjUnwrap to ComObjValue in order to avoid AddRef (thanks fincs)
; 	Added Acc_GetRoleText &amp; 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(&quot;LoadLibrary&quot;,&quot;Str&quot;,&quot;oleacc&quot;,&quot;Ptr&quot;)
}
Acc_ObjectFromEvent(ByRef _idChild_, hWnd, idObject, idChild)
{
	Acc_Init()
	If	DllCall(&quot;oleacc\AccessibleObjectFromEvent&quot;, &quot;Ptr&quot;, hWnd, &quot;UInt&quot;, idObject, &quot;UInt&quot;, idChild, &quot;Ptr*&quot;, pacc, &quot;Ptr&quot;, VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&amp;varChild)=0
	Return	ComObjEnwrap(9,pacc,1), _idChild_:=NumGet(varChild,8,&quot;UInt&quot;)
}

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

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

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

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

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

Acc_SetWinEventHook(eventMin, eventMax, pCallback)
{
	Return	DllCall(&quot;SetWinEventHook&quot;, &quot;Uint&quot;, eventMin, &quot;Uint&quot;, eventMax, &quot;Uint&quot;, 0, &quot;Ptr&quot;, pCallback, &quot;Uint&quot;, 0, &quot;Uint&quot;, 0, &quot;Uint&quot;, 0)
}

Acc_UnhookWinEvent(hHook)
{
	Return	DllCall(&quot;UnhookWinEvent&quot;, &quot;Ptr&quot;, hHook)
}
/*	Win Events:
	pCallback := RegisterCallback(&quot;WinEventProc&quot;)
	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,&quot;Name&quot;)=&quot;IAccessible&quot;?Acc_GetRoleText(Acc.accRole(ChildId)):&quot;invalid object&quot;
}
Acc_State(Acc, ChildId=0) {
	try return ComObjType(Acc,&quot;Name&quot;)=&quot;IAccessible&quot;?Acc_GetStateText(Acc.accState(ChildId)):&quot;invalid object&quot;
}
Acc_Location(Acc, ChildId=0, byref Position=&quot;&quot;) { ; adapted from Sean&#039;s code
	try Acc.accLocation(ComObj(0x4003,&amp;x:=0), ComObj(0x4003,&amp;y:=0), ComObj(0x4003,&amp;w:=0), ComObj(0x4003,&amp;h:=0), ChildId)
	catch
		return
	Position := &quot;x&quot; NumGet(x,0,&quot;int&quot;) &quot; y&quot; NumGet(y,0,&quot;int&quot;) &quot; w&quot; NumGet(w,0,&quot;int&quot;) &quot; h&quot; NumGet(h,0,&quot;int&quot;)
	return	{x:NumGet(x,0,&quot;int&quot;), y:NumGet(y,0,&quot;int&quot;), w:NumGet(w,0,&quot;int&quot;), h:NumGet(h,0,&quot;int&quot;)}
}
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&amp;p=509530#509530
	try return ComObj(9, ComObjQuery(Acc,&quot;{618736e0-3c3d-11cf-810c-00aa00389b71}&quot;), 1)
}
Acc_Error(p=&quot;&quot;) {
	static setting:=0
	return p=&quot;&quot;?setting:setting:=p
}
Acc_Children(Acc) {
	if ComObjType(Acc,&quot;Name&quot;) != &quot;IAccessible&quot;
		ErrorLevel := &quot;Invalid IAccessible Object&quot;
	else {
		Acc_Init(), cChildren:=Acc.accChildCount, Children:=[]
		if DllCall(&quot;oleacc\AccessibleChildren&quot;, &quot;Ptr&quot;,ComObjValue(Acc), &quot;Int&quot;,0, &quot;Int&quot;,cChildren, &quot;Ptr&quot;,VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&amp;varChildren, &quot;Int*&quot;,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 := &quot;AccessibleChildren DllCall Failed&quot;
	}
	if Acc_Error()
		throw Exception(ErrorLevel,-1)
}
Acc_ChildrenByRole(Acc, Role) {
	if ComObjType(Acc,&quot;Name&quot;)!=&quot;IAccessible&quot;
		ErrorLevel := &quot;Invalid IAccessible Object&quot;
	else {
		Acc_Init(), cChildren:=Acc.accChildCount, Children:=[]
		if DllCall(&quot;oleacc\AccessibleChildren&quot;, &quot;Ptr&quot;,ComObjValue(Acc), &quot;Int&quot;,0, &quot;Int&quot;,cChildren, &quot;Ptr&quot;,VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&amp;varChildren, &quot;Int*&quot;,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 := &quot;AccessibleChildren DllCall Failed&quot;
	}
	if Acc_Error()
		throw Exception(ErrorLevel,-1)
}
Acc_Get(Cmd, ChildPath=&quot;&quot;, ChildID=0, WinTitle=&quot;&quot;, WinText=&quot;&quot;, ExcludeTitle=&quot;&quot;, ExcludeText=&quot;&quot;) {
	static properties := {Action:&quot;DefaultAction&quot;, DoAction:&quot;DoDefaultAction&quot;, Keyboard:&quot;KeyboardShortcut&quot;}
	AccObj :=   IsObject(WinTitle)? WinTitle
			:   Acc_ObjectFromWindow( WinExist(WinTitle, WinText, ExcludeTitle, ExcludeText), 0 )
	if ComObjType(AccObj, &quot;Name&quot;) != &quot;IAccessible&quot;
		ErrorLevel := &quot;Could not access an IAccessible Object&quot;
	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 &quot;m2&quot; output in else-statement
				else
					RegExMatch(A_LoopField, &quot;(\D*)(\d*)&quot;, m), Children:=Acc_ChildrenByRole(AccObj, m1), m2:=(m2?m2:1)
				if Not Children.HasKey(m2)
					throw
				AccObj := Children[m2]
			} catch {
				ErrorLevel:=&quot;Cannot access ChildPath Item #&quot; A_Index &quot; -&gt; &quot; A_LoopField, Acc_Error(AccError)
				if Acc_Error()
					throw Exception(&quot;Cannot access ChildPath Item&quot;, -1, &quot;Item #&quot; A_Index &quot; -&gt; &quot; A_LoopField)
				return
			}
		Acc_Error(AccError)
		StringReplace, Cmd, Cmd, %A_Space%, , All
		properties.HasKey(Cmd)? Cmd:=properties[Cmd]:
		try {
			if (Cmd = &quot;Location&quot;)
				AccObj.accLocation(ComObj(0x4003,&amp;x:=0), ComObj(0x4003,&amp;y:=0), ComObj(0x4003,&amp;w:=0), ComObj(0x4003,&amp;h:=0), ChildId)
			  , ret_val := &quot;x&quot; NumGet(x,0,&quot;int&quot;) &quot; y&quot; NumGet(y,0,&quot;int&quot;) &quot; w&quot; NumGet(w,0,&quot;int&quot;) &quot; h&quot; NumGet(h,0,&quot;int&quot;)
			else if (Cmd = &quot;Object&quot;)
				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[&quot;acc&quot; Cmd]
			else
				ret_val := AccObj[&quot;acc&quot; Cmd](ChildID+0)
		} catch {
			ErrorLevel := &quot;&quot;&quot;&quot; Cmd &quot;&quot;&quot; Cmd Not Implemented&quot;
			if Acc_Error()
				throw Exception(&quot;Cmd Not Implemented&quot;, -1, Cmd)
			return
		}
		return ret_val, ErrorLevel:=0
	}
	if Acc_Error()
		throw Exception(ErrorLevel,-1)
}</code></pre></div><p>uTorrent положить в C:\Program Files (x86)\uTorrent\ <a href="http://forum.script-coding.com/misc.php?action=pun_attachment&amp;item=1197&amp;download=1">http://forum.script-coding.com/misc.php … download=1</a><br />margin распаковать в C:\staff\margin\</p>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Sun, 17 Jul 2016 21:46:18 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106136#p106136</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106092#p106092</link>
			<description><![CDATA[<p>Доделал доп гуи выбора видео, если кликнуть на пустое место допгуи, то оно закроется и скрипт продолжит работу. <br />Как ещё бы добавить, чтобы доп гуи закрывалось к примеру если кликнуть вообще на другое окно?</p><p>Добавил адаптацию под разные разрешение экранов. И так, по мелочам...</p><div class="codebox"><pre><code>#NoTrayIcon
#NoEnv
#SingleInstance, force


global ip := &quot;127.0.0.1&quot;
global port := &quot;8080&quot;
global user := &quot;admin&quot;
global pass := &quot;pass&quot;

SetTitleMatchMode, 2
DetectHiddenWindows, On
Gui, Color, 000000 
Gui, -SysMenu -ToolWindow -Caption -Border +AlwaysOnTop ; (+E0x20 - клик сквозь)
Gui +LastFound 
hWnd:=WinExist()
DllCall(&quot;SetClassLong&quot;,&quot;UInt&quot;,hWnd,&quot;Int&quot;,-26,&quot;UInt&quot;,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, &quot;WM_LBUTTONDOWN&quot;)
OnMessage(0x203,&quot;WM_LBUTTONDBLCLK&quot;)
onmessage(0x207,&quot;WM_MBUTTONDOWN&quot;)
onmessage(0x204,&quot;WM_RBUTTONDOWN&quot;)
OnMessage(0x100, &quot;WM_KEYDOWN&quot;)

;MsgBox, needw = %needx_text% needh = %needh% h-%ssh%
WM_LBUTTONDBLCLK()
{	
	Global click := 2
   ;ToolTip, % vlc &quot; &quot; urlVlc &quot;?sid=&quot; sid &quot;&amp;file=0&quot;
	;return
      ;MsgBox, multivideo %multivideo% video %video%
  if ((video = 1) &amp; (multivideo = 0)) 
{
   Run, % vlc &quot; &quot; urlVlc &quot;?sid=&quot; sid &quot;&amp;file=0&quot;
    ;MsgBox, multivideo %multivideo% video %video%
    return
}
    
    if ((video = 0) &amp; (multivideo = 0)) 
{
    run, %path1%
        return
}
    if ((video = 0) &amp; (multivideo = 1)) 
{
    run, %path1%
        return
}
    if ((video = 1) &amp; (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(&quot;&quot;, file[1][A_Index-1][0])


;LV_ModifyCol()  ; Auto-size each column to fit its contents.
LV_ModifyCol(2, &quot;Integer&quot;)  ; 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(&quot;LButton&quot;,&quot;P&quot;))
Loop
{
    ;ToolTip, while a=%a% `n dblclkmylistview = %dblclk% `n rundblclk= %rundblclk%
    ;sleep 200
    
    
    if canceldblclk = 1 
    {
       Gui,2:default
	global RowNumber := LV_GetNext(&quot;0&quot;)
	;MsgBox клик в пустоту %A_EventInfo%. Text: &quot;%RowNumber%&quot; %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(&quot;0&quot;)
	Run, % vlc &quot; &quot; urlVlc &quot;?sid=&quot; sid &quot;&amp;file=&quot; RowNumber -1
    ;MsgBox You clicked row number %A_EventInfo%. Text: &quot;%RowNumber%&quot; %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(&quot;0&quot;)
   
  
   if ((click = 1) &amp; (dblclk = 0))
    run %path1%	
   if ((click = 1) &amp; (dblclk = 1) &amp; (global RowNumber != 0)) 
global rundblclk = 1
if ((click = 1) &amp; (dblclk = 1) &amp; (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( &quot;PostMessage&quot;, 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( &quot;PostMessage&quot;, 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( &quot;PostMessage&quot;, 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 := &quot;http://&quot; ip &quot;:&quot; port &quot;/gui/&quot;
global vlc := &quot;C:\Program Files\DAUM\PotPlayer\PotPlayerMini64.exe&quot;
global urlVlc := &quot;http://&quot; ip &quot;:&quot; port &quot;/proxy&quot;
tokenUrl := url &quot;token.html&quot;
action := &quot;?list=1&quot;
HTTP := ComObjCreate(&quot;WinHTTP.WinHTTPRequest.5.1&quot;)

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

HTTP.Open(&quot;GET&quot;, tokenUrl, false)
HTTP.SetCredentials(user, pass, 0)
HTTP.Send()
token := &quot;&amp;token=&quot; RegExReplace(HTTP.ResponseText, &quot;&lt;.+?&gt;&quot;)
HTTP.Open(&quot;GET&quot;, 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, &quot;uint&quot;)
pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, &quot;ptr&quot;)
;MsgBox, % StrGet(pText, cBytes, &quot;utf-8&quot;) 
;msgbox % HTTP.ResponseText
JsonString := StrGet(pText, cBytes, &quot;utf-8&quot;)
JS := new ActiveScript(&quot;JScript&quot;)
JS.eval(&quot;delete ActiveXObject; delete GetObject;&quot;) 
obj := JS.eval(&quot;(&quot; . JsonString . &quot;)&quot;).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}])&#039;&#039;, match)
  ;  global mm := % multiornot &quot;,([0-9])&quot;
  ;  ToolTip, mm = %mm%
  ;  OutputVar := % StrGet(pText, cBytes, &quot;utf-8&quot;) 
;OutputVar := &quot;12.456 h/ 5673 567-&quot;
;var1 := RegExMatch(OutputVar, mm, mattch)
;var1 := RegExMatch(OutputVar, &quot;%mm%([a-zA-Z0-9{7}])&quot;, match)
;if (match2 != &quot;М&quot; &amp;&amp; match1 &lt; 10)
;MsgBox % mattch1 &quot;`n&quot; mattch &quot;`n&quot; mattch3 &quot;`n var1=&quot; var1 &quot;`n&quot; 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 := &quot;?action=getfiles&amp;hash=&quot; hash 
   
   Process, Exist, uTorrent.exe
status = %ErrorLevel% 
if status = 0
   {
run, &quot;C:\staff\margin\margin hsi.exe&quot; &quot;C:\staff\margin\destroy margin 0.hss&quot; ; убрать кусок отрезаного от приложений экрана
Process, close, uTorrent_osd.exe
ExitApp
}
   
   
   HTTP.Open(&quot;GET&quot;, 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, &quot;uint&quot;)
   pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, &quot;ptr&quot;)
   JsonString := StrGet(pText, cBytes, &quot;utf-8&quot;)
   global file := JS.eval(&quot;(&quot; . JsonString . &quot;)&quot;).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 ; &quot;\&quot; file[1][A_Index-1][0]
   
   loop % file[1].length
{
   If RegexMatch(file[1][A_Index-1][0], &quot;\.(avi|mpg|mp4|mkv)$&quot;) 
      Global video := 1
  }
      
    IfInString, path1, %n%
      Global multivideo := 1 
      
   IfnotInString, path1, %n%
      Global multivideo := 0
   
  
   
;Run, % vlc &quot; &quot; urlVlc &quot;?sid=&quot; sid &quot;&amp;file=0&quot; ; A_Index-1
     ; Msgbox play %urlVlc%


var1 := RegExMatch(p, &quot;(.*)\.&quot;, match)
if t contains -
{
var2 := RegExMatch(t, &quot;-(.*)&quot;, 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, &quot;C:\staff\margin\margin hsi.exe&quot; &quot;C:\staff\margin\margin bottom 15.hss&quot;
    
}

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&#039;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(&quot;Invalid language&quot;, -1, Language)
        this._site := new ActiveScriptSite(this)
        this._SetScriptSite(this._site.ptr)
        this._InitNew()
        this._objects := {}
        this.Error := &quot;&quot;
        this._dsp := this._GetScriptDispatch()  ; Must be done last.
        try
            if this.ScriptEngine() = &quot;JScript&quot;
                this.SetJScript58()
    }

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

class ActiveScriptSite
{
    __New(Script)
    {
        ObjSetCapacity(this, &quot;_site&quot;, 3 * A_PtrSize)
        NumPut(&amp;Script
        , NumPut(ActiveScriptSite._vftable(&quot;_vft_w&quot;, &quot;31122&quot;, 0x100)
        , NumPut(ActiveScriptSite._vftable(&quot;_vft&quot;, &quot;31125232211&quot;, 0)
            , this.ptr := ObjGetAddress(this, &quot;_site&quot;))))
    }
    
    _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(&quot;_ActiveScriptSite&quot;, &quot;F&quot;, 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 &amp; 0xFF
    if A_EventInfo &gt;= 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 = &quot;{00000000-0000-0000-C000-000000000046}&quot;  ; IUnknown
         || iid = &quot;{DB01A1E3-A42B-11cf-8F20-00805F2CD064}&quot;) ; IActiveScriptSite
        {
            NumPut(this, a2+0)
            return 0 ; S_OK
        }
        if (iid = &quot;{D10F6761-83E9-11cf-8F20-00805F2CD064}&quot;) ; 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, &quot;UTF-16&quot;)
        , (a3 &amp;&amp; NumPut(0, a3+0))  ; *ppiunkItem := NULL
        , (a4 &amp;&amp; NumPut(0, a4+0))  ; *ppti := NULL
        if (a2 &amp; 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&#039;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&#039;t require implementations.
    return 0x80004001 ; E_NOTIMPL
}

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

}

sleep 3000

}

}

return 



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


</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Thu, 14 Jul 2016 07:14:53 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106092#p106092</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106091#p106091</link>
			<description><![CDATA[<p>Получилась проверка на много файловость.</p><p> </p><div class="codebox"><pre><code>Global n = % obj[A_Index - 1][2]
   
   Global path1 := % folder ; &quot;\&quot; file[1][A_Index-1][0]
   
   loop % file[1].length
{
   If RegexMatch(file[1][A_Index-1][0], &quot;\.(avi|mpg|mp4|mkv)$&quot;) 
      Global video := 1
  }
      
    IfInString, path1, %n%
      Global multivideo := 1 
      
   IfnotInString, path1, %n%
      Global multivideo := 0</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Wed, 13 Jul 2016 19:52:51 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106091#p106091</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106090#p106090</link>
			<description><![CDATA[<p>Оказывается, чтобы список добавился в мой код не хватало лишь.</p><div class="codebox"><pre><code>global file := JS.eval(&quot;(&quot; . JsonString . &quot;)&quot;).files</code></pre></div><p>А точнее global.</p>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Wed, 13 Jul 2016 17:34:48 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106090#p106090</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106089#p106089</link>
			<description><![CDATA[<p>Чтобы знать или есть в торрент раздаче папка, если есть, значит в торренте больше одного файла, в этом случае нужен гуи выбора файла. Если файл на раздачу один, то гуи не нужен, пусть сразу запускается стрим.</p>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Wed, 13 Jul 2016 17:33:33 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106089#p106089</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Прогресс бар скачивания торрент файла с программы uTorrent]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106088#p106088</link>
			<description><![CDATA[<p>А зачем?</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Wed, 13 Jul 2016 17:27:30 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106088#p106088</guid>
		</item>
	</channel>
</rss>
