首页 > 解决方案 > 如何在typora中使用applescript将markdown导出到html

问题描述

我想使用 Applescript 在 apptypora 上重复将导出降价到 HTML 的处理

我觉得可以分为两部分

第一:点击导出到HTML 第二:选择目标目录,点击保存

但我的第一步有问题

tell application "System Events"
    tell application "Typora"
        open "path/to/my/markdown.md"
    end tell
    tell process "Typora"
        click (menu item "HTML" of menu "export" of menu item "export" of menu "file" of menu bar item "file" of menu bar 1)
    end tell
end tell

此代码不起作用。运行此脚本后没有弹出窗口(要求我选择目标目录)

标签: applescript

解决方案


这对我有用:

activate application "Typora"
delay 1
tell application "System Events"
    tell process "Typora"
        click (menu item "HTML" of menu "export" of menu item "export" of menu "file" of menu bar item "file" of menu bar 1)
        delay 1
        click button "Save" of sheet 1 of window 1
        click button "Replace" of sheet 1 of sheet 1 of window 1
    end tell
end tell

查找更多 UI 元素的有用命令是:entire contents of window 1


推荐阅读