#SingleInstance Force
syncTime := 10000 ; время синхронизации в милисекундах, больше которого выводить сообщение
sync := false
#Persistent
SetTimer checkSync, 100 ; милисекунды
checkSync:
googleDrive := TrayIcon_GetInfo("googledrivesync.exe")
if (InStr(googleDrive[1].tooltip, "Sync complete") || InStr(googleDrive[1].tooltip, "Синхронизация завершена"))
{
if sync
{
sync := false
if ( (A_TickCount - StartTime) > syncTime )
{
SetTimer checkSync, off
MsgBox Sync Complete! Синхронизация завершена!
SetTimer checkSync, on
}
}
}
else
{
if !sync
{
sync := true
StartTime := A_TickCount
}
}
return
;// ниже идет сама библиотека
; ----------------------------------------------------------------------------
TrayIcon_GetInfo(sExeName:="") {
d := A_DetectHiddenWindows
DetectHiddenWindows, On
oTrayInfo := Object()
For key, sTrayP in ["Shell_TrayWnd", "NotifyIconOverflowWindow"]
{
idxTB := TrayIcon_GetTrayBar()
WinGet, pidTaskbar, PID, ahk_class %sTrayP%
hProc := DllCall( "OpenProcess", UInt,0x38, Int,0, UInt,pidTaskbar )
pRB := DllCall( "VirtualAllocEx", 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( "ReadProcessMemory", Ptr,hProc, Ptr,pRB, Ptr,&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( "ReadProcessMemory", Ptr,hProc, Ptr,dwData, Ptr,&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( "ReadProcessMemory", Ptr,hProc, Ptr,iString, Ptr,&tip, UInt,szTip, UInt,0 )
, oTrayInfo.Insert({ "idx": A_Index-1, "idcmd": idCmd, "pid": pid, "uid": uID, "msgid": nMsg
, "hicon": hIcon, "hwnd": hWnd, "class": sClass, "process": sProcess
, "tooltip": StrGet(&tip, "UTF-16"), "place": sTrayP })
}
DllCall( "VirtualFreeEx", Ptr,hProc, Ptr,pRB, UInt,0, UInt,0x8000 )
DllCall( "CloseHandle", Ptr,hProc )
}
DetectHiddenWindows, %d%
Return oTrayInfo
}
TrayIcon_Hide(idCmd, sTrayP:="Shell_TrayWnd", 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( "Shell32.dll\Shell_NotifyIcon", UInt,2, Ptr,&NID )
}
TrayIcon_Delete(idx, sTrayP:="Shell_TrayWnd") {
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:="Shell_TrayWnd") {
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, "(?<=ToolbarWindow32)\d+(?!.*ToolbarWindow32)", nTB)
Loop, %nTB%
{
ControlGet, hWnd, hWnd,, ToolbarWindow32%A_Index%, ahk_class Shell_TrayWnd
hParent := DllCall( "GetParent", Ptr,hWnd )
WinGetClass, sClass, ahk_id %hParent%
If (sClass <> "SysPager")
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 << 32 >> 32
}
помещает в переменную SyncStatus либо пустую строку, либо "panel", а не статус синхронизации.