Tutorial – Remotely Sync HanDBase Database for Android with Desktop PC via Cloud. Using Dropbox or Google Drive

Set-up the AutoHotKey Macro App for Remote, Automatic Syncing

This section of the Tutorial has been updated since originally published.

The following instructions will still work but I suggest you take a look at the update to see if the Enhanced AutoHotKey scripts might suit your needs better.

After some additional testing I figured out a way in AutoHotKey to automatically select the HanDBase Conduit Partnership, rather than requiring it to be the first Partnership in the list. I have also added instructions for syncing these files between your Android device and Dropbox or Google Drive to make initiating the sync easier, with fewer steps.

To view the update click the following link.

Tutorial Update – Enhanced AutoHotKey Scripts when Remotely Syncing HanDBase Database for Android with Desktop PC via Dropbox or Google Drive

Original Tutorial Instructions Continue Below.


Before you proceed, make sure you have installed the AutoHotKey Macro App on your computer. For this to work properly you will also need to create another folder on Dropbox or Google Drive. You can do this by opening the Dropbox or Google Drive folder on your computer. Create a folder there named:

remoteAction_ran

You will then need to create or modify two scripts for the Remote and Automatic syncing to work properly. At the end of this section you will find a link to download a .ZIP file that includes the two files needed. You can modify those as needed.

The first script is RemoteAction.ahk (.ahk is the file extension for AutoHotKey scripts). This script will always be active on your computer, so that it can run the second script when needed. The commands in the RemoteAction.ahk script are as follows.

RemoteAction.ahk Code

;Format the Date and Time for the Backup file.
FormatTime, CurrentDateTime,, yyyy.MM.dd.HH.mm.ss

; Check if the RemoteHDBSync.ahk script exists in the same folder.
IfExist, RemoteHDBSync.ahk

; If the RemoteHDBSync.ahk script exits, run it to launch the HanDBase Conduit.
; Then wait for about 2 minutes for the Conduit sync to finish before continuing.
{
Run, RemoteHDBSync.ahk
Sleep, 120000

; Move the RemoteHDBSync.ahk file to the remoteAction_ran folder and rename it with the Date and Time ran.
FileMove, RemoteHDBSync.ahk, remoteAction_ran/%CurrentDateTime%_RemoteHDBSync.ahk
}

; Wait for 5 minutes and then restart this script to search for the file again.
Sleep, 300000


Reload

The comments in the code give you a basic idea of what is happening. You should not need to change any of the code in this script. The only thing you may need to change is the “Sleep, 120000” after the RemoteHDBSync script is launched. If you have a lot of databases and it takes longer than 2 minute to synchronize with the HanDBase Conduit you can increase this so the script waits longer. During your testing you can guage how long the sync is taking. The last step is to move the RemoteHDBSync.ahk script file to the remoteAction_ran folder you created before and then re-name it with the Date and Time that the script was run. This will enable you to open Dropbox or Google Drive on your Android device and see exactly when the Sync was executed on your computer, like a log of your sync.

Save a copy of this script file somewhere local, I’d recommend in your HanDBase “sync folder”, eg C:\Users\WindowsUser\Documents\HanDBase\. That way you have a backup of it in case something happens to it. You will then save a copy of it to your Dropbox or Google Drive. Save it to the actual folder mentioned above, when setting up the computer to sync.

  • Dropbox – C:\Users\WindowsUser\Dropbox\
  • Google Drive – C:\Users\WindowsUser\Google Drive\

Next create or modify the RemoteHDBSync.ahk script file. The settings in this script assume you have not made any changes to the Install location of the HanDBase Conduit when you installed it. It also assumes that you only have ONE Partnership set up in the HanDBase Conduit, or that the Partnership that will sync with your device is the first one in the list of Partnerships.

RemoteHDBSync.ahk Code

; Check to see if the HanDBase Conduit is already open.
IfWinExist Manage Android Users
{
; If the HanDBase Conduit is already open, activate it and bring it to the front of other windows.
WinActivate
}
else
{
; If the HanDBase Conduit is not open, launch it and wait for it to open and come to the front of other windows.
Run %A_ProgramFiles%\HanDBase4\Android\AndroidSync.exe
WinWait Manage Android Users
WinActivate
}

; Wait for the HanDBase Conduit to load and show all Partnerships.
Sleep, 5000

; Highlight the Synchronize button using Keyboard commands and then Press Enter to start the synchronization.
Send, {TAB}{TAB}{ENTER}

; Wait One Minute for the Synchronization to complete
; Increase this number if in your tests the Sync takes longer
; 60000 = 1 Minute – 120000 = 2 Minutes – 180000 = 3 Minutes – 300000 = 5 Minutes – ETC.
Sleep, 60000

; Exit the HanDBase Conduit
Send !{F4}

; Wait for the HanDBase Conduit to exit.
Sleep, 5000


; Exit the RemoteHDBSync.ahk script so it's no longer running.
ExitApp

Save a copy of this script file somewhere local, I’d recommend in your HanDBase “sync folder” again, eg C:\Users\WindowsUser\Documents\HanDBase\. That way you have a backup of it in case something happens to it. You will then save a copy of it to your Dropbox or Google Drive. Save it to the same folder you saved the RemoteAction.ahk script file to.

Then on your Android Device open Dropbox or Google Drive and download the RemoteHDBSync.ahk script to your device. You can save this anywhere as long as you can access it again to upload it back to Dropbox or Google Drive when you want to Synchronize.

You can now test the scripts while you are at your computer, to make sure they are functioning as designed. To see that the sync is working I’d recommend adding a test record to one of your databases on your Android device. Then Synchronize your Android using FolderSync. When you see confirmation that the files have been Synchronized you can proceed. While testing do not use any other programs or click anywhere on the screen or the sync may fail. Open your Dropbox or Google Drive folder on your computer and double click the RemoteAction.ahk script to launch it. You will see the AutoHotKey icon appear in the Taskbar. Since this is the first time running the script you will see the HanDBase Conduit window open quickly. You will also see another AutoHotKey icon appear in the Taskbar. You will be able to watch the keyboard commands move to the Synchronize button and then press Enter to start the sync. You will then see the Conduit progress appear. After a minute or so, unless you changed the time in the RemoteHDBSync.ahk file, you will see the HanDBase Conduit window close. You should then only see one of the AutoHotKey icons in the task bar as well. Wait another couple of minutes and then open your Dropbox or Google Drive folder on your computer and you should see that the RemoteHDBSync.ahk file is no longer there. If you open the remoteAction_ran folder you will see the file in there with the Date and Time the script was run in the file name now. When you open the database on your Android device and your computer you should see the test record you added in both places.

The Setup for Remote, Automatic syncing using Dropbox or Google Drive is now finished.

Download the AutoHotKey Script files

If you don’t want to create the AutoHotKey Script files yourself you can click the link below to download the default ones that I created. Clicking the link below will download a .ZIP file that contains the RemoteAction.ahk and RemoteHDBSync.ahk Script files. You can modify these as needed or use them as is.

Download AutoHotKey Script Files

Pages: Prev 1 2 3 4 5 6 7 Next

One Response to this post.

  1. Posted by LordDewi on 02.03.15 at 3:17 am

    After completing this Tutorial I decided to take it a little further. I saw some posts on the DDH Software forum from users who couldn’t or didn’t want to use Cloud Storage. Since FolderSync supports FTP also, I started to set up this type of sync also. I’m in the testing phase for this and I will be posting another tutorial specific to FTP syncing since there are some things that are more specific to this. I’ll also include instructions on setting up your own FTP server.

    In addition, I figured out a way to use AutoHotKey to automatically select the user in the HanDBase Conduit, rather than requiring it be the first user in the list. This should also allow remote syncing for multiple users to the same computer.

Respond to this post

You must be logged in to post a comment.