我正在尝试创建一个 AppleScript 来设置System Preferences中Sound菜单下输入类别的输入音量值。
如何改变 Slider 的值?
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.sound"
end tell
tell application "System Events"
if UI elements enabled then
try
tell application process "System Preferences"
tell tab group 1 of window "Sound"
click radio button "Input"
select row 1 of table 1 of scroll area 1
set selected of row 1 of table 1 of scroll area 1 to true
set deviceselected to …Run Code Online (Sandbox Code Playgroud) 在 PCSX(ps1 模拟器)中,我试图自动执行播放 iso 的步骤。所以,我正在这样做:
set thepath to path to me
set thesecondpath to POSIX path of thepath
set thethirdpath to "Contents/PSX/ROMS/img.bin"
set thefourthpath to "/Contents/PSX/PCSX.app"
set thefifthpath to thesecondpath & thefourthpath
set theultimatepath to thesecondpath & thethirdpath
tell application thefifthpath
activate
tell application "System Events"
keystroke "i" using {command down}
keystroke theultimatepath
delay 1.0
tell process "PCSX"
click button "Go"
end tell
key code 53
end tell
end tell
Run Code Online (Sandbox Code Playgroud)
从 AppleScript 编辑器运行将不起作用。我让它从它创建的应用程序运行。PCSX 和 img.bin 位于生成的包内。
按后command+i,它会打开一个"Go …
我创建了一个对我非常有帮助的AppleScript,我希望是否可以自动更改文件夹图标。
该脚本非常简单,它创建一个文件夹,然后在同一文件夹中创建一个空文本文件。
这是脚本:
tell application "Finder"
set newfolder to make new folder with properties {name:My Folder}
make new file at newfolder with properties {name:"read_me.txt"}
end tell
Run Code Online (Sandbox Code Playgroud)
可以自动更改文件夹图标吗?
(当然,我在与脚本相同的文件夹中拥有自定义文件夹图标 (.icns))
有谁知道是否有 Applescript 错误日志告诉您错误号的含义?
我想打开一个默认为应用程序设置文件夹的文件夹:
/Users/XXX/Library/Application Support/Tunnelblick/Configurations
Run Code Online (Sandbox Code Playgroud)
我不想对“XXX”进行“硬编码”。
文件/library夹:
set theDestination to (choose folder with prompt "Open destination folder" default location (path to library folder))
Run Code Online (Sandbox Code Playgroud)
文件home夹:
set theDestination to (choose folder with prompt "Open destination folder" default location (path to home folder))
Run Code Online (Sandbox Code Playgroud)
我不确定如何获取该~/Library文件夹及其子文件夹之一。
在继续执行脚本之前如何等待网页完全加载?
\n\n我知道如果您希望它等待 4 秒,您可以使用延迟 4,但这不够安全。
\n\n在 VBA 中,您有一个始终有效的简单代码,如下所示:
\n\nDim x As String\nx = "https://na6.salesforce.com/p/attach/NoteAttach?pid=" & Range("T34").Value & "&parentname=" & Range("T35").Value & "&retURL=%2F0018000000sKz8K%3Fpb0%3Dtrue"\n\n Set IE = CreateObject("InternetExplorer.Application")\n IE.Navigate (x)\n IE.Visible = True\n SetParent IE.Hwnd, Application.Hwnd\n\nDo\nDoEvents\nLoop Until IE.READYSTATE = 4\nRun Code Online (Sandbox Code Playgroud)\n\n在 mac 上使用 safari for applescript 相当于什么?
\n\n我\xc2\xb4在网上看到了很多版本,但只有类似于延迟或返回指定值或计算页面上的单词数等的解决方法。
\n\n我只是想要上面的版本是100%完美的。
\n\n先感谢您:)
\n我正在 Applescript 中编写一个快速程序来帮助我学习考试,但我似乎无法正确生成随机数。这是程序:
\n\nrepeat\n set page to (random number from 3 to 198) as text\n set dialog1Text to "Page: " & page & "\n How many paragraphs are on this page?"\n\n display dialog dialog1Text default answer ""\n set userNumParagraphs to text returned of result\n set numParagraphs to (userNumParagraphs) as integer\n\n set paragraph to (random number from 1 to numParagraphs) as text\n set dialog2Text to "Paragraph: " & paragraph\n\n display dialog paragraph\nend repeat\nRun Code Online (Sandbox Code Playgroud)\n\n有一个部分不起作用。这是随机数生成器,这部分:
\n\nset paragraph to (random …Run Code Online (Sandbox Code Playgroud) 是否可以查明 Chrome 是否在隐身模式下运行?
if application "Google Chrome" is running then
tell application "Finder" to display dialog "Chrome is running"
// --> some condition here to check if it is in incognito ?
tell application "Finder" to display dialog "Chrome is running in INCOGNITO mode"
end if
Run Code Online (Sandbox Code Playgroud)
另外,我希望这个脚本继续运行。这意味着一旦用户以隐身模式打开 Chrome,我就会显示警报。像这样:
set chromeRunning to false
repeat until application "Google Chrome" is running
if not chromeRunning then
tell application "Finder" to display dialog "Chrome is started in INCOGNITO mode"
set chromeRunning to true
#may …Run Code Online (Sandbox Code Playgroud) 我正在尝试从坞站中删除(所有)项目。我可以按名称删除它们,如下所示:
tell application "System Events"
tell UI element "Launchpad" of list 1 of process "Dock"
perform action "AXShowMenu"
click menu item "Remove from Dock" of menu 1
end tell
end tell
Run Code Online (Sandbox Code Playgroud)
但我想拉出当前项目的列表并迭代它们。 这个堆栈溢出问题似乎涵盖了如何获取列表。我想做的是调整上面的代码以在循环内运行。我猜想在循环内引用列表的当前项目将使用“thisRecord”完成。我想我误解了如何将“thisRecord”转换为我可以在系统事件中引用的内容。
set plistpath to (path to preferences folder as text) & "com.apple.dock.plist"
tell application "System Events"
set plistContents to contents of property list file plistpath
set pListItems to value of plistContents
end tell
set persistentAppsList to |persistent-apps| of pListItems
set dockAppsList to {}
repeat with thisRecord in …Run Code Online (Sandbox Code Playgroud) 如何在 safari 私人模式下打开 youtube?
我试过这个,但它不起作用:
tell application "Safari" to activate
tell application "System Events"
tell process "Safari"
click menu item "New Private Window" of menu "File" of menu bar 1
open location "https://www.youtube.com" -- this will open default browser
end tell
end tell
Run Code Online (Sandbox Code Playgroud)
我的默认浏览器是 Chrome,它在 chrome 中打开 youtube,而不是在 safari 私人模式下。
如何解决这个问题?