Last active
May 16, 2019 17:34
-
-
Save jNizM/5af2a189a8421f0f66b4 to your computer and use it in GitHub Desktop.
[AHK] Get Dropbox Status
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 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") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could you briefly please explain how/why this script works?
In particular, where does request info"0x3048302" and pipe name "DropboxPipe_" come from? I've searched the Internet but they don't seem to be documented anywhere.
Thanks