从 macOS Monterey 开始,可以在预览中选择图像中的文本。
AppleScript 和/或 JXA(自动化 JavaScript)是否可以使用此 OCR 功能?
在Script Editor.app File>Open dictionary...我选择了Preview.app并查看了Standard Suite和Text Suite的 API ,但似乎没有任何与 OCR 相关的内容。(文本套件显然与在图片上绘制文本有关,而不是与文本提取有关。)
我还在 Automator.app 中搜索了文本识别操作,但没有看到任何合适的内容。
我已尽力找到Stack Overflow和互联网上的许多脚本问题的解决方案,但我似乎找不到我需要的解决方案.
我想要做的是创建一个更自动化,更少点击的解决方案,以删除系统上的所有移动缓存用户帐户.我一直在登录并手动转到用户帐户并通过单击" - "按钮逐个删除用户,然后单击"立即删除"以获取用户数据.这是有效的,但是很耗时,而且我有更好的时间与我的时间有关.所以我知道必须有一种方法可以用脚本来做到这一点.
我跑过这段代码:
for cuser in `dscl . -list /Users AuthenticationAuthority | grep LocalCachedUser | awk '{print $1}' | tr '/n' ' '`; do
dscl . -delete /Users/$cuser
done
Run Code Online (Sandbox Code Playgroud)
如果我在终端运行这个我得到权限错误.所以我想我需要用sudo运行它.所以我开始考虑创建AppleScripts来运行脚本,但我似乎无法找到正确的方法来执行它.
有任何想法吗?顺便说一下,我是Mac上脚本的新手,所以请注释你的代码,以便我知道发生了什么,所以我不会只是运行一些脚本代码而不知道它会做什么.:)
谢谢
我试图在一个不太可编写的应用程序区域中打开一个文件.
通过使用UI脚本来选择正确的菜单项,我得到了一半,但这会打开一个标准文件对话框.
如何使用Applescript设置文件对话框的目标?
如何检查文件是否是AppleScript或shell脚本中的图像.我知道这个file命令,但它没有说是否是一个图像.
我有一个正在我的计算机上运行的Applescript,但不在我的同事身上.操作路径时出现两个错误:-10004和-10000.我知道如何解决这个问题,但首先我想了解这些错误代码.
这是脚本(我删除了无用的部分,完整版本在github上):
-- export all layers to image files
-- Settings
property exportFileExtension : "png"
property ADD_CANVAS_NUMBER : true
-- End of Settings
on file_exists(FileOrFolderToCheckString)
try
alias FileOrFolderToCheckString
return true
on error
return false
end try
end file_exists
tell application "OmniGraffle Professional 5"
set theWindow to front window
set theDocument to document of theWindow
set theFilename to name of theDocument
-- remove .graffle
-- FIRST ERROR IS HERE -10004
set theFilename to …Run Code Online (Sandbox Code Playgroud) 终端中的Osascript始终为最简单的函数返回此错误.
当我在ApplescriptEditor中运行脚本时运行良好...
例如:
$: osascript -e 'tell application "iTerm" to display dialog "Hello World"'
2014-01-22 11:59:19.822 osascript[665:707] Cannot find executable for CFBundle 0x7fa3f42032e0 </Library/ScriptingAdditions/AeroFSFinderExtension.osax> (not loaded)
osascript: OpenScripting.framework - scripting addition
"/Library/ScriptingAdditions/AeroFSFinderExtension.osax" declares no loadable handlers.
button returned:OK
Run Code Online (Sandbox Code Playgroud)
我已经重新安装了XCode和CLL(使用Appcleaner)
有谁知道如何解决这个错误?(或至少让它沉默......)
我在10.8.5
我这样做:
tell application "System Events" to click button "Reply" of window 1 of process "Notification Center"
Run Code Online (Sandbox Code Playgroud)
如果没有窗口,会出现异常.所以我尝试了这个:
if exists (window 1 of process "Notification Center") then
tell application "System Events" to click button "Reply" of window 1 of process "Notification Center"
end if
Run Code Online (Sandbox Code Playgroud)
但似乎AppleScript不会window 1 of process在某种情况下发生.我怎么能做到这一点?
我想使用Python在Mac OS中打开像TextEdit或Firefox这样的应用程序,等待应用程序退出.我无法弄清楚打开应用程序并等待的确切命令.
我想制作一个可读取文本文件的applescript,然后将每一行的文本复制到剪贴板(从这里进行排序,将其做什么),然后移至下一行并将其复制到剪贴板。谢谢!