我正在尝试启动并隐藏 Quicktime 播放器,开始录制 iPhone 屏幕一段时间,并使用以下脚本将输出保存在桌面上,文件名为“hello”
on run
set filePath to (path to desktop as text) & "hello.mov"
set f to a reference to file filePath
startVideoRecording(f)
end run
on startVideoRecording(f)
tell application "QuickTime Player"
activate
tell application "System Events"
keystroke "h" using command down
end tell
set newMovieRecording to new movie recording
set camera to "Prabhu Konchada's iPhone"
tell newMovieRecording
set camera to "Prabhu Konchada's iPhone"
start
end tell
delay (10)
pause
save newMovieRecording in f
stop
close newMovieRecording
end …Run Code Online (Sandbox Code Playgroud) 我试图删除每次重新启动计算机时都会显示的隐藏文件,并将 Apple 脚本设置为在启动时运行。然而,我似乎无法正确猜测该文件的路径。
文件的路径是Macintosh HD/Users/cristian/Dropbox (Hyperion)/Hyperion Team 文件夹/图标
如果我将文件移动到桌面并运行下面的脚本,它就会起作用。
tell application "Finder"
delete the file "Icon
" of the desktop
end tell
Run Code Online (Sandbox Code Playgroud)
我的问题是,如何更改此脚本以定位上面的路径?另外,有什么办法可以永久删除它,而不仅仅是将其移至垃圾箱吗?
提前致谢。
显然,有一种方法可以让我的 GUI 应用程序可以使用 AppleScript 编写脚本。例如,我可以有一个命令行应用程序(例如从 LaunchDaemon 运行)来告诉我的 GUI 应用程序发布侧边栏通知。有人有一个简单的例子来解释这一点吗?我在苹果网站上看到的一切都很难理解。
我想创建一条 AppleScript 消息,例如:
tell "My App" to notify with title "Title" subtitle "subtitle" text "some text"
Run Code Online (Sandbox Code Playgroud)
在我的 CLI 应用程序中,然后我的 GUI 应用程序唤醒、接收并处理它。
为了学习如何最大程度地使用 AppleScript 记录和列表,我一直在尝试创建 BBEdit 项目的报告,但我发现文档非常有限。昨天我问了一个问题,试图找出为什么我的查找模式不起作用,但在发现问题是由于我缺乏之后,returning results:true我能够获得结果记录,并且在阅读Class并运行后验证它是一条记录:
class of findFunction
Run Code Online (Sandbox Code Playgroud)
因为它说这是一条记录,我在这里length of findFunction查看并运行count of findFunction,它们都返回了 2。我很好奇知道记录中的这两项内容是什么,所以我使用了return findFunction并被告知有:
found: true
found matches: list of X items
Run Code Online (Sandbox Code Playgroud)
想知道匹配项位于列表中的位置和文件,我做了更多搜索并读取列表和记录并运行:
set theMatches to get found matches of findFunction
Run Code Online (Sandbox Code Playgroud)
它返回列表项并检查新变量,get count of theMatches我可以获取记录内目标列表中的项目数量。当我查看列表中的内容时(学习自:How to get a value from a list with a string in AppleScript?和Searching for items in list),我可以得出结论,在使用findBBEdit 时,列表中的每个项目都包含:
end_offset :
match_string …Run Code Online (Sandbox Code Playgroud) 我试图找出最前面的应用程序 x 是什么,运行一个脚本,然后使用 applescript 将 x 设置为最前面的应用程序。
tell application "System Events"
set frontApp to displayed name of first process whose frontmost is true
set apptemp to frontApp
end tell
Run Code Online (Sandbox Code Playgroud)
[代码在这里]
tell application "System Events"
set frontmost of process whose name is apptemp to true
end tell
Run Code Online (Sandbox Code Playgroud)
尽管此代码不会返回任何错误,但它不起作用。我也尝试过这段代码
tell application "System Events"
set apptemp to application "Google Chrome"
set frontmost of process "Google Chrome" to true
end tell
Run Code Online (Sandbox Code Playgroud)
但同样,虽然没有错误,但它不会工作。
另外,请有人告诉管理员,以便更容易显示代码。我在这个网站上显示代码最困难。我必须为每行代码缩进四个空格,这太疯狂了。
我正在尝试自动快速创建新笔记,并且Notes.app我想在单个浮动窗口中打开新创建的笔记。
这是我创建注释的代码:
set RunTime to ((current date)) as string
tell application "Notes"
activate
tell account "iCloud"
make new note at folder "Notes" with properties {name:RunTime}
--does not work
--open document {name:RunTime}
end tell
end tell
Run Code Online (Sandbox Code Playgroud)
有什么想法吗?
我尝试在弹出窗口中选择“确定”,以使用 Apple 脚本缩放屏幕。
有谁知道我可以向此脚本添加什么以允许我单击“确定”?
苹果脚本:
tell application "System Preferences"
reveal anchor "displaysDisplayTab" of pane "com.apple.preference.displays"
end tell
tell application "System Events" to tell process "System Preferences" to tell window "Built-in Retina Display"
click radio button "Scaled" of radio group 1 of tab group 1
click radio button 1 of radio group 1 of group 1 of tab group 1
(* Trying to click the ok button here *)
delay 1
click ((pop up buttons of sheet 1 of window 1) …Run Code Online (Sandbox Code Playgroud) 在我运行博览会开始后
\n\nWeb 控制台成功打开,但 iOS 模拟器无法正常工作
\n\n安装或运行应用程序时出错。错误:命令失败:osascript -e 告诉应用程序“系统事件”对名称为“模拟器”的进程进行计数\n28:69:执行错误:\xe6\x9c\xaa\xe7\x8d\xb2\xe6\x8e\x88\ xe6\xac\x8a\xe5\x82\xb3\xe9\x80\x81 Apple 事件 \xe7\xb5\xa6\xe3\x80\x8c系统事件\xe3\x80\x8d\xe3\x80\x82 (-1743)
\n\n我怎样才能解决这个问题?
\n\nReact Native 环境信息:\n 系统:\n 操作系统:macOS 10.14.3\n CPU:(4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz\n 内存:38.77 MB / 8.00 GB\ n 外壳程序:3.2.57 - /bin/bash\n 二进制文件:\n 节点:10.15.1 - /usr/local/bin/node\n npm:6.9.0 - ~/.npm-global/bin/npm\ Watchman:4.9.0 - /usr/local/bin/watchman\n SDK:\n iOS SDK:\n 平台:iOS 12.1、macOS 10.14、tvOS 12.1、watchOS 5.1\n IDE:\n Xcode:10.1/10B61 - /usr/bin/xcodebuild\n npmPackages:\n 反应:16.5.0 => 16.5.0 \n 反应原生: https: //github.com/expo/react-native/archive/sdk-32.0.0 .tar.gz => 0.57.1 \n npmGlobalPackages:\n react-native-cli: 2.0.1
\n我正在尝试创建一个脚本,该脚本将打开一个iTerm2窗口,将其垂直分成 3 个窗格,并在每个窗格中运行一些命令。
这是我迄今为止的尝试:
\n\ntell application "iTerm2"\n activate\n\n -- Create main window\n create window with default profile\n\n tell current session of current window\n set name to "frontend"\n write text "cd ~/Documents/frontendDir"\n split vertically with default profile\n end tell\n\n tell second session of current window -- ERROR HERE\n set name to "backend"\n write text "cd ~/Documents/backendDir"\n split vertically with default profile\n end tell\n\n tell third session of current window\n set name to "apollo-server"\n write text "cd ~/Documents/GitHub/apolloDir"\n …Run Code Online (Sandbox Code Playgroud) 我想使用 Automator 和 AppleScript 在 Safari 中填写表单。我有一个功能脚本,看起来像这个玩具示例:
on run {}
tell application "System Events" to keystroke "Hello"
tell application "System Events" to keystroke tab
tell application "System Events" to keystroke "World"
end run
Run Code Online (Sandbox Code Playgroud)
我希望当我位于浏览器中的特定位置时使用键盘快捷键来执行它。但是,当我这样做时,我遇到了权限问题:
The action "Run AppleSCript" encountered an error:
"System Events got an error: Automator Workflow Runner
(WorkflowServiceRunner, my_script_name) is not allowed to send keystrokes"
Run Code Online (Sandbox Code Playgroud)
在System Prefrences -> Security & Privacy -> Privacy -> Accessibility“我已允许Automator和”中AppleScript Utility,在选项卡下 Automation,我已允许System EventsSafari。
如果我也允许 …
applescript ×10
macos ×4
automator ×1
bbedit ×1
cocoa ×1
expo ×1
iterm2 ×1
list ×1
objective-c ×1
record ×1
repeat ×1
safari ×1
scriptable ×1