Depuis plusieurs jours je cherche une solution pour partager automatiquement un dossier DropBox pour un projet plus global.
J'ai deux pistes :
Sachant qu'il existe des API, je me suis documenté sur le site, il y a plusieurs méthodes dont HTTP POST.
J'ai lu plusieurs fois la doc et utilisé l'API explorer mais je ne comprend pas comment m'en servir.
J'ai trouvé sur le forum US 2 codes mais aucun n'est fonctionnel, ci-dessous celui qui ma paraissait le plus aboutis.
Il suffirait d'adapter pour utilisé l'appel /create_shared_link .
Mais je ne dépasse pas l'Authentification, j'ai une erreur 401 alors que mes App_Key sont OK et ma clé Oauth est correctement généré via MyApps.
► Afficher le texte
#include <File.au3>
#include <WinHttp.au3>
#include <Date.au3>
#include <Array.au3>
#include <String.au3>
; set the dropbox tokens
;~ If $App_Key = "" Then
$File = ""
$App_Key = ""
$App_secret = ""
$Oauth_access_token = ""
$Oauth_access_token_secret = "" ; this the personal Oauth2 Generated access token
$App_folder = "GetShare" ; this is (probably) the name of your app - it's not currently needed in this code
;~ EndIf
getAuth($App_Key, $App_secret)
upload($App_Key, $App_secret, $Oauth_access_token, $Oauth_access_token_secret, $File)
Func upload($App_Key, $App_secret, $Oauth_access_token, $Oauth_access_token_secret, $File="")
; trayseticon("C:\Program Files\AutoIt3\Icons\cute panda.ico", -1)
; Get the file to upload
Local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = ""
local $time= CurrentTime()
local $Random = Random(0,32767,1)
; if a filename isn't passed to the function, then ask the user for one
If $File = "" Then
$File = fileopendialog("Pick something to upload", @desktopdir, "All (*.*)|Text files (*.txt)" )
EndIf
;ConsoleWriteTS($File)
; Now open the file and load the data into memory
local $array = _PathSplit($File,$sDrive, $sDir, $sFilename, $sExtension) ; get the file name and extension
Local $i = UBound($array) - 1
local $sFile = fileopen($File,16)
Local $data = fileread($sFile)
local $size = @extended
FileClose($File)
;set up the dropbox upload URL
;to get the dropbox tokens, browse to https://www.dropbox.com/developers/appl ... opers/apps and create a new app
;$array[$i-1] is the file name of the file the user wants to upload and $array[$i] is the extension
Local $sUrl = ("https://api-content.dropbox.com/1/files_put/dropbox" & "/" & $array[$i-1] & $array[$i] & _
"?oauth_consumer_key=" & $App_Key & _
"&oauth_token=" & $Oauth_access_token & _
"&oauth_signature_method=PLAINTEXT" & _
"&oauth_signature=" & $App_secret & "&" & $Oauth_access_token_secret & _
"&oauth_timestamp=" & $time & _
"&oauth_nonce=" & $RANDOM)
ConsoleWriteTS("URL: " & $sUrl)
; now attempt to upload the file with the generated dropbox URL
Local $obj = ObjCreate("WinHttp.WinHttpRequest.5.1")
$obj.Open("PUT", $sURL, False)
ConsoleWriteTS("Open PUT")
If @error Then
ConsoleWriteTS("@1:unable to open PUT" & " " &$array[$i-1] & $array[$i])
else
ConsoleWriteTS("request opened")
$obj.SetRequestHeader("User-Agent", "User-Agent=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0")
;$obj.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
$obj.SetRequestHeader("Content-Length", $size)
; if _FindNetwork() = "xavier" Then
; $obj.SetProxy(2, "number")
; endif
ConsoleWriteTS("@2:" & $sFile)
$obj.Send($data) ; send the file to uploaded
$oReceived = $obj.ResponseText
$oStatusCode = $obj.Status
If $obj.Status <> $HTTP_STATUS_OK Then
$FindError = FindError($oStatusCode)
ConsoleWriteTS($oReceived)
ConsoleWriteTS("@3:" & $oStatusCode & ":" & $FindError & " :unable to upload " & $array[$i-1] & $array[$i])
else
ConsoleWriteTS("uploaded " & $array[$i-1] & $array[$i])
endif
; trayseticon("C:\Program Files\AutoIt3\Icons\panda.ico", -1)
endif
EndFunc
Func CurrentTime()
return _DateDiff('s', "1970/01/01 00:00:00", _NowCalc())
EndFunc
Func FindError($apple)
switch 1
case $apple = 400
return "Bad input parameter"
case $apple = 401
return "Bad or expired token."
case $apple = 403
return "Bad OAuth request (wrong consumer key, bad nonce, expired timestamp...). "
case $apple = 404
return "File or folder not found at the specified path."
case $apple = 405
return "Request method not expected (generally should be GET or POST)."
case $apple = 429
return "Your app is making too many requests and is being rate limited"
case $apple = 503
return "OAuth 1.0 app is being rate limited. "
case $apple = 507
return "User is over Dropbox storage quota."
case $apple = 5&"xx"
return "server error"
endswitch
EndFunc
Func ConsoleWriteTS($pea)
; consolewrite writes whatever value you want to the stdout stream
ConsoleWrite(@Mday&"/"&@mon&" "&@hour&":"&@min&":"&@sec&" --> " & $pea & @CRLF)
EndFunc
Exit
;********************* Dropbox authenticator ********************
DirCreate(@desktopdir & "\Dropbox authenticator")
;fileinstall("C:\Users\jcampbell\Desktop\AutoIT\tokens.txt", @desktopdir & "\Dropbox authenticator\tokens.txt")
;fileinstall("C:\Users\jcampbell\Desktop\AutoIT\url.txt", @desktopdir & "\Dropbox authenticator\url.txt")
Func getAuth($App_Key="", $App_secret="")
ConsoleWriteTS("starting Func GetToken")
If $App_Key = "" Then
Msgbox(0,"Welcome", "This was created to make getting your oauth_token and secret easier. When you first run this program it will create an empty folder on your desktop (please leave it as it needs to be on the desktop). As your progress though the program text files will be created as they are needed. make sure not to click ok on the ConsoleWriteTSbox without reading as it is vitial each step be complete before going onto the next.")
$App_Key = inputbox("App key", "Please enter your app key" & @CRLF & "To get the initial dropbox tokens, browse to https://www.dropbox.com/developers/appl ... opers/apps and create a new app", "https://www.dropbox.com/developers/apply?cont=/developers/apps" )
$App_Secret = inputbox("App secret", "Please enter your app secret")
EndIf
Local $obj = ObjCreate("WinHttp.WinHttpRequest.5.1")
local $time=currenttime()
local $Random = Random(0,32767,1)
; using my fucntion _FindNetwork I can determine whether or not I need to set a proxy. This is so the user doesn't have to do anything and is all automated.
;if _FindNetwork() = "xavier" Then $obj.SetProxy(2, "proxy.school:3128")
;$obj.SetTimeouts(30000,60000,30000,400000) ;wait a max of 6.6 minutes for request to timeout
Local $sUrl = ("https://api.dropbox.com/1/oauth/request_token" & _
"?oauth_consumer_key=" & $App_Key & _
"&oauth_token=" & $Oauth_access_token & _
"&oauth_signature_method=PLAINTEXT" & _
"&oauth_signature=" & $App_secret & "&" & _
"&oauth_timestamp=" & $time & _
"&oauth_nonce=" & $RANDOM)
ConsoleWriteTS("URL: " & $sUrl)
$obj.Open("POST", $sURL , False)
ConsoleWriteTS("Open POST")
$obj.Send($sUrl)
local $status = $obj.Status
local $Recieved = $obj.ResponseText
local $FindError = FindError($status)
If $obj.Status <> 200 Then
$FindError = FindError($status)
ConsoleWriteTS($FindError)
Exit
else
ConsoleWriteTS($obj.ResponseText)
ConsoleWriteTS($Recieved)
$secret = GetSecret($Recieved)
ConsoleWriteTS("secret:" & " "&$secret)
$token = GetToken1($Recieved)
ConsoleWriteTS("token:" & " "&$token)
authorize($secret, $token)
;pause(100)
local $url = "https://www.dropbox.com/1/oauth/authorize"&"?oauth_consumer_key="&$App_Key&"&oauth_token="&$token&"&oauth_signature="&$App_Secret&"&"&$secret&"&oauth_signature_method=PLAINTEXT"
ConsoleWriteTS("Copy and paste the following url into your browser and click the ok button when you have accepted authorization" & @CRLF & $url & @CRLF)
InputBox("Instructions", "Copy and paste the following url into your browser and click the ok button when you have accepted authorization", $url)
AccessToken($secret, $token)
endif
EndFunc
Func AccessToken($secret, $token)
ConsoleWriteTS("starting Func AccessToken")
Local $obj = ObjCreate("WinHttp.WinHttpRequest.5.1")
local $time = currenttime()
local $Random = Random(0,32767,1)
;ConsoleWriteTS("App key" & " " & $App_Key)
ConsoleWriteTS($token)
Local $sUrl = ("https://api.dropbox.com/1/oauth/access_token" & _
"?oauth_consumer_key=" & $App_Key & _
"&oauth_token=" & $token & _
"&oauth_signature_method=PLAINTEXT" & _
"&oauth_signature=" & $App_secret & "&" & $secret & _
"&oauth_timestamp=" & $time & _
"&oauth_nonce=" & $RANDOM)
ConsoleWriteTS("URL: " & $sUrl)
;$size = stringlen($token)
$obj.Open("POST", $sUrl , False)
ConsoleWriteTS("Open POST")
;$obj.SetResponseHeaders("content-length", $size)
;$obj.SetRequestHeader("User-Agent", "User-Agent=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0")
$obj.send($sUrl)
local $Recieved = $obj.ResponseText
If $obj.Status <> 200 Then
ConsoleWriteTS($obj.status)
ConsoleWriteTS($obj.ResponseText)
MsgBox(0, "Error", "Unable to retrieve your Oauth_token and secret at this time")
else
;iniwrite(@scriptdir & "/
;ConsoleWriteTS($Recieved)
;$oauth_token_secret = GetSecret1($Recieved)
;$oauth_token = GetOauth($Recieved)
msgbox(0, "Success", "Go to the dropbox authenticator folder, open tokens.txt and the last line has your most recent Oauth_token and secret")
local $sFile = fileopen(@desktopdir & "\Dropbox authenticator\tokens.txt",1)
filewrite($sFile, $Recieved)
fileclose($sFile)
endif
EndFunc
Func GetOauth($data)
local $array = _StringBetween($data, "oauth_token=","&")
return $array[0]
EndFunc
Func GetSecret1($data)
local $array = _StringBetween($data, "oauth_token_secret=", "&")
return $array[0]
EndFunc
Func authorize($token_secret, $access_token)
local $time=currenttime()
local $Random = Random(0,32767,1)
local $url = "https://www.dropbox.com/1/oauth/authorize"&"?oauth_consumer_key="&$App_Key&"&oauth_token="&$access_token&"&oauth_signature="&$App_Secret&"&"&$token_secret&"&oauth_signature_method=PLAINTEXT"&"&oauth_timestamp="&$time&"&oauth_nonce="&$RANDOM
local $Random = Random(0,32767,1)
ConsoleWriteTS("url is " & " "&$url)
Local $obj = ObjCreate("WinHttp.WinHttpRequest.5.1")
$obj.Open("GET", $url , False)
;if _FindNetwork() = "xavier" Then $obj.SetProxy(2, "proxy.school:3128")
;ConsoleWriteTS($url)
local $size = stringlen($url)
$obj.SetResponseHeaders("content-length", $size)
$obj.SetRequestHeader("User-Agent", "User-Agent=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0")
$obj.Send($url)
local $status = $obj.Status
local $Recieved = $obj.ResponseText
If $obj.Status <> 200 Then
local $FindError = FindError($status)
ConsoleWriteTS($FindError)
else
ConsoleWriteTS($obj.Status)
endif
EndFunc
Func GetToken1($str)
Local $pie = _StringBetween($str, "oauth_token=","") ; gets the text starting from oauth_token to the end of the file
if $pie = 1 then
ConsoleWriteTS("error")
else
return $pie[0]
endif
EndFunc
Func GetSecret($str)
local $pie = _StringBetween($str,"oauth_token_secret=","&")
if $pie = 1 then
ConsoleWriteTS(@error)
else
ConsoleWriteTS("pie is" & " " &$pie[0])
return $pie[0]
endif
EndFunc
#include <WinHttp.au3>
#include <Date.au3>
#include <Array.au3>
#include <String.au3>
; set the dropbox tokens
;~ If $App_Key = "" Then
$File = ""
$App_Key = ""
$App_secret = ""
$Oauth_access_token = ""
$Oauth_access_token_secret = "" ; this the personal Oauth2 Generated access token
$App_folder = "GetShare" ; this is (probably) the name of your app - it's not currently needed in this code
;~ EndIf
getAuth($App_Key, $App_secret)
upload($App_Key, $App_secret, $Oauth_access_token, $Oauth_access_token_secret, $File)
Func upload($App_Key, $App_secret, $Oauth_access_token, $Oauth_access_token_secret, $File="")
; trayseticon("C:\Program Files\AutoIt3\Icons\cute panda.ico", -1)
; Get the file to upload
Local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = ""
local $time= CurrentTime()
local $Random = Random(0,32767,1)
; if a filename isn't passed to the function, then ask the user for one
If $File = "" Then
$File = fileopendialog("Pick something to upload", @desktopdir, "All (*.*)|Text files (*.txt)" )
EndIf
;ConsoleWriteTS($File)
; Now open the file and load the data into memory
local $array = _PathSplit($File,$sDrive, $sDir, $sFilename, $sExtension) ; get the file name and extension
Local $i = UBound($array) - 1
local $sFile = fileopen($File,16)
Local $data = fileread($sFile)
local $size = @extended
FileClose($File)
;set up the dropbox upload URL
;to get the dropbox tokens, browse to https://www.dropbox.com/developers/appl ... opers/apps and create a new app
;$array[$i-1] is the file name of the file the user wants to upload and $array[$i] is the extension
Local $sUrl = ("https://api-content.dropbox.com/1/files_put/dropbox" & "/" & $array[$i-1] & $array[$i] & _
"?oauth_consumer_key=" & $App_Key & _
"&oauth_token=" & $Oauth_access_token & _
"&oauth_signature_method=PLAINTEXT" & _
"&oauth_signature=" & $App_secret & "&" & $Oauth_access_token_secret & _
"&oauth_timestamp=" & $time & _
"&oauth_nonce=" & $RANDOM)
ConsoleWriteTS("URL: " & $sUrl)
; now attempt to upload the file with the generated dropbox URL
Local $obj = ObjCreate("WinHttp.WinHttpRequest.5.1")
$obj.Open("PUT", $sURL, False)
ConsoleWriteTS("Open PUT")
If @error Then
ConsoleWriteTS("@1:unable to open PUT" & " " &$array[$i-1] & $array[$i])
else
ConsoleWriteTS("request opened")
$obj.SetRequestHeader("User-Agent", "User-Agent=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0")
;$obj.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
$obj.SetRequestHeader("Content-Length", $size)
; if _FindNetwork() = "xavier" Then
; $obj.SetProxy(2, "number")
; endif
ConsoleWriteTS("@2:" & $sFile)
$obj.Send($data) ; send the file to uploaded
$oReceived = $obj.ResponseText
$oStatusCode = $obj.Status
If $obj.Status <> $HTTP_STATUS_OK Then
$FindError = FindError($oStatusCode)
ConsoleWriteTS($oReceived)
ConsoleWriteTS("@3:" & $oStatusCode & ":" & $FindError & " :unable to upload " & $array[$i-1] & $array[$i])
else
ConsoleWriteTS("uploaded " & $array[$i-1] & $array[$i])
endif
; trayseticon("C:\Program Files\AutoIt3\Icons\panda.ico", -1)
endif
EndFunc
Func CurrentTime()
return _DateDiff('s', "1970/01/01 00:00:00", _NowCalc())
EndFunc
Func FindError($apple)
switch 1
case $apple = 400
return "Bad input parameter"
case $apple = 401
return "Bad or expired token."
case $apple = 403
return "Bad OAuth request (wrong consumer key, bad nonce, expired timestamp...). "
case $apple = 404
return "File or folder not found at the specified path."
case $apple = 405
return "Request method not expected (generally should be GET or POST)."
case $apple = 429
return "Your app is making too many requests and is being rate limited"
case $apple = 503
return "OAuth 1.0 app is being rate limited. "
case $apple = 507
return "User is over Dropbox storage quota."
case $apple = 5&"xx"
return "server error"
endswitch
EndFunc
Func ConsoleWriteTS($pea)
; consolewrite writes whatever value you want to the stdout stream
ConsoleWrite(@Mday&"/"&@mon&" "&@hour&":"&@min&":"&@sec&" --> " & $pea & @CRLF)
EndFunc
Exit
;********************* Dropbox authenticator ********************
DirCreate(@desktopdir & "\Dropbox authenticator")
;fileinstall("C:\Users\jcampbell\Desktop\AutoIT\tokens.txt", @desktopdir & "\Dropbox authenticator\tokens.txt")
;fileinstall("C:\Users\jcampbell\Desktop\AutoIT\url.txt", @desktopdir & "\Dropbox authenticator\url.txt")
Func getAuth($App_Key="", $App_secret="")
ConsoleWriteTS("starting Func GetToken")
If $App_Key = "" Then
Msgbox(0,"Welcome", "This was created to make getting your oauth_token and secret easier. When you first run this program it will create an empty folder on your desktop (please leave it as it needs to be on the desktop). As your progress though the program text files will be created as they are needed. make sure not to click ok on the ConsoleWriteTSbox without reading as it is vitial each step be complete before going onto the next.")
$App_Key = inputbox("App key", "Please enter your app key" & @CRLF & "To get the initial dropbox tokens, browse to https://www.dropbox.com/developers/appl ... opers/apps and create a new app", "https://www.dropbox.com/developers/apply?cont=/developers/apps" )
$App_Secret = inputbox("App secret", "Please enter your app secret")
EndIf
Local $obj = ObjCreate("WinHttp.WinHttpRequest.5.1")
local $time=currenttime()
local $Random = Random(0,32767,1)
; using my fucntion _FindNetwork I can determine whether or not I need to set a proxy. This is so the user doesn't have to do anything and is all automated.
;if _FindNetwork() = "xavier" Then $obj.SetProxy(2, "proxy.school:3128")
;$obj.SetTimeouts(30000,60000,30000,400000) ;wait a max of 6.6 minutes for request to timeout
Local $sUrl = ("https://api.dropbox.com/1/oauth/request_token" & _
"?oauth_consumer_key=" & $App_Key & _
"&oauth_token=" & $Oauth_access_token & _
"&oauth_signature_method=PLAINTEXT" & _
"&oauth_signature=" & $App_secret & "&" & _
"&oauth_timestamp=" & $time & _
"&oauth_nonce=" & $RANDOM)
ConsoleWriteTS("URL: " & $sUrl)
$obj.Open("POST", $sURL , False)
ConsoleWriteTS("Open POST")
$obj.Send($sUrl)
local $status = $obj.Status
local $Recieved = $obj.ResponseText
local $FindError = FindError($status)
If $obj.Status <> 200 Then
$FindError = FindError($status)
ConsoleWriteTS($FindError)
Exit
else
ConsoleWriteTS($obj.ResponseText)
ConsoleWriteTS($Recieved)
$secret = GetSecret($Recieved)
ConsoleWriteTS("secret:" & " "&$secret)
$token = GetToken1($Recieved)
ConsoleWriteTS("token:" & " "&$token)
authorize($secret, $token)
;pause(100)
local $url = "https://www.dropbox.com/1/oauth/authorize"&"?oauth_consumer_key="&$App_Key&"&oauth_token="&$token&"&oauth_signature="&$App_Secret&"&"&$secret&"&oauth_signature_method=PLAINTEXT"
ConsoleWriteTS("Copy and paste the following url into your browser and click the ok button when you have accepted authorization" & @CRLF & $url & @CRLF)
InputBox("Instructions", "Copy and paste the following url into your browser and click the ok button when you have accepted authorization", $url)
AccessToken($secret, $token)
endif
EndFunc
Func AccessToken($secret, $token)
ConsoleWriteTS("starting Func AccessToken")
Local $obj = ObjCreate("WinHttp.WinHttpRequest.5.1")
local $time = currenttime()
local $Random = Random(0,32767,1)
;ConsoleWriteTS("App key" & " " & $App_Key)
ConsoleWriteTS($token)
Local $sUrl = ("https://api.dropbox.com/1/oauth/access_token" & _
"?oauth_consumer_key=" & $App_Key & _
"&oauth_token=" & $token & _
"&oauth_signature_method=PLAINTEXT" & _
"&oauth_signature=" & $App_secret & "&" & $secret & _
"&oauth_timestamp=" & $time & _
"&oauth_nonce=" & $RANDOM)
ConsoleWriteTS("URL: " & $sUrl)
;$size = stringlen($token)
$obj.Open("POST", $sUrl , False)
ConsoleWriteTS("Open POST")
;$obj.SetResponseHeaders("content-length", $size)
;$obj.SetRequestHeader("User-Agent", "User-Agent=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0")
$obj.send($sUrl)
local $Recieved = $obj.ResponseText
If $obj.Status <> 200 Then
ConsoleWriteTS($obj.status)
ConsoleWriteTS($obj.ResponseText)
MsgBox(0, "Error", "Unable to retrieve your Oauth_token and secret at this time")
else
;iniwrite(@scriptdir & "/
;ConsoleWriteTS($Recieved)
;$oauth_token_secret = GetSecret1($Recieved)
;$oauth_token = GetOauth($Recieved)
msgbox(0, "Success", "Go to the dropbox authenticator folder, open tokens.txt and the last line has your most recent Oauth_token and secret")
local $sFile = fileopen(@desktopdir & "\Dropbox authenticator\tokens.txt",1)
filewrite($sFile, $Recieved)
fileclose($sFile)
endif
EndFunc
Func GetOauth($data)
local $array = _StringBetween($data, "oauth_token=","&")
return $array[0]
EndFunc
Func GetSecret1($data)
local $array = _StringBetween($data, "oauth_token_secret=", "&")
return $array[0]
EndFunc
Func authorize($token_secret, $access_token)
local $time=currenttime()
local $Random = Random(0,32767,1)
local $url = "https://www.dropbox.com/1/oauth/authorize"&"?oauth_consumer_key="&$App_Key&"&oauth_token="&$access_token&"&oauth_signature="&$App_Secret&"&"&$token_secret&"&oauth_signature_method=PLAINTEXT"&"&oauth_timestamp="&$time&"&oauth_nonce="&$RANDOM
local $Random = Random(0,32767,1)
ConsoleWriteTS("url is " & " "&$url)
Local $obj = ObjCreate("WinHttp.WinHttpRequest.5.1")
$obj.Open("GET", $url , False)
;if _FindNetwork() = "xavier" Then $obj.SetProxy(2, "proxy.school:3128")
;ConsoleWriteTS($url)
local $size = stringlen($url)
$obj.SetResponseHeaders("content-length", $size)
$obj.SetRequestHeader("User-Agent", "User-Agent=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0")
$obj.Send($url)
local $status = $obj.Status
local $Recieved = $obj.ResponseText
If $obj.Status <> 200 Then
local $FindError = FindError($status)
ConsoleWriteTS($FindError)
else
ConsoleWriteTS($obj.Status)
endif
EndFunc
Func GetToken1($str)
Local $pie = _StringBetween($str, "oauth_token=","") ; gets the text starting from oauth_token to the end of the file
if $pie = 1 then
ConsoleWriteTS("error")
else
return $pie[0]
endif
EndFunc
Func GetSecret($str)
local $pie = _StringBetween($str,"oauth_token_secret=","&")
if $pie = 1 then
ConsoleWriteTS(@error)
else
ConsoleWriteTS("pie is" & " " &$pie[0])
return $pie[0]
endif
EndFunc
GeSHi © Extension Codebox Plus
Mon autre piste était de passer directement via l'appli windows.
Je pense avoir trouvé la DLL utilisé mais je ne sais pas quoi en faire.
J'ai lu également de la doc sur les communications COM, mais je n'ai pas compris le fonctionnement.
Le .exe de dropbox ne permet pas non plus de crée un lien vers un dossier via une exécution avec des arguments.
Le seul moyen que j'ai trouvé c'est donc d'utiliser le menu contextuel :
► Afficher le texte
Func _GetDropBoxUrl($filepath)
Local $sUrl = ""
Local $aProcessStart = ProcessList("explorer.exe")
Local $sClip = _ClipBoard_GetData()
Local $iPid = Run("C:\Windows\explorer.exe /n,/e," & $filepath, "", @SW_HIDE)
ProcessWait($iPid)
Sleep(1000)
Local $hList = ControlGetHandle("[CLASS:CabinetWClass]", "", "[CLASS:SysListView32; INSTANCE:1]")
ControlSend("", "", $hList, "test+{F10}+{DOWN 9}+{ENTER}")
;~ WinSetState("[CLASS:CabinetWClass]", "", @SW_MINIMIZE)
$aProcessEnd = ProcessList("explorer.exe")
Sleep(1000)
For $i = 1 To $aProcessEnd[0][0]
For $c = 1 To $aProcessStart[0][0]
If $aProcessEnd[$i][1] <> $aProcessStart[$c][1] Then ProcessClose($aProcessEnd[$i][1])
Next
Next
$sUrl = _ClipBoard_GetData()
ConsoleWrite($sUrl & @CRLF)
_ClipBoard_SetData($sClip)
Return($sUrl)
EndFunc
Local $sUrl = ""
Local $aProcessStart = ProcessList("explorer.exe")
Local $sClip = _ClipBoard_GetData()
Local $iPid = Run("C:\Windows\explorer.exe /n,/e," & $filepath, "", @SW_HIDE)
ProcessWait($iPid)
Sleep(1000)
Local $hList = ControlGetHandle("[CLASS:CabinetWClass]", "", "[CLASS:SysListView32; INSTANCE:1]")
ControlSend("", "", $hList, "test+{F10}+{DOWN 9}+{ENTER}")
;~ WinSetState("[CLASS:CabinetWClass]", "", @SW_MINIMIZE)
$aProcessEnd = ProcessList("explorer.exe")
Sleep(1000)
For $i = 1 To $aProcessEnd[0][0]
For $c = 1 To $aProcessStart[0][0]
If $aProcessEnd[$i][1] <> $aProcessStart[$c][1] Then ProcessClose($aProcessEnd[$i][1])
Next
Next
$sUrl = _ClipBoard_GetData()
ConsoleWrite($sUrl & @CRLF)
_ClipBoard_SetData($sClip)
Return($sUrl)
EndFunc
GeSHi © Extension Codebox Plus
1. C'est sale comme méthode, j'ai l'affichage du menu contextuel pendant quelques ms
2. Je ne sais pas comment lire le menu contextuel et du coup je n'ai pas d'autre moyen que de faire 9 DOWN que j'ai calculé à l'avance, du coup si la taille du menu change, c'est mort.
Un grand merci si quelqu'un me trouve une solution

