API

自动传输、远程设置设置和控制许可证。

此功能需要 OffShoot Pro 许可证。通过 License Manager 或通过 OffShoot > Settings > License 进行升级。在此处查看所有 Pro 功能。

你可以通过调用 URL offshoot:// 来告诉 OffShoot 执行某些操作。你可以从任何能够打开 URL 的应用程序或脚本中调用此 URL 。

使用 Hedge?将 offshoot:// 改为 hedge:// 就可以了。

使用浏览器

复制/粘贴下面的网址到一个网络浏览器中,按下 Enter 键,OffShoot 将会打开。

offshoot://open

使用 shell

请将下面的命令复制/粘贴到终端中,按下 Enter 键,OffShoot 将会打开。

Mac

使用终端

open 'offshoot://open'

Windows

使用 PowerShell

start 'offshoot://open'

使用脚本

Mac

AppleScript:

do shell script ("open 'offshoot://open'")

Python:

import os
os.system("start 'offshoot://open'")
Windows

Python:

import os
os.system("start 'offshoot://open'")

API调用的结果被记录在一个文本文件中。

Mac

位置: ~/Library/Logs/Hedge/urlSchemeResponseLog.txt

这个日志将包含一行 successfail 状态。在OffShoot启动时为空,在每次调用后清空。

Windows

位置: C:\Users\$username\AppData\Roaming\Hedge\HedgeCallback.log

这是一个多行日志。它在应用启动时和每次调用后都会清空。

$time | $id | $arguments_passed
$time | $id | $call_result

API 调用

控制 OffShoot 的应用程序状态。

打开

offshoot://open

退出

offshoot://quit

重新启动

offshoot://restart

检查更新

offshoot://update

激活

offshoot://activate?key=xxxx-xxxx-xxxx-xxxx

URL 参数 类型 描述
key 字符串 必填

关闭

offshoot://deactivate

动作链

actions 调用允许您在单个请求中传递多个 API 调用:

offshoot://actions?json=[{"<action>":{"<property>": "<value>"},},{"<action>":{"<property>": "<value>"}}]
URL 参数 类型 描述
json 包含 JSON 对象的数组 必填
<action> 字符串 API 操作
<property> 字符串 操作属性
<value> 各种 属性的值

比如,你可以将以下两个操作包含在一个动作链中:

offshoot://deactivate
offshoot://activate?key=xxxx-xxxx-xxxx-xxxx

改写的动作链为:

offshoot://actions?json=[{"deactivate":{}},{"activate":{"key":"xxxx-xxxx-xxxx-xxxx"}}]

调用无法正常工作?将JSON字符串进行URL编码。
没有属性的操作以{}传递。
链式操作可能会导致时间问题。在调试时要牢记这一点。如果遇到时间问题,请将链式操作分割为多个调用,并根据 timers/OffShoot Events 事件或日志输出进行处理。

重置磁盘

sources(来源)/destinations(目标) 拖放区域中移除磁盘。现有的传输不受影响。如果未定义type,则源和目标都将被重置。

offshoot://reset?type="sources"

URL 参数 类型 描述
type Sting 可选的 sourcesdestinations

设置源

设置一个单一的源或一组路径,并在定义时应用一个标签。

offshoot://setSource?paths=["/Volumes/UNTITLED"]&label=Clips

URL 参数 类型 描述
paths Array 必需的
label String 可选的
调用无法正常工作?将JSON字符串进行URL编码。
Mac

终端示例:

open 'offshoot://actions?json=[{"setSource":{"paths":["/Volumes/Untitled/The Clips"],"label":"test"}}]'

使用URL编码的json键值对进行调用

open 'offshoot://actions?json=%5B%7B%22setSource%22%3A%7B%22paths%22%3A%5B%22%2FVolumes%2FUntitled%2FThe%20Clips%22%5D%2C%22label%22%3A%22test%22%7D%7D%5D
Windows

PowerShell 示例:

带有转义引号的调用

start 'offshoot://actions?json=[{\"setSource\":{\"paths\":[\"G:\The Clips\"],\"label\":\"test\"}}]'

使用URL编码的json键值对进行调用

start 'offshoot://actions?json=[{"setSource":{"paths":["G:\The Clips"],"label":"test"}}]'

编码结果为

start 'offshoot://actions?json=%5B%7B%22setSource%22%3A%7B%22paths%22%3A%5B%22G%3A%5CThe%20Clips%22%5D%2C%22label%22%3A%22test%22%7D%7D%5D'

设定目标

设置单个目标

offshoot://setDestination?path=/Volumes/BACKUP

URL 参数 类型 描述
path 数组 必需/URL 编码
调用无法正常工作?将JSON字符串进行URL编码。
Mac

终端示例:

open 'offshoot://actions?json=[{"setDestination":{"path":"/Volumes/Untitled/The Project"}}]'

使用URL编码的json键值对进行调用

open 'offshoot://actions?json=%5B%7B%22setDestination%22%3A%7B%22path%22%3A%22%2FVolumes%2FUntitled%2FThe%20Project%22%7D%7D%5D'
Windows

PowerShell 示例:

带有转义引号的调用

start 'offshoot://actions?json=[{\"setDestination\":{\"path\":\"G:\The Clips\"}}]'

使用URL编码的json键值对进行调用

start 'offshoot://actions?json=[{"setSource":{"paths":["G:\The Clips"],"label":"test"}}]'

编码结果为

start 'offshoot://actions?json=%5B%7B%22setSource%22%3A%7B%22paths%22%3A%5B%22G%3A%5CThe%20Clips%22%5D%2C%22label%22%3A%22test%22%7D%7D%5D'

新增传输

创建所有新的源和目标组合的传输。与在OffShoot中按下Add Transfers按钮相同。

offshoot://addTransfers

设置首选项

将特定首选项设置为特定值。此处提供了所有键名的完整列表:

/Applications/OffShoot.app/Contents/Resources/SFIDefaults.plist

不确定要使用哪个键名称?尝试更改 OffShoot 中的设置,然后在以下位置验证修改后的值:

~/Library/Preferences/nl.syncfactory.Hedge.Mac.plist

offshoot://setPreferences?preferences={"SFIDefaultsAutoSources":"0"}

URL 参数 类型 描述
preferences JSON 对象 必填
SetPreferences 操作仅适用于 macOS。

在 Windows 上,您可以在 Windows 注册表的 <current-user>\Software\Hedge 下设置相应的键和值。