[CMD] gDrive - interacting with Google Drive
Posted: 13 Mar 2017, 01:55
Let's help each other out
https://www.autohotkey.com/boards/
https://www.autohotkey.com/boards/viewtopic.php?f=22&t=29165
Correct me if i'm wrong, but isn't this just advertising?
Code: Select all
#SingleInstance, Force
GuiCreate() {
Global ; Assume-global mode
Static Init := GuiCreate() ; Call function
Gui, +LastFound -Resize +HWNDhGdrive
Gui, Margin, 10, 10
Gui, Add, ListView, xs y+10 w800 r10, Id|Name|Type|Size|Created
Gui, Show, AutoSize, Example
Populate("'root' in parents and trashed = false")
}
GdQuery(Query) {
File := A_Temp "\GdriveQueryTemp.txt"
If (FileExist(File)) {
FileDelete, % File
}
RunWait, %ComSpec% /c gdrive-windows-386 list --max 0 --name-width 0 --absolute --query "%Query%" > %File%,, Hide
FileRead, QueryContents, % File
return QueryContents
}
Populate(Query) {
File := A_Temp "\GdriveQueryTemp.txt"
FileContents := GdQuery(Query)
IdPos := InStr(FileContents, "Id", 1, 1, 1)
NamePos := InStr(FileContents, "Name", 1, 1, 1)
TypePos := InStr(FileContents, "Type", 1, 1, 1)
SizePos := InStr(FileContents, "Size", 1, 1, 1)
CreatedPos := InStr(FileContents, "Created", 1, 1, 1)
LV_Delete()
Loop, Read, %File%
{
IfEqual, A_Index, 1, Continue
Id := RegExReplace(SubStr(A_LoopReadLine, IdPos, NamePos - IdPos), "^\s+|\s+$")
Name := RegExReplace(SubStr(A_LoopReadLine, NamePos, TypePos - NamePos), "^\s+|\s+$")
Type := RegExReplace(SubStr(A_LoopReadLine, TypePos, SizePos - TypePos), "^\s+|\s+$")
Size := RegExReplace(SubStr(A_LoopReadLine, SizePos, CreatedPos - SizePos), "^\s+|\s+$")
Created := RegExReplace(SubStr(A_LoopReadLine, CreatedPos), "^\s+|\s+$")
LV_Add("", Id, Name, Type, Size, Created)
}
Loop, % LV_GetCount("Col") {
LV_ModifyCol(A_Index, "AutoHdr")
}
}
I really appreciate it if someone like you offers a sample code to show how AHK could be used that way.TheDewd wrote:Very nice!
This could be used to create a file browser in AutoHotkey... For example, the code below to get the root directory
I'd guess, yes. Check out the tools command lines switches/parameters (stdout/logging) for further details.fenchai wrote:Is there a way to detect if Google Drive is syncing at the moment? and also when it is finished?