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 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