Jump to content

Wait untill google drive finish synchronize files


 Share

Recommended Posts

I'm trying to find out when the google drive finishes syncing files. I have tried to read the title from the tray via _GUICtrlToolbar_GetButtonText() function but my tray control always have different instance number and google drive toolbar item also have different index. I tried the code from here

#include <GUIToolbar.au3>

$hToolBar = ControlGetHandle("[CLASS:Shell_TrayWnd]", "", "[CLASS:ToolbarWindow32;INSTANCE:4]") ;INSTANCE in my PC is 4 for toolbar but other PC is 1, when I delete INSTANCE section then it does not work
if @error then Exit MsgBox($MB_ICONERROR, @ScriptName, "ControlGetHandle() failed. Exit")
$CMDiD = _GUICtrlToolbar_IndexToCommand($hToolBar, 1)             ;index is not always the same for google drive
$sText = _GUICtrlToolbar_GetButtonText($hToolBar, $CMDiD)
MsgBox($MB_ICONINFORMATION, @ScriptName, $sText)

Any idea how to find the right tray and google drive handle/control?

Any idea how to do the job with other way?

Link to comment
Share on other sites

I found a solution

#include <GUIToolbar.au3>

GoogleSyncWait()

Func GoogleSyncWait($timeout = 60) ;in seconds
    Opt("MustDeclareVars", 1)
    
    Local $hTimer = TimerInit() ;for timeout

    Local $hSysTray = ControlGetHandle("[CLASS:Shell_TrayWnd]", "", "[CLASS:ToolbarWindow32;TEXT:Obszar powiadomień użytkownika]") ;instead of instance I used "text" value to find proper system tray element
    if @error then Exit MsgBox($MB_ICONERROR, @ScriptName, "ControlGetHandle() failed. Exit")
    
    Local $bFound = false, $iSysTray_ButCount, $CMDiD, $sText, $counter = 0, $fDiff

    while not $bFound
        $iSysTray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray)
        If $iSysTray_ButCount = 0 Then Exit MsgBox($MB_ICONERROR, @ScriptName, "_GUICtrlToolbar_ButtonCount() No items found in system tray")
        for $iSystray_ButtonNumber=0 to $iSystray_ButCount - 1
            $CMDiD = _GUICtrlToolbar_IndexToCommand($hSysTray, $iSystray_ButtonNumber)
            $sText = _GUICtrlToolbar_GetButtonText($hSysTray, $CMDiD)
            if StringInStr($sText, "Kopia zapasowa i synchronizacja w usługach Google - Zaktualizowano") then
                $bFound = true
                ExitLoop
            EndIf
        Next
        Sleep(1000)
        $fDiff = Int(TimerDiff($hTimer)/1000)
        if Int($fDiff) > $timeout then Return MsgBox($MB_ICONERROR, @ScriptName, "GoogleSyncWait() timeout. Return", 10)
    WEnd
EndFunc

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...