<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Оповещение о завершении синхронизации Google Drive]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=11450&amp;type=atom" />
	<updated>2016-12-20T01:24:42Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=11450</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Оповещение о завершении синхронизации Google Drive]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=109945#p109945" />
			<content type="html"><![CDATA[<p>Подскажите, пожалуйста, как правильно добавить в <strong>checkSync </strong> из последнего сценария от <strong>mafckz </strong>перечисление нескольких различных клиентов (программ) и соответствующих сообщений для них? Например, &quot;Yandex.Disk: Synced&quot; для YandexDisk.exe. Спасибо!</p>]]></content>
			<author>
				<name><![CDATA[becauseim]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33149</uri>
			</author>
			<updated>2016-12-20T01:24:42Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=109945#p109945</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Оповещение о завершении синхронизации Google Drive]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102101#p102101" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>becauseim пишет:</cite><blockquote><p>А можно ли установить проверку лишь на тот случай, если фалы синхронизировались как минимум пять минут?</p></blockquote></div><div class="codebox"><pre><code>#SingleInstance Force

syncTime := 10000  ; время синхронизации в милисекундах, больше которого выводить сообщение
sync := false

#Persistent
SetTimer checkSync, 100  ; милисекунды

checkSync:
googleDrive := TrayIcon_GetInfo(&quot;googledrivesync.exe&quot;)
if (InStr(googleDrive[1].tooltip, &quot;Sync complete&quot;) || InStr(googleDrive[1].tooltip, &quot;Синхронизация завершена&quot;))
{
	if sync
	{
		sync := false
		if ( (A_TickCount - StartTime) &gt; syncTime )
		{
			SetTimer checkSync, off
			
			MsgBox Sync Complete! Синхронизация завершена!
			
			SetTimer checkSync, on
		}
	}
}
else
{
	if !sync
	{
		sync := true
		StartTime := A_TickCount
	}
}
return


;// ниже идет сама библиотека

; ----------------------------------------------------------------------------
TrayIcon_GetInfo(sExeName:=&quot;&quot;) {
    d := A_DetectHiddenWindows
	DetectHiddenWindows, On   

    oTrayInfo := Object()
	For key, sTrayP in [&quot;Shell_TrayWnd&quot;, &quot;NotifyIconOverflowWindow&quot;]
    {	
        idxTB := TrayIcon_GetTrayBar()
        WinGet, pidTaskbar, PID, ahk_class %sTrayP%

        hProc := DllCall( &quot;OpenProcess&quot;,    UInt,0x38, Int,0, UInt,pidTaskbar                       )
        pRB   := DllCall( &quot;VirtualAllocEx&quot;, Ptr,hProc, Ptr,0, UInt,20,        UInt,0x1000, UInt,0x4 )

        szBtn := VarSetCapacity( btn, (A_Is64bitOS) ? 32 : 24, 0 )
        szNfo := VarSetCapacity( nfo, (A_Is64bitOS) ? 32 : 24, 0 )
        szTip := VarSetCapacity( tip, 128 * 2,                 0 )

        SendMessage, 0x418, 0, 0, ToolbarWindow32%idxTB%, ahk_class %sTrayP% ; TB_BUTTONCOUNT
        Loop, %ErrorLevel%
        {
            SendMessage, 0x417, A_Index - 1, pRB, ToolbarWindow32%idxTB%, ahk_class %sTrayP% ; TB_GETBUTTON

            DllCall( &quot;ReadProcessMemory&quot;, Ptr,hProc, Ptr,pRB, Ptr,&amp;btn, UInt,szBtn, UInt,0 )

            iBitmap	:= NumGet( btn, 0                       )
            idCmd   := NumGet( btn, 4                       )
            Statyle := NumGet( btn, 8                       )
            dwData	:= NumGet( btn, (A_Is64bitOS) ? 16 : 12 )
            iString	:= NumGet( btn, (A_Is64bitOS) ? 24 : 16 )

            DllCall( &quot;ReadProcessMemory&quot;, Ptr,hProc, Ptr,dwData, Ptr,&amp;nfo, UInt,szNfo, UInt,0 )

            hWnd  := NumGet( nfo, 0                       )
            uID	  := NumGet( nfo, (A_Is64bitOS) ? 8  : 4  )
            nMsg  := NumGet( nfo, (A_Is64bitOS) ? 12 : 8  )
            hIcon := NumGet( nfo, (A_Is64bitOS) ? 24 : 20 )

            WinGet,      pid,      PID,         ahk_id %hWnd%
            WinGet,      sProcess, ProcessName, ahk_id %hWnd%
            WinGetClass, sClass,                ahk_id %hWnd%

            If ( !sExeName || (sExeName == sProcess) || (sExeName == pid) )
                DllCall( &quot;ReadProcessMemory&quot;, Ptr,hProc, Ptr,iString, Ptr,&amp;tip, UInt,szTip, UInt,0 )
              , oTrayInfo.Insert({ &quot;idx&quot;: A_Index-1, &quot;idcmd&quot;: idCmd, &quot;pid&quot;: pid, &quot;uid&quot;: uID, &quot;msgid&quot;: nMsg
                                 , &quot;hicon&quot;: hIcon, &quot;hwnd&quot;: hWnd, &quot;class&quot;: sClass, &quot;process&quot;: sProcess
                                 , &quot;tooltip&quot;: StrGet(&amp;tip, &quot;UTF-16&quot;), &quot;place&quot;: sTrayP })
        }
        
        DllCall( &quot;VirtualFreeEx&quot;, Ptr,hProc, Ptr,pRB, UInt,0, UInt,0x8000 )
        DllCall( &quot;CloseHandle&quot;,   Ptr,hProc                               )
	}
	DetectHiddenWindows, %d%
	Return oTrayInfo
}

TrayIcon_Hide(idCmd, sTrayP:=&quot;Shell_TrayWnd&quot;, bHide:=True) {
    d := A_DetectHiddenWindows
	DetectHiddenWindows, On
	idxTB := TrayIcon_GetTrayBar()
	SendMessage, 0x404, idCmd, bHide, ToolbarWindow32%idxTB%, ahk_class %sTrayP% ; TB_HIDEBUTTON
	SendMessage, 0x1A, 0, 0, , ahk_class %sTrayP%
    DetectHiddenWindows, %d%
}

TrayIcon_Remove(hWnd, uID) {
	sz := VarSetCapacity( NID, (A_PtrSize == 4) ? 832 : 848, 0 )
	NumPut( sz, NID, 0 ), NumPut( hWnd, NID, A_PtrSize ), NumPut( uID, NID, A_PtrSize*2 )
	DllCall( &quot;Shell32.dll\Shell_NotifyIcon&quot;, UInt,2, Ptr,&amp;NID )
}

TrayIcon_Delete(idx, sTrayP:=&quot;Shell_TrayWnd&quot;) {
    d := A_DetectHiddenWindows
	DetectHiddenWindows, On
	idxTB := TrayIcon_GetTrayBar()
	SendMessage, 0x416, idx, 0, ToolbarWindow32%idxTB%, ahk_class %sTrayP% ; TB_DELETEBUTTON
	SendMessage, 0x1A, 0, 0, , ahk_class %sTrayP%
	DetectHiddenWindows, %d%
}

TrayIcon_Move(idxOld, idxNew, sTrayP:=&quot;Shell_TrayWnd&quot;) {
    d := A_DetectHiddenWindows
	DetectHiddenWindows, On
	idxTB := TrayIcon_GetTrayBar()
	SendMessage, 0x452, idxOld, idxNew, ToolbarWindow32%idxTB%, ahk_class %sTrayP% ; TB_MOVEBUTTON
    DetectHiddenWindows, %d%
}

TrayIcon_GetTrayBar() {
    d := A_DetectHiddenWindows
	DetectHiddenWindows, On
	WinGet, ControlList, ControlList, ahk_class Shell_TrayWnd
	RegExMatch(ControlList, &quot;(?&lt;=ToolbarWindow32)\d+(?!.*ToolbarWindow32)&quot;, nTB)

	Loop, %nTB%
	{
		ControlGet, hWnd, hWnd,, ToolbarWindow32%A_Index%, ahk_class Shell_TrayWnd
		hParent := DllCall( &quot;GetParent&quot;, Ptr,hWnd )
		WinGetClass, sClass, ahk_id %hParent%
		If (sClass &lt;&gt; &quot;SysPager&quot;)
			Continue
		idxTB := A_Index
			Break
	}
	
	DetectHiddenWindows, %d%
	Return	idxTB
}

TrayIcon_GetHotItem() {
   idxTB := TrayIcon_GetTrayBar()
   SendMessage, 0x447, 0, 0, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd ; TB_GETHOTITEM
   Return ErrorLevel &lt;&lt; 32 &gt;&gt; 32
}
</code></pre></div><div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>Правильно, наверное, так - проверить не могу.</p></blockquote></div><p>Проблема в том, что код:</p><div class="codebox"><pre><code>ControlGetText, SyncStatus, wxWindowNR16, ahk_exe googledrivesync.exe</code></pre></div><p>помещает в переменную SyncStatus либо пустую строку, либо &quot;panel&quot;, а не статус синхронизации.</p>]]></content>
			<author>
				<name><![CDATA[mafckz]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=32877</uri>
			</author>
			<updated>2016-03-29T15:37:08Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102101#p102101</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Оповещение о завершении синхронизации Google Drive]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102087#p102087" />
			<content type="html"><![CDATA[<p>Конечно было бы замечательно если бы кто-то написал враппер Гугловского Api для Ahk.<br />Есть утилитка, можешь ее покопать:<br /><a href="https://github.com/prasmussen/gdrive">https://github.com/prasmussen/gdrive</a><br />Кстати в первом коде ошибка.<br />Правильно, наверное, так - проверить не могу.<br /></p><div class="codebox"><pre><code>#SingleInstance Force
DetectHiddenWindows, On
SetTitleMatchMode 2

Loop
{
   ControlGetText, SyncStatus, wxWindowNR16, ahk_exe googledrivesync.exe 
   if (SyncStatus = &quot;Sync complete&quot;)
   {
	   MsgBox Sync Complete!
       return
   }
   sleep 50
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2016-03-28T22:54:27Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102087#p102087</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Оповещение о завершении синхронизации Google Drive]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102074#p102074" />
			<content type="html"><![CDATA[<p>А можно ли установить проверку лишь на тот случай, если фалы синхронизировались как минимум пять минут? Оповещение о синхронизации, например, текстового файла, что происходит мгновенно, как оказалось, мне ни к чему.</p>]]></content>
			<author>
				<name><![CDATA[becauseim]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33149</uri>
			</author>
			<updated>2016-03-28T17:03:43Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102074#p102074</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Оповещение о завершении синхронизации Google Drive]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102073#p102073" />
			<content type="html"><![CDATA[<p><strong>mafckz</strong>, спасибо! Но если, как Вы упомянули, это не самый верный способ решения данной задачи, то как подразумевается её верное решение? Думал, что при интервальной проверке сообщение будет выходить при каждой перезагрузке скрипта, однако, как и задумывалось, выходит только после момента синхронизации файлов. Думаю, это то, что мне нужно.</p>]]></content>
			<author>
				<name><![CDATA[becauseim]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33149</uri>
			</author>
			<updated>2016-03-28T16:59:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102073#p102073</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Оповещение о завершении синхронизации Google Drive]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102054#p102054" />
			<content type="html"><![CDATA[<p>Написал с интервалом проверки 100 милисекунд. За работоспособность и возможные глюки не отвечаю <img src="//forum.script-coding.com/img/smilies/tongue.png" width="15" height="15" /><br />Все-таки, такую задачу нужно решать по-другому.</p><div class="codebox"><pre><code>#SingleInstance Force
sync := false

#Persistent
SetTimer checkSync, 100  ; милисекунды

checkSync:
googleDrive := TrayIcon_GetInfo(&quot;googledrivesync.exe&quot;)
if (InStr(googleDrive[1].tooltip, &quot;Sync complete&quot;) || InStr(googleDrive[1].tooltip, &quot;Синхронизация завершена&quot;))
{
	if sync
	{
		SetTimer checkSync, off
		sync := false
		
		MsgBox Sync Complete! Синхронизация завершена!
		
		SetTimer checkSync, on
	}
}
else
	sync := true
return


;// ниже идет сама библиотека

; ----------------------------------------------------------------------------
TrayIcon_GetInfo(sExeName:=&quot;&quot;) {
    d := A_DetectHiddenWindows
	DetectHiddenWindows, On   

    oTrayInfo := Object()
	For key, sTrayP in [&quot;Shell_TrayWnd&quot;, &quot;NotifyIconOverflowWindow&quot;]
    {	
        idxTB := TrayIcon_GetTrayBar()
        WinGet, pidTaskbar, PID, ahk_class %sTrayP%

        hProc := DllCall( &quot;OpenProcess&quot;,    UInt,0x38, Int,0, UInt,pidTaskbar                       )
        pRB   := DllCall( &quot;VirtualAllocEx&quot;, Ptr,hProc, Ptr,0, UInt,20,        UInt,0x1000, UInt,0x4 )

        szBtn := VarSetCapacity( btn, (A_Is64bitOS) ? 32 : 24, 0 )
        szNfo := VarSetCapacity( nfo, (A_Is64bitOS) ? 32 : 24, 0 )
        szTip := VarSetCapacity( tip, 128 * 2,                 0 )

        SendMessage, 0x418, 0, 0, ToolbarWindow32%idxTB%, ahk_class %sTrayP% ; TB_BUTTONCOUNT
        Loop, %ErrorLevel%
        {
            SendMessage, 0x417, A_Index - 1, pRB, ToolbarWindow32%idxTB%, ahk_class %sTrayP% ; TB_GETBUTTON

            DllCall( &quot;ReadProcessMemory&quot;, Ptr,hProc, Ptr,pRB, Ptr,&amp;btn, UInt,szBtn, UInt,0 )

            iBitmap	:= NumGet( btn, 0                       )
            idCmd   := NumGet( btn, 4                       )
            Statyle := NumGet( btn, 8                       )
            dwData	:= NumGet( btn, (A_Is64bitOS) ? 16 : 12 )
            iString	:= NumGet( btn, (A_Is64bitOS) ? 24 : 16 )

            DllCall( &quot;ReadProcessMemory&quot;, Ptr,hProc, Ptr,dwData, Ptr,&amp;nfo, UInt,szNfo, UInt,0 )

            hWnd  := NumGet( nfo, 0                       )
            uID	  := NumGet( nfo, (A_Is64bitOS) ? 8  : 4  )
            nMsg  := NumGet( nfo, (A_Is64bitOS) ? 12 : 8  )
            hIcon := NumGet( nfo, (A_Is64bitOS) ? 24 : 20 )

            WinGet,      pid,      PID,         ahk_id %hWnd%
            WinGet,      sProcess, ProcessName, ahk_id %hWnd%
            WinGetClass, sClass,                ahk_id %hWnd%

            If ( !sExeName || (sExeName == sProcess) || (sExeName == pid) )
                DllCall( &quot;ReadProcessMemory&quot;, Ptr,hProc, Ptr,iString, Ptr,&amp;tip, UInt,szTip, UInt,0 )
              , oTrayInfo.Insert({ &quot;idx&quot;: A_Index-1, &quot;idcmd&quot;: idCmd, &quot;pid&quot;: pid, &quot;uid&quot;: uID, &quot;msgid&quot;: nMsg
                                 , &quot;hicon&quot;: hIcon, &quot;hwnd&quot;: hWnd, &quot;class&quot;: sClass, &quot;process&quot;: sProcess
                                 , &quot;tooltip&quot;: StrGet(&amp;tip, &quot;UTF-16&quot;), &quot;place&quot;: sTrayP })
        }
        
        DllCall( &quot;VirtualFreeEx&quot;, Ptr,hProc, Ptr,pRB, UInt,0, UInt,0x8000 )
        DllCall( &quot;CloseHandle&quot;,   Ptr,hProc                               )
	}
	DetectHiddenWindows, %d%
	Return oTrayInfo
}

TrayIcon_Hide(idCmd, sTrayP:=&quot;Shell_TrayWnd&quot;, bHide:=True) {
    d := A_DetectHiddenWindows
	DetectHiddenWindows, On
	idxTB := TrayIcon_GetTrayBar()
	SendMessage, 0x404, idCmd, bHide, ToolbarWindow32%idxTB%, ahk_class %sTrayP% ; TB_HIDEBUTTON
	SendMessage, 0x1A, 0, 0, , ahk_class %sTrayP%
    DetectHiddenWindows, %d%
}

TrayIcon_Remove(hWnd, uID) {
	sz := VarSetCapacity( NID, (A_PtrSize == 4) ? 832 : 848, 0 )
	NumPut( sz, NID, 0 ), NumPut( hWnd, NID, A_PtrSize ), NumPut( uID, NID, A_PtrSize*2 )
	DllCall( &quot;Shell32.dll\Shell_NotifyIcon&quot;, UInt,2, Ptr,&amp;NID )
}

TrayIcon_Delete(idx, sTrayP:=&quot;Shell_TrayWnd&quot;) {
    d := A_DetectHiddenWindows
	DetectHiddenWindows, On
	idxTB := TrayIcon_GetTrayBar()
	SendMessage, 0x416, idx, 0, ToolbarWindow32%idxTB%, ahk_class %sTrayP% ; TB_DELETEBUTTON
	SendMessage, 0x1A, 0, 0, , ahk_class %sTrayP%
	DetectHiddenWindows, %d%
}

TrayIcon_Move(idxOld, idxNew, sTrayP:=&quot;Shell_TrayWnd&quot;) {
    d := A_DetectHiddenWindows
	DetectHiddenWindows, On
	idxTB := TrayIcon_GetTrayBar()
	SendMessage, 0x452, idxOld, idxNew, ToolbarWindow32%idxTB%, ahk_class %sTrayP% ; TB_MOVEBUTTON
    DetectHiddenWindows, %d%
}

TrayIcon_GetTrayBar() {
    d := A_DetectHiddenWindows
	DetectHiddenWindows, On
	WinGet, ControlList, ControlList, ahk_class Shell_TrayWnd
	RegExMatch(ControlList, &quot;(?&lt;=ToolbarWindow32)\d+(?!.*ToolbarWindow32)&quot;, nTB)

	Loop, %nTB%
	{
		ControlGet, hWnd, hWnd,, ToolbarWindow32%A_Index%, ahk_class Shell_TrayWnd
		hParent := DllCall( &quot;GetParent&quot;, Ptr,hWnd )
		WinGetClass, sClass, ahk_id %hParent%
		If (sClass &lt;&gt; &quot;SysPager&quot;)
			Continue
		idxTB := A_Index
			Break
	}
	
	DetectHiddenWindows, %d%
	Return	idxTB
}

TrayIcon_GetHotItem() {
   idxTB := TrayIcon_GetTrayBar()
   SendMessage, 0x447, 0, 0, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd ; TB_GETHOTITEM
   Return ErrorLevel &lt;&lt; 32 &gt;&gt; 32
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[mafckz]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=32877</uri>
			</author>
			<updated>2016-03-28T09:57:30Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102054#p102054</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Оповещение о завершении синхронизации Google Drive]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102053#p102053" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>becauseim пишет:</cite><blockquote><p>Если можно, добавьте, пожалуйста, положение, при котором состояние будет проверяться циклично, т.е. чтобы сообщение выходило после каждого отдельно синхронизированного файла, а не только после запуска скрипта.</p></blockquote></div><p>После каждого файла - без понятия как сделать. Добавил интервал проверки состояния через 10 секунд.</p><p>------<br />Только, если сделать проверку каждые N миллисекунд, отслеживать когда статус изменится на &quot;синхронизация&quot; (т.е. новые объекты начали синхронизироваться) - после этого ждать статуса &quot;Синхронизация завершена&quot; - и тогда выводить сообщение. Но это как-то некрасиво совсем.</p>]]></content>
			<author>
				<name><![CDATA[mafckz]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=32877</uri>
			</author>
			<updated>2016-03-28T09:19:24Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102053#p102053</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Оповещение о завершении синхронизации Google Drive]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102052#p102052" />
			<content type="html"><![CDATA[<p><strong>mafckz</strong>, Спасибо, работает! Т.е. без трей-сообщения нельзя получить информацию из клиента Google Drive?</p><p>Если можно, добавьте, пожалуйста, положение, при котором состояние будет проверяться циклично, т.е. чтобы сообщение выходило после каждого отдельно синхронизированного файла, а не только после запуска скрипта.</p>]]></content>
			<author>
				<name><![CDATA[becauseim]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33149</uri>
			</author>
			<updated>2016-03-28T09:08:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102052#p102052</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Оповещение о завершении синхронизации Google Drive]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102051#p102051" />
			<content type="html"><![CDATA[<p>С помощью библиотеки TrayIcon.ahk (<a href="https://autohotkey.com/boards/viewtopic.php?t=1229">https://autohotkey.com/boards/viewtopic.php?t=1229</a>) можно получить Tip-cooбщение иконки, а там как раз и пишется статус синхронизации.</p><p>Вот скрипт с добавленным в конце кодом библиотеки<br /></p><div class="codebox"><pre><code>#SingleInstance Force

#Persistent
SetTimer checkSync, 10000  ; милисекунды

checkSync:
Icons := TrayIcon_GetInfo()
Loop, % Icons.MaxIndex()
    if (Icons[A_Index].process = &quot;googledrivesync.exe&quot;)
        if (InStr(Icons[A_Index].tooltip, &quot;Sync complete&quot;) || InStr(Icons[A_Index].tooltip, &quot;Синхронизация завершена&quot;))
            MsgBox Sync Complete! Синхронизация завершена!
return



;// ниже идет сама библиотека

; ----------------------------------------------------------------------------
TrayIcon_GetInfo(sExeName:=&quot;&quot;) {
    d := A_DetectHiddenWindows
	DetectHiddenWindows, On   

    oTrayInfo := Object()
	For key, sTrayP in [&quot;Shell_TrayWnd&quot;, &quot;NotifyIconOverflowWindow&quot;]
    {	
        idxTB := TrayIcon_GetTrayBar()
        WinGet, pidTaskbar, PID, ahk_class %sTrayP%

        hProc := DllCall( &quot;OpenProcess&quot;,    UInt,0x38, Int,0, UInt,pidTaskbar                       )
        pRB   := DllCall( &quot;VirtualAllocEx&quot;, Ptr,hProc, Ptr,0, UInt,20,        UInt,0x1000, UInt,0x4 )

        szBtn := VarSetCapacity( btn, (A_Is64bitOS) ? 32 : 24, 0 )
        szNfo := VarSetCapacity( nfo, (A_Is64bitOS) ? 32 : 24, 0 )
        szTip := VarSetCapacity( tip, 128 * 2,                 0 )

        SendMessage, 0x418, 0, 0, ToolbarWindow32%idxTB%, ahk_class %sTrayP% ; TB_BUTTONCOUNT
        Loop, %ErrorLevel%
        {
            SendMessage, 0x417, A_Index - 1, pRB, ToolbarWindow32%idxTB%, ahk_class %sTrayP% ; TB_GETBUTTON

            DllCall( &quot;ReadProcessMemory&quot;, Ptr,hProc, Ptr,pRB, Ptr,&amp;btn, UInt,szBtn, UInt,0 )

            iBitmap	:= NumGet( btn, 0                       )
            idCmd   := NumGet( btn, 4                       )
            Statyle := NumGet( btn, 8                       )
            dwData	:= NumGet( btn, (A_Is64bitOS) ? 16 : 12 )
            iString	:= NumGet( btn, (A_Is64bitOS) ? 24 : 16 )

            DllCall( &quot;ReadProcessMemory&quot;, Ptr,hProc, Ptr,dwData, Ptr,&amp;nfo, UInt,szNfo, UInt,0 )

            hWnd  := NumGet( nfo, 0                       )
            uID	  := NumGet( nfo, (A_Is64bitOS) ? 8  : 4  )
            nMsg  := NumGet( nfo, (A_Is64bitOS) ? 12 : 8  )
            hIcon := NumGet( nfo, (A_Is64bitOS) ? 24 : 20 )

            WinGet,      pid,      PID,         ahk_id %hWnd%
            WinGet,      sProcess, ProcessName, ahk_id %hWnd%
            WinGetClass, sClass,                ahk_id %hWnd%

            If ( !sExeName || (sExeName == sProcess) || (sExeName == pid) )
                DllCall( &quot;ReadProcessMemory&quot;, Ptr,hProc, Ptr,iString, Ptr,&amp;tip, UInt,szTip, UInt,0 )
              , oTrayInfo.Insert({ &quot;idx&quot;: A_Index-1, &quot;idcmd&quot;: idCmd, &quot;pid&quot;: pid, &quot;uid&quot;: uID, &quot;msgid&quot;: nMsg
                                 , &quot;hicon&quot;: hIcon, &quot;hwnd&quot;: hWnd, &quot;class&quot;: sClass, &quot;process&quot;: sProcess
                                 , &quot;tooltip&quot;: StrGet(&amp;tip, &quot;UTF-16&quot;), &quot;place&quot;: sTrayP })
        }
        
        DllCall( &quot;VirtualFreeEx&quot;, Ptr,hProc, Ptr,pRB, UInt,0, UInt,0x8000 )
        DllCall( &quot;CloseHandle&quot;,   Ptr,hProc                               )
	}
	DetectHiddenWindows, %d%
	Return oTrayInfo
}

TrayIcon_Hide(idCmd, sTrayP:=&quot;Shell_TrayWnd&quot;, bHide:=True) {
    d := A_DetectHiddenWindows
	DetectHiddenWindows, On
	idxTB := TrayIcon_GetTrayBar()
	SendMessage, 0x404, idCmd, bHide, ToolbarWindow32%idxTB%, ahk_class %sTrayP% ; TB_HIDEBUTTON
	SendMessage, 0x1A, 0, 0, , ahk_class %sTrayP%
    DetectHiddenWindows, %d%
}

TrayIcon_Remove(hWnd, uID) {
	sz := VarSetCapacity( NID, (A_PtrSize == 4) ? 832 : 848, 0 )
	NumPut( sz, NID, 0 ), NumPut( hWnd, NID, A_PtrSize ), NumPut( uID, NID, A_PtrSize*2 )
	DllCall( &quot;Shell32.dll\Shell_NotifyIcon&quot;, UInt,2, Ptr,&amp;NID )
}

TrayIcon_Delete(idx, sTrayP:=&quot;Shell_TrayWnd&quot;) {
    d := A_DetectHiddenWindows
	DetectHiddenWindows, On
	idxTB := TrayIcon_GetTrayBar()
	SendMessage, 0x416, idx, 0, ToolbarWindow32%idxTB%, ahk_class %sTrayP% ; TB_DELETEBUTTON
	SendMessage, 0x1A, 0, 0, , ahk_class %sTrayP%
	DetectHiddenWindows, %d%
}

TrayIcon_Move(idxOld, idxNew, sTrayP:=&quot;Shell_TrayWnd&quot;) {
    d := A_DetectHiddenWindows
	DetectHiddenWindows, On
	idxTB := TrayIcon_GetTrayBar()
	SendMessage, 0x452, idxOld, idxNew, ToolbarWindow32%idxTB%, ahk_class %sTrayP% ; TB_MOVEBUTTON
    DetectHiddenWindows, %d%
}

TrayIcon_GetTrayBar() {
    d := A_DetectHiddenWindows
	DetectHiddenWindows, On
	WinGet, ControlList, ControlList, ahk_class Shell_TrayWnd
	RegExMatch(ControlList, &quot;(?&lt;=ToolbarWindow32)\d+(?!.*ToolbarWindow32)&quot;, nTB)

	Loop, %nTB%
	{
		ControlGet, hWnd, hWnd,, ToolbarWindow32%A_Index%, ahk_class Shell_TrayWnd
		hParent := DllCall( &quot;GetParent&quot;, Ptr,hWnd )
		WinGetClass, sClass, ahk_id %hParent%
		If (sClass &lt;&gt; &quot;SysPager&quot;)
			Continue
		idxTB := A_Index
			Break
	}
	
	DetectHiddenWindows, %d%
	Return	idxTB
}

TrayIcon_GetHotItem() {
   idxTB := TrayIcon_GetTrayBar()
   SendMessage, 0x447, 0, 0, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd ; TB_GETHOTITEM
   Return ErrorLevel &lt;&lt; 32 &gt;&gt; 32
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[mafckz]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=32877</uri>
			</author>
			<updated>2016-03-28T08:57:02Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102051#p102051</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Оповещение о завершении синхронизации Google Drive]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102050#p102050" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>#SingleInstance Force
DetectHiddenWindows, On
SetTitleMatchMode 2

ControlGetText, SyncStatus, wxWindowNR16, ahk_exe googledrivesync.exe 

Loop
{
if (SyncStatus = &quot;Sync complete&quot;)
{
	MsgBox Sync Complete!
	return
}
}
return
</code></pre></div><p>По задумке, должно выходить оповещающее сообщение о завершении синхронизации файлов посредством клиента Google Drive. В таком виде не работает. Исправьте, пожалуйста.</p>]]></content>
			<author>
				<name><![CDATA[becauseim]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33149</uri>
			</author>
			<updated>2016-03-28T08:06:56Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102050#p102050</id>
		</entry>
</feed>
