簡體   English   中英

使用 AppleScript 在 Powerpoint 中選擇橡皮擦

[英]Use AppleScript to select eraser in Powerpoint

首先,是我的問題的視頻解釋。

我是一名教師,正在尋找一種在使用 PowerPoint 進行演示的同時輕松訪問橡皮擦工具的方法。 部分遵循本指南,當我選擇橡皮擦時,我嘗試使用 Automator 記錄我的操作,將其保存為快速操作,然后為該操作分配鍵盤快捷鍵。

不幸的是,我收到錯誤:

操作“Watch Me Do”遇到錯誤:“Application Powerpoint 未按預期運行”

或者,如果我首先從 Automator 操作中復制代碼,將其粘貼到運行 AppleScript 文件中,然后設置一個快捷方式來執行該文件,則會得到以下信息:

操作“運行 AppleScript”遇到錯誤:“操作無法完成。 (com.apple.Automator 錯誤 -212。)”

有人可以幫忙嗎? 謝謝!

或者,如果有人知道實現我的目標的更好方法,請分享。

有時,您需要一次一個地完成每個流程以隔離產生錯誤的原因。 首先讓我們看看這段代碼是否會選擇橡皮擦工具。
將以下 AppleScript 代碼粘貼到新的 Script Editor.app 文檔中。 您可以直接從該文檔運行代碼。 如果代碼適合您,則嘗試將其粘貼到您的 Automator 工作流程中。

tell application "Microsoft PowerPoint"
    activate
    repeat until frontmost
        delay 0.1
    end repeat
end tell

tell application "System Events"
    repeat while not (exists of radio button 3 of tab group 1 of window 1 of application process "PowerPoint")
        delay 0.1
    end repeat
    if not (exists of menu button "Eraser" of group 1 of scroll area 1 of tab group 1 of window 1 of application process "PowerPoint") then
        click radio button 3 of tab group 1 of window 1 of application process "PowerPoint"
        delay 0.1
        if value of menu button 1 of group 1 of scroll area 1 of tab group 1 of window 1 of application process "PowerPoint" is 0 then
            click menu button "Eraser" of group 1 of scroll area 1 of tab group 1 of window 1 of application process "PowerPoint"
        end if
    else
        delay 0.1
        if value of menu button 1 of group 1 of scroll area 1 of tab group 1 of window 1 of application process "PowerPoint" is 0 then
            click menu button "Eraser" of group 1 of scroll area 1 of tab group 1 of window 1 of application process "PowerPoint"
        end if
    end if
end tell

在此處輸入圖片說明

確保將 Automator.app、Script Editor.app、System Events.app 和 PowerPoint.app...以及您的腳本(如果已保存為 .app)添加到系統偏好設置 > 安全性 > 隱私 > 輔助功能應用程序列表. 然后再次將這些相同的項目添加到系統偏好設置 > 安全 > 隱私 > 全盤訪問應用程序列表。

在此處輸入圖片說明

此外,如果您將腳本或 Automator 工作流保存為應用程序,則無論何時進行更改並再次保存該文件,您都需要返回並再次將其添加到安全首選項中的那些應用程序列表中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM