I have a backup program that is doing backups to my dropbox and google drive folders on my hard disk which sync the backup files respectively to my cloud google drive and dropbox accounts. But i don't want Dropbox and Google Drive to run constantly, only when a new backup is done. On my backup program i can setup a script that can be executed after a backup is finished and this script can start dropbox and google drive and they can start syncing the new backup.
But is it possible autohotkey script to detect when the syncing is finished and then to close the programs?
Close Dropbox/GoogleDrive after syncing is finished?
My GitHub Profile | Donations are appreciated if I could help you
; Return Values ; 0 [NOT_IN_DROPBOX] ==> Folder is not in Dropbox ; 1 [UP_TO_DATE] ==> Up to Date ; 2 [SYNCHRONIZING] ==> Sync in Progress ; 99 [NOT_RUNNING] ==> Dropbox is not running
My GitHub Profile | Donations are appreciated if I could help you
Can you tell me how to make the script to monitor if the dropbox status is up to date, i am not very advanced with ahk. If i put If in front of DropBoxStatus(Path) it gives error:
; 0 ==> Folder is not in Dropbox ; 1 ==> Up to Date ; 2 ==> Sync in Progress MsgBox % DropBoxStatus("C:\Users\" A_UserName "\Dropbox") If DropBoxStatus(Path) { static RequestInfo := 0x3048302 static ProcessId := DllCall("kernel32.dll\GetCurrentProcessId") static ThreadId := DllCall("kernel32.dll\GetCurrentThreadId") static RequestType := 1 if !(DllCall("kernel32.dll\ProcessIdToSessionId", "UInt", ProcessId, "UInt*", SessionId)) return "*" DllCall("kernel32.dll\GetLastError") PipeName := "\\.\pipe\DropboxPipe_" . SessionId SizeIn := VarSetCapacity(BuffIn, 16 + 524) NumPut(RequestInfo, BuffIn, 0, "Int") NumPut(ProcessId, BuffIn, 4, "Int") NumPut(ThreadId, BuffIn, 8, "Int") NumPut(RequestType, BuffIn, 12, "Int") StrPut(path, &BuffIn + 16, 524//2, "UTF-16") SizeOut := VarSetCapacity(BuffOut, 16382, 0) if !(DllCall("kernel32.dll\CallNamedPipe", "Str", PipeName, "Ptr", &BuffIn, "UInt", SizeIn, "Ptr", &BuffOut, "UInt", SizeOut, "UInt*", BytesRead, "UInt", 1000)) return "*" DllCall("kernel32.dll\GetLastError") return StrGet(&BuffOut + 4, BytesRead - 5, "CP0") }
More like this:
Dropbox_Path := "C:\Users\USERNAME\Dropbox" ; <== Change this to your DropBox Path if (DropBoxStatus(Dropbox_Path) = 1) ; <== if Status is 1 (explained above) MsgBox % "Dropbox is up to date" ; FUNCTIONS ===================================================================================================================== DropBoxStatus(Path, GetStatus := 0) { static DropBoxStatus := {0: "NOT_IN_DROPBOX", 1: "UP_TO_DATE", 2: "SYNCHRONIZING", 99: "NOT_RUNNING"} static RequestInfo := 0x3048302 static ProcessId := DllCall("kernel32.dll\GetCurrentProcessId") static ThreadId := DllCall("kernel32.dll\GetCurrentThreadId") static RequestType := 1 Process, Exist, % "Dropbox.exe" if (ErrorLevel = 0) return GetStatus ? DropBoxStatus[99] : 99 if !(DllCall("kernel32.dll\ProcessIdToSessionId", "UInt", ProcessId, "UInt*", SessionId)) return "*" DllCall("kernel32.dll\GetLastError") PipeName := "\\.\pipe\DropboxPipe_" . SessionId SizeIn := VarSetCapacity(BuffIn, 16 + 524) NumPut(RequestInfo, BuffIn, 0, "Int") NumPut(ProcessId, BuffIn, 4, "Int") NumPut(ThreadId, BuffIn, 8, "Int") NumPut(RequestType, BuffIn, 12, "Int") StrPut(path, &BuffIn + 16, 524//2, "UTF-16") SizeOut := VarSetCapacity(BuffOut, 16382, 0) if !(DllCall("kernel32.dll\CallNamedPipe", "Str", PipeName, "Ptr", &BuffIn, "UInt", SizeIn, "Ptr", &BuffOut, "UInt", SizeOut, "UInt*", BytesRead, "UInt", 1000)) return "*" DllCall("kernel32.dll\GetLastError") return GetStatus ? DropBoxStatus[StrGet(&BuffOut + 4, BytesRead - 5, "CP0")] : StrGet(&BuffOut + 4, BytesRead - 5, "CP0") }
My GitHub Profile | Donations are appreciated if I could help you
Thanks, now the script is working! Can it be modified and used for google drive?
221 Posts and not ahk advanced?
I am mostly searching if there is already created scripts for what i need and i am trying with my limited knowledge to modify them to fit my needs. If i don't know something i ask. From there the post count.
Thanks, now the script is working! Can it be modified and used for google drive?
Nope. This function is just for Dropbox.
And since I dont use Google Drive I can not help you with it.
My GitHub Profile | Donations are appreciated if I could help you
Ok, no problem.
What is the best way to close Drobpox? I am using Process, Close, dropbox.exe and when it close the process the dropbox icon stay in the system tray, and if i move the mouse over it, it disappear.
#Persistent Dropbox_Path := "E:\Dropbox" ; <== Change this to your DropBox Path SetTimer, Check, 100 gosub, Check Check: if (DropBoxStatus(Dropbox_Path) = 1) ; <== if Status is 1 (explained above) ;MsgBox % "Dropbox is up to date" Process, Close, Dropbox.exe ; FUNCTIONS ===================================================================================================================== DropBoxStatus(Path, GetStatus := 0) { static DropBoxStatus := {0: "NOT_IN_DROPBOX", 1: "UP_TO_DATE", 2: "SYNCHRONIZING", 99: "NOT_RUNNING"} static RequestInfo := 0x3048302 static ProcessId := DllCall("kernel32.dll\GetCurrentProcessId") static ThreadId := DllCall("kernel32.dll\GetCurrentThreadId") static RequestType := 1 Process, Exist, % "Dropbox.exe" if (ErrorLevel = 0) return GetStatus ? DropBoxStatus[99] : 99 if !(DllCall("kernel32.dll\ProcessIdToSessionId", "UInt", ProcessId, "UInt*", SessionId)) return "*" DllCall("kernel32.dll\GetLastError") PipeName := "\\.\pipe\DropboxPipe_" . SessionId SizeIn := VarSetCapacity(BuffIn, 16 + 524) NumPut(RequestInfo, BuffIn, 0, "Int") NumPut(ProcessId, BuffIn, 4, "Int") NumPut(ThreadId, BuffIn, 8, "Int") NumPut(RequestType, BuffIn, 12, "Int") StrPut(path, &BuffIn + 16, 524//2, "UTF-16") SizeOut := VarSetCapacity(BuffOut, 16382, 0) if !(DllCall("kernel32.dll\CallNamedPipe", "Str", PipeName, "Ptr", &BuffIn, "UInt", SizeIn, "Ptr", &BuffOut, "UInt", SizeOut, "UInt*", BytesRead, "UInt", 1000)) return "*" DllCall("kernel32.dll\GetLastError") return GetStatus ? DropBoxStatus[StrGet(&BuffOut + 4, BytesRead - 5, "CP0")] : StrGet(&BuffOut + 4, BytesRead - 5, "CP0") }
this is more a Windows problemwhen it close the process the dropbox icon stay in the system tray, and if i move the mouse over it, it disappear.
#Persistent Dropbox_Path := "E:\Dropbox" ; <== Change this to your DropBox Path loop { if (DropBoxStatus(Dropbox_Path) = 1) ; <== if Status is 1 (explained above) { Process, Close, Dropbox.exe ExitApp } sleep 1000 } ; FUNCTIONS =====================================================================================================================
My GitHub Profile | Donations are appreciated if I could help you