Skip to content

Instantly share code, notes, and snippets.

@Luoyayu
Last active May 12, 2021 16:17
Show Gist options
  • Save Luoyayu/4830878501d615800d99d98cfc3d6102 to your computer and use it in GitHub Desktop.
Save Luoyayu/4830878501d615800d99d98cfc3d6102 to your computer and use it in GitHub Desktop.
Bear writer: autosave to icloud
tell application "System Events"
-- 前提/premiss:
-- 1. 在iCloud云盘下新建Bear文件夹/Create a new folder "Bear" under the iCloud
-- 脚本做的事:/What the script does:
-- 1. 自动化点击/Automated click
tell application "Bear" to activate -- 打开Bear/Open Bear APP
tell process "Bear"
set frontmost to true -- 置于前台/At the front desk
click menu item "备份笔记..." of menu "文件" of menu bar item "文件" of menu bar 1 -- 点击文件->备份笔记
delay 1
key code 5 using {shift down, command down} -- ⌘+Shift+G
set the clipboard to "~/Library/Mobile Documents/com~apple~CloudDocs/Bear"
key code 9 using {command down}
delay 1
key code 76
click button "导出笔记" of window "请选择保存笔记的位置" of application process "Bear" of application "System Events"
-- key code 13 using {command down} -- ⌘+W -- close Bear Windows
end tell
end tell
@Luoyayu
Copy link
Author

Luoyayu commented Dec 10, 2018

@BitionSong
Copy link

我怎么搜不到bearsave.app啊???

@BitionSong
Copy link

在出发自动备份的,谢谢

@Luoyayu
Copy link
Author

Luoyayu commented Feb 10, 2020

这个script 需要用脚本编辑器编译成 app(文件->导出 格式: 应用程序),第一次使用时需要授权辅助访问, 理论上无论该app放在哪儿,聚焦搜索都能搜索到

@Luoyayu
Copy link
Author

Luoyayu commented Feb 10, 2020

脚本更新了,这是我自己签名的app https://c-t.work/s/60846921cdbf44#code=w9djtl

@BitionSong
Copy link

脚本更新了,这是我自己签名的应用https://ct.work/s/60846921cdbf44#code=w9djtl

app我可以直接拿来使用吗?

@BitionSong
Copy link

你目前是没有订阅bear是吧?我也是没有订阅,用的tf版本 ,手机和电脑可以同步,不喜欢订阅制的app。其他笔记又不喜欢,

@BitionSong
Copy link

我回家试过了,可以的,就是现在不删除之前的备份了是不是的?其他好像都正常的。

@Luoyayu
Copy link
Author

Luoyayu commented Feb 13, 2020

是的,Apple Script 还是很好用的。不想写代码可以考虑用 自动完成 的“我做给你看”

@flexih
Copy link

flexih commented Apr 29, 2020

tell application "System Events"
	
	-- 前提/premiss:
	
	-- 1. 在iCloud云盘下新建Bear文件夹/Create a new folder "Bear" under the iCloud
	
	-- 脚本做的事:/What the script does:
	
	-- 1. 自动化点击/Automated click
	
	tell application "Bear" to activate -- 打开Bear/Open Bear APP
	
	tell process "Bear"
		
		set frontmost to true -- 置于前台/At the front desk
		click menu item "Backup Notes..." of menu "File" of menu bar item "File" of menu bar 1 -- 点击文件->备份笔记
		delay 1
		key code 5 using {shift down, command down} -- ⌘+Shift+G
		set the clipboard to "~/Library/Mobile Documents/com~apple~CloudDocs/Bear"
		key code 9 using {command down}
		delay 1
		key code 76
		click button "Export notes" of window "Please choose the location where the notes will be saved" of application process "Bear" of application "System Events"
		
		-- key code 13 using {command down} -- ⌘+W -- close Bear Windows
		
	end tell
	
end tell

英文菜单

@Cherrymelon
Copy link

请问点击编译无反应,退出时显示该文稿未能自动存储,错误-1752,应该怎么做?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment