V1: Reload script when Dropbox finishes syncing
Posted: 18 Apr 2024, 11:20
I have been using this function for over 2 years, and it has worked flawlessly. A couple of days ago, on both my computers this stopped working... It simply wouldn't Get the Dropbox sync status no more. Here's the code below, and here are some threads where the same code was mentioned (here and here ). Is there anything that I can do?
This was a really handy function, as I had all my scripts on a DropBox folder, which was obviously synced across my two workstations... So when I'd update a script, DropBox would then start syncing and once the sync was over the GetDropboxStatus function will notice it, and I had it set so that my master script would then be refreshed after every sync. It was a great auto-refresh script that would also refresh when editing the #include files.
Code: Select all
; 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
MsgBox % GetDropboxStatus("C:\Users\" A_UserName "\Dropbox") ; ==> return e.g. 1
MsgBox % GetDropboxStatus("C:\Users\" A_UserName "\Dropbox", 1) ; ==> return e.g. UP_TO_DATE ;
GetDropboxStatus(DBLocation, StatusToText := 0)
{
static DBStatusTxt := {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)
return StatusToText ? DBStatusTxt[99] : 99
if !(DllCall("kernel32.dll\ProcessIdToSessionId", "UInt", ProcessId, "UInt*", SessionId))
return "*ProcessIdToSessionId [" 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(DBLocation, &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 "*CallNamedPipe [" DllCall("kernel32.dll\GetLastError") "]"
return StatusToText ? DBStatusTxt[StrGet(&BuffOut + 4, BytesRead - 5, "CP0")] : StrGet(&BuffOut + 4, BytesRead - 5, "CP0")
}