使用 AHK 从 COM 设备复制文件

Copy files from COM device using AHK

我有一个功能可以有效地从我的 android 设备复制文件,

GetDeviceFolder(deviceName) {
    shell := ComObjCreate("Shell.Application")
    computer := shell.Namespace("::{20d04fe0-3aea-1069-a2d8-08002b30309d}")
    for item in computer.Items
        if item.Name = deviceName
            return item.GetFolder()
}

save_data_file()
{
    GuiControlGet,phonename
    GuiControlGet,datapath
    GuiControlGet,savepath
    phone := GetDeviceFolder(phonename)
    phone.ParseName(datapath).InvokeVerb("copy")
}

但是,我不知道如何将它“粘贴”到本地驱动器。我知道它在剪贴板中,因为我可以在 运行 这个函数之后手动粘贴它。

本地磁盘也需要COM处理

示例:

GetDeviceFolder(deviceName) {
    shell := ComObjCreate("Shell.Application")
    computer := shell.Namespace("::{20d04fe0-3aea-1069-a2d8-08002b30309d}")
    for item in computer.Items
        if item.Name = deviceName
            return item.GetFolder()
}

save_data_file(src, dest) {
    src := StrSplit(src, "\", , 2)
    dest := StrSplit(dest, "\", , 2)
    
    GetDeviceFolder(src[1]).ParseName(src[2]).InvokeVerb("copy")
    GetDeviceFolder(dest[1]).ParseName(dest[2]).InvokeVerb("paste")
}

save_data_file("Phone Name\Internal Storage\Downloada5f641e9893c.jpg", "Disk Name (E:)\incoming")

我喜欢用这个辅助函数

InvokeVerb(path, menu, validate=True) {
    ;by A_Samurai
    ;v 1.0.1 http://sites.google.com/site/ahkref/custom-functions/invokeverb
    objShell := ComObjCreate("Shell.Application")
    if InStr(FileExist(path), "D") || InStr(path, "::{") {
        ;~ MsgBox % path
        objFolder := objShell.NameSpace(path)   
        ;~ MsgBox % namespace(path) . "k"
        objFolderItem := objFolder.Self
    }
    else {
        SplitPath, path, name, dir
        ;~ MsgBox % path . "`n" name . "`n" . dir
    ;~ loop, % path0
        ;~ MsgBox % path%A_index%
    objFolder := objShell.NameSpace(dir)
    objFolderItem := objFolder.ParseName(name)


    }
    if validate {
    colVerbs := objFolderItem.Verbs   
    colVerbs.Count
        loop % colVerbs.Count {
            verb := colVerbs.Item(A_Index - 1) 
            retMenu := verb.name
            StringReplace, retMenu, retMenu, &       
            if (retMenu = menu) {
            verb.DoIt
                Return True
            }
        }


        Return False
    } else
        objFolderItem.InvokeVerbEx(Menu)
}   

然后我就这样做了: InvokeVerb(savepath, "Paste", "false")