Sign in to follow this  
Followers 0
ptrex

DropboxEX - Hardlinks

12 posts in this topic

DropboxEX - Hardlinks

Dorpbox is getting more and more versatile !

Most of you know it as a file sharing tool for different OS's and Mobile platforms .

But Dropbox can be more. Much more. Using some web programming trickery (which the folks at Dropbox encourage), software developers have whipped up a number of web apps that extend Dropbox and make it even more useful. And, to be honest, a lot cooler ....http://www.the10most.com/misc/10-great-web-apps-that-let-you-use-dropbox-for-more-than-storage.html

By the way I use 8 / 9 and 10, just amazing, but that's a different story.

Anyhow the feature that is missing is, can I sync files and folders which are outside of the Dropbox area.

And not to use a seperate sync tool that copies / duplicates all the files ?

The answer was given here :

Important ; https://forums.dropbox.com/topic.php?id=51001

To sync multiple external folders, follow these instructions:

1.Quit (or pause) Dropbox on all of the involved computers.

2.Delete any pre-existing symlinks in your Dropbox pointing towards your Desktop. You will have to do this on all of your computers.

3.On every computer involved, create a new symlink inside your Dropbox folder pointing towards your desktop. Make sure that on every computer involved, you put the symlink in the same location inside your Dropbox.

4.Launch (or un-pause) Dropbox.

Once synced, everything should work perfectly.

Ok let's see what we can do with AutoIT to help a hand.

I created 2 versions to create hard links to the dropbox folder called EXTERNAL.

1 version is using native AutoIT commands

The second version is using the _WinAPI commands.

( Downside on this one is that you needs full administrator rights :-( Not so elegant of course ! )

Enjoy,

ptrex

DropboxEx Folder Sync.au3

DropboxEx Folder Sync_WinAPI.au3

2 people like this

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Thanks. Nice example of using WinAPIEx.

Edit: By the way in the native script Array.au3 has been included for no reason and I don't understand the code below as _PathSplit neither returns an @error value or @extended. I take it that was left over from the WinAPI version.

If @error Or @extended Then
    MsgBox(16, 'Error', 'You do not have the required privileges.')
    Exit
EndIf
Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Without the need for _PathSplit, so now it uses 100% AutoIt native functions.

Local $sDropboxDir = @UserProfileDir & 'DropboxExternal'
Local $sSourceDir = FileSelectFolder('Choose a folder.', '')

_CreateDropboxHardLink($sSourceDir, $sDropboxDir, 1)

Func _CreateDropboxHardLink($sSourcePath, $sDropboxPath = Default, $iFlag = 0)
    If $sDropboxPath = Default Then
        $sDropboxPath = @UserProfileDir & 'DropboxExternal'
    EndIf
    Local $sPath = StringTrimLeft($sSourcePath, StringInStr($sSourcePath, '', 2, -1))
    Local $sDestinationPath = $sDropboxDir & '' & $sPath
    If FileExists($sDestinationPath) = 0 Then
        ; DirCreate($sDestinationPath) & @CRLF)
        ConsoleWrite($sDestinationPath & @CRLF)
    EndIf
    Return ConsoleWrite("Data From " & '"' & $sSourcePath & '"' & " To " & '"' & $sDestinationPath & '"' & @CRLF)
    Return FileCreateNTFSLink($sSourcePath, $sDestinationPath, $iFlag)
EndFunc   ;==>_CreateDropboxHardLink

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I guess maybe Dropbox solved the old symlink/junction issue then? It used to be that a running instance of Dropbox would not recognize changes inside a directory junction until it was restarted. So the old solution was to have the real files inside your Dropbox folder, and the symlinks/junctions on the system.

Edit -

Nope, problem still exists. This was always such a bummer, but the old solution still works of course.

Edited by wraithdu

Share this post


Link to post
Share on other sites

@guinness

Thanks for the cleanup !

@Wraithu

It is not solved, but the work around is simple.

Right click the Dropbox icon -> Select PAUZE Syncing -> Select RESUME syncing. And you off again :-)

For me this is realy a 'non issue' compaired to the benifits it gives :-).

Maybe someone can write a script to pauze / resume syncing every x-time.

Rgds

ptrex

Share this post


Link to post
Share on other sites

Ah, well that's a nice bonus to the pause function then. I ran into this problem and changed the way I was organizing things before Dropbox had pause ;)

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

Ah, well that's a nice bonus to the pause function then. I ran into this problem and changed the way I was organizing things before Dropbox had pause ;)

His request was granted:

I hope you enjoy!

Regards,

João Carlos.

1 person likes this

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Share this post


Link to post
Share on other sites

Awesome! petrex. 5 stars from me. :thumbsup:


73 108 111 118 101 65 117 116 111 105 116

Share this post


Link to post
Share on other sites

@all

If you want to schedule the Pause / Resume then you could use this version.

Credits to Melba and others for the basics I found on the forum.

I modified this version to fit the needs.

#include <GuiToolBar.au3>
#Include <GuiMenu.au3>
#include <SendMessage.au3>
#include <WindowsConstants.au3>

; If you want to click on the bottom item then you just have to send the enter key Send("{ENTER}")
; If you want to 2nd item from the bottom then : Send("{UP 1}{ENTER}")
; Credits tor Rover / Melba / ... ??

Global $hSysTray_Handle, $iSysTray_ButtonNumber

Global $sToolTipTitle = "Dropbox"
Global $nChars = 7 ; Number of chars to catch

$iSysTray_ButtonNumber = Get_SysTray_Index($sToolTipTitle, $nChars)

If $iSysTray_ButtonNumber = -1 Then
MsgBox(16, "Error", "Icon not found in system tray")
Exit
Else

_GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSysTray_ButtonNumber, "right")
Sleep(500)
Send("{UP 4}") ; Menu index 4 UP
Local $ret

$ret = GetPopUpSelText()
ConsoleWrite($ret & @CRLF) ; This will read the currently selected item

If $ret == "Pause syncing" Then
Send("{ENTER}")
Sleep (1500)
EndIf

_GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSysTray_ButtonNumber, "right")
Sleep(500)
Send("{UP 4}")

$ret = GetPopUpSelText()
ConsoleWrite($ret & @CRLF)

If $ret == "Resume syncing" Then
Send("{ENTER}")
Sleep (1500)
Else
MsgBox(48,"Status","Check the Dropbox Status")
EndIf
EndIf

Exit


Func Get_SysTray_Index($sToolTipTitle, $iChar=30)
;ConsoleWrite("Search String = " & StringLeft($sToolTipTitle,$iChar) & @CRLF)

; Systray handle
$hSysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]')
If @error Then
MsgBox(16, "Error", "System tray not found")
Exit
EndIf

; Systray item count
Local $iSysTray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle)
If $iSysTray_ButCount = 0 Then
MsgBox(16, "Error", "No items found in system tray")
Exit
EndIf

; Tooltip catch
For $iSysTray_ButtonNumber = 0 To $iSysTray_ButCount - 1
;ConsoleWrite("Index = " & $iSysTray_ButtonNumber & " Text = " & _GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSysTray_ButtonNumber) & @CRLF)
If StringLeft(_GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSysTray_ButtonNumber),$iChar) = $sToolTipTitle Then
;ConsoleWrite($iSysTray_ButtonNumber & @CRLF)
Return $iSysTray_ButtonNumber ; Found
EndIf
Next
Return -1 ; Not found
EndFunc ;==>Get_SysTray_Index

Func GetPopUpSelText()
Local $aPopUp_List = _WinAPI_EnumWindowsPopup()
Local $hWnd = $aPopUp_List[1][0]
Local $sClass = $aPopUp_List[1][1]
If $sClass = "#32768" Then ; This is a "standard" Windows API popup menu
     $hMenu = _SendMessage($hWnd, $MN_GETHMENU, 0, 0)
     If _GUICtrlMenu_IsMenu($hMenu) Then
         $iCount = _GUICtrlMenu_GetItemCount($hMenu)
         For $j = 0 To $iCount - 1
             If _GUICtrlMenu_GetItemHighlighted($hMenu, $j) Then
                 Return _GUICtrlMenu_GetItemText($hMenu, $j)
             EndIf
         Next
     EndIf
EndIf
Return ""
EndFunc

Enjoy !

rgds

ptrex

1 person likes this

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Similar Content

    • TheSaint
      By TheSaint
      I've finally come up with a simple solution for dragging & dropping a URL.
      It's not perfect, but it does the job. Mostly just a tweak of some Help file examples.
      Thanks also to AutoBert, for his StringRegExp and example that set me on the right path.
      I have seen this requested for many times, so enjoy!
      It goes without saying, that any improvements are welcome.
      Dropbox For URLs.au3
      #include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Global $hGui, $g_hRichEdit Example() Func Example() Local $cnt, $URL, $val, $text Local $iMsg, $state = $WS_CAPTION + $WS_POPUP + $WS_CLIPSIBLINGS + $WS_SYSMENU $hGui = GUICreate(StringTrimRight(@ScriptName, 4), 160, 100, -1, -1, $state, $WS_EX_TOPMOST) $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 140, 80, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) GUISetState(@SW_SHOW) _GUICtrlRichEdit_SetEventMask($g_hRichEdit, $ENM_LINK) _GUICtrlRichEdit_AutoDetectURL($g_hRichEdit, True) $cnt = 0 While True $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($g_hRichEdit) ExitLoop Case Else If $cnt = 20 Then $text = _GUICtrlRichEdit_GetText($g_hRichEdit) If $text <> "" Then $val = StringRegExp($text, "(?s)((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)", 2) If UBound($val) > 0 Then $URL = $text ClipPut($URL) ;MsgBox(0, "URL", $URL, 0, $hGui) Else _GUICtrlRichEdit_SetText($g_hRichEdit, "Only URL's are supported!") ;MsgBox(0, "Not URL", "Only URL's are supported!", 0, $hGui) EndIf Sleep(600) _GUICtrlRichEdit_SetText($g_hRichEdit, "") EndIf $cnt = 0 Else $cnt = $cnt + 1 EndIf EndSelect WEnd EndFunc ;==>Example GUIDelete($hGui) Exit I also wanted a version that would work with an earlier version of AutoIt (v3.3.0.0), to use with updates for some older scripts (programs).
      The following works fine on my Win XP laptop, but fails (also when compiled) on my Win 7 Netbook.
      I found a RichEdit example in the GUICtrlCreateEdit function (Example 2) in the AutoIt v3.3.0.0 Help file, and modified that to suit my script.
      Failure is no doubt due to 'MSCOMCT2.OCX' missing from the System32 folder, at the very least.
      Any solution to getting the following to work on Win 7 would be greatly appreciated. Perhaps a different '.OCX' file etc.
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> Global $oMyError RichEditExample() Exit ; Rich edit control EXAMPLE using GUICtrlCreateObj ; Author: Kåre Johansson ; AutoIt Version: 3.1.1.55 ; Description: Very Simple example: Embedding RICHTEXT object ; Needs: MSCOMCT2.OCX in system32 but it's probably already there ; Date: 3 jul 2005 Func RichEditExample() Local $cnt, $DropBoxGUI, $GUIActiveX, $msg, $oRP, $state, $text, $URL, $val $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $oRP = ObjCreate("RICHTEXT.RichtextCtrl.1") If @error Then Return $state = $WS_CAPTION + $WS_POPUP + $WS_CLIPSIBLINGS + $WS_SYSMENU $DropBoxGUI = GUICreate(StringTrimRight(@ScriptName, 4), 160, 100, -1, -1, $state, $WS_EX_TOPMOST) $GUIActiveX = GUICtrlCreateObj($oRP, 0, 0, 140, 80) GUICtrlSetPos($GUIActiveX, 5, 5, 150, 90) $cnt = 0 With $oRP; Object tag pool .OLEDrag() .Font = 'Arial' .Text = @CRLF & @CRLF & " Drag & Drop a URL here." .SelBold = True .BackColor = 0xff00 ;.FileName = @ScriptDir & '\RichText.rtf' ;$oRP.AboutBox() ;$oRP.SelBold = False ;$oRP.SelItalic = False ;$oRP.SelUnderline = False ;$oRP.SelFontSize = 8 ;$oRP.SaveFile(@ScriptDir & "\RichText.rtf", 0) EndWith GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUIDelete($DropBoxGUI) ExitLoop Case Else If $cnt = 20 Then $text = $oRP.Text If $text <> "" Then If $text = @CRLF & @CRLF & " Drag & Drop a URL here." Then Sleep(2000) Else $val = StringRegExp($text, "(?s)((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)", 2) If UBound($val) > 0 Then $URL = $text ClipPut($URL) ;MsgBox(0, "URL", $URL, 0, $hGui) Sleep(600) Else With $oRP .Text = "Only URL's are supported!" EndWith ;MsgBox(0, "Not URL", "Only URL's are supported!", 0, $hGui) Sleep(1500) EndIf EndIf With $oRP .Text = "" .SelBold = False EndWith EndIf $cnt = 0 Else $cnt = $cnt + 1 EndIf EndSelect WEnd EndFunc ;==>RichEditExample Func MyErrFunc() MsgBox(0, "AutoItCOM Test", "We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & Hex($oMyError.number, 8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext , 5) ; Will automatically continue after 5 seconds Local $err = $oMyError.number If $err = 0 Then $err = -1 SetError($err) ; to check for after this function returns EndFunc ;==>MyErrFunc And a slower embedded IE based version. This has an error in latest AutoIt, but works fine in v3.3.0.0.
      #include <Constants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> Local $DropboxGUI, $GUIActiveX, $loaded, $loops, $oBody, $oIE, $sHTML, $timeout, $urlpage _IEErrorHandlerRegister() $oIE = _IECreateEmbedded() $DropboxGUI = GUICreate("URL Dropbox", 140, 140, -1, -1, _ $WS_OVERLAPPED + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_SYSMENU, $WS_EX_TOPMOST) $GUIActiveX = GUICtrlCreateObj($oIE, 5, 5, 125, 100) $oBody = _IETagNameGetCollection($oIE, "body", 0) _IEDocInsertHTML($oBody, "", "afterbegin") $loaded = _IEPropertyGet($oIE, "locationurl") $urlpage = $loaded $loops = 0 $sHTML = "" $sHTML &= "<HTML>" & @CR $sHTML &= "<HEAD>" & @CR $sHTML &= "<TITLE>Drag And Drop Example</TITLE>" & @CR $sHTML &= "</HEAD>" & @CR $sHTML &= "<BODY>" & @CR $sHTML &= "</BODY>" & @CR $sHTML &= "</HTML>" _IELoadWaitTimeout(1) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ; Quit, Close or Exit window GUIDelete($DropboxGUI) ExitLoop Case Else ;;; If $loops = 10 Then $loops = 0 $loaded = _IEPropertyGet($oIE, "locationurl") If $loaded <> $urlpage Then _IEAction($oIE, "stop") _IEDocWriteHTML($oIE, $sHTML) If $loaded = "res://ieframe.dll/navcancl.htm" Then $loaded = "" $urlpage = $loaded _IEBodyWriteHTML($oIE, '<p style="WORD-WRAP: normal; WORD-BREAK: break-all; FONT-SIZE: 8px">' & $loaded & '</p>') EndIf Else $loops = $loops + 1 EndIf EndSelect WEnd Exit  
    • dgm5555
      By dgm5555
      I'd like to create a dropbox uploader (and downloader) to provide a simple file sync without using the dropbox app.
      The following is my current code (cadged and modified from other posts and websites), but I can't even figure out how to get initial authorization. Can anyone help?
      NB I would be quite happy to use the oauth2 Generated access token if it bypassed a lot of this, but I'm not sure how to do this.
      (If you can't guess, I know virtually nothing about http calls)
      Alternatively if there is a working autoit dropbox up/downloader, I'm more than happy not to write my own (but couldn't find one)
      Thanks
       
      #include "WinHttp.au3" ; set the dropbox tokens ;to get the dropbox app_key and app_secret tokens, browse to https://www.dropbox.com/developers/apply?cont=/developers/apps and create a new app If $App_Key = "" Then $File = "" $App_Key = "" $App_secret = "" $Oauth_access_token = "" $Oauth_access_token_secret = "" ; this could possibly the personal Oauth2 Generated access token $App_folder = "" ; this is the name of your app - it's not currently needed in this code ; the folder where the uploaded file will be stored is: Dropbox/Apps/$App_folder EndIf Local $sURL = "https://api.dropbox.com/1/oauth/request_token " & _ "Authorization: OAuth oauth_version=""1.0"", oauth_signature_method=""PLAINTEXT"", " & _ "oauth_consumer_key=""" & $App_Key & """, " & _ "oauth_signature=""" & $App_secret & "&""" $hOpen = _WinHttpOpen() $FileHandle = FileOpen($File) $hConnect = _WinHttpConnect($hOpen, $sURL) $hRequest = _WinHttpOpenRequest($hConnect, "POST") _WinHttpReceiveResponse($hRequest) $sResult = "" Do $sResult &= _WinHttpReadData($hRequest) Until @error ;MsgBox(0, "", $sResult) ConsoleWrite($sResult & @CRLF) _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; response should be: ;oauth_token=<request-token>&oauth_token_secret=<request-token-secret> ;user will have to browse to the following and authorise the app ;https://www.dropbox.com/1/oauth/authorize?oauth_token=<request-token> ; you now need to generate an access token ; POST https://api.dropbox.com/1/oauth/access_token ; Header will be: ;Authorization: OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT", oauth_consumer_key="<app-key>", oauth_token="<request-token>", oauth_signature="<app-secret>&<request-token-secret>" ;reponse will be: ;oauth_token=<access-token>&oauth_token_secret=<access-token-secret>&uid=<user-id> ;now you can access the account and undertake actions ;eg get account info: ;GET https://api.dropbox.com/1/account/info ;Header: ;Authorization: OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT", oauth_consumer_key="<app-key>", oauth_token="<access-token>", oauth_signature="<app-secret>&<access-token-secret>" ; this function doesn't work, it will need to be modified to allow upload 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=@HOUR & ":" & @MIN & ":" & @SEC 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 ;message($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/apply?cont=/developers/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 & "%26" & $Oauth_access_token_secret & _ " & oauth_timestamp=" & $time & _ " & oauth_nonce=" & $RANDOM) ;Authorization: OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT", ;oauth_consumer_key="<app-key>", oauth_token="<access-token>", ;oauth_signature="<app-secret>&<access-token-secret>" msgbox(1,"URL",$sUrl) ; now attempt to upload the file with the generated dropbox URL Local $obj = ObjCreate("WinHttp.WinHttpRequest.5.1") ;message("here") $obj.Open("PUT", $sURL, False) If @error Then MsgBox(1,"ERROR","@1unable to upload" & " " &$array[$i-1] & $array[$i]) else ; message("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 ; message($sFile) $obj.Send($data) ; send the file to uploaded $oReceived = $obj.ResponseText $oStatusCode = $obj.Status If $obj.Status <> $HTTP_STATUS_OK Then ; local $FindError = FindError($oStatusCode) ; message($oReceived) msgbox(0 , "Error", "@2" & $oStatusCode & " :unable to upload " & $array[$i-1] & $array[$i]) else msgbox(0 , "success", "uploaded " & $array[$i-1] & $array[$i]) endif trayseticon("C:\Program Files\AutoIt3\Icons\panda.ico", -1) endif endfunc  
    • wakillon
      By wakillon
      Using GoogleDrive for store my files, some days ago, i discover those nice messages :
                 
      It is certain that if someone wants downloaded my files, such messages is not very encouraging !
      So, don't know which incompetent AV Google use, but i decided to try some other files hosters.
      I have made this script last year for GoogleDrive, but tired of false positives, i adapted it to OneDrive and Dropbox too. 
      Added the possibility to create a Html ShortcutRedirector as i use in my topics for download files.
       

      Buttons were made online with chimply.com the easy and free buttons generator !
       
      Source : SharedLink2DirectLink v1.0.0.9.au3.html
       
      Executable : SharedLink2DirectLink.exe.html
       
      Hope it can help someone ! 
    • Gimerly
      By Gimerly
      This .au3 file will take the trouble out of trying to gain your dropbox oauth_access_token and oauth_access_token_secret by doing it for you. when first run the program it will create an empty folder on your desktop. As you progress through the application it will create text files as needed. Be sure to follow each of the message box's instructions as it is vital that each step be completed before moving onto the next. Enjoy
    • adamchapman
      By adamchapman
      I'm trying t upload a file to dropbox using the dropbox RESTful API. 
       
      In the last section on the page at http://cgeers.com/2012/03/11/dropbox-rest-api-part-5-file-upload/ , 
      the author uses a method "GetRequestStream"
       
      Everything I've done so far with the dropbox API has utilised a winhttp object, with the structure below:
      $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("POST", $URL, false) $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") $authString = 'OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT", oauth_consumer_key="'& $key & '", oauth_token="' & $accessToken & '", oauth_signature="' & $secret & '&' & $accessSecret & '"' $oHTTP.SetRequestHeader("Authorization",$authString) ; Performing the Request $oHTTP.Send() ; Download the body response if any, and get the server status response code. $oReceived = $oHTTP.ResponseText $oStatusCode = $oHTTP.Status Now I need a GetRequestStream() mehod, I'm not sure if there is a facility to do this.
      I've tried $oHTTP.GetRequestStream() but it just threw an error
      If anybody can offer some insight It would be a great help