- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我做了这个快速的 Applescript 应用程序,它给了我一个错误,这里是编码:
set buyannounce to "AUTOMATIC SERVER EMAIL : BUY"
set transferannounce to "AUTOMATIC SERVER EMAIL : TRANSFER"
set signupannounce to "AUTOMATIC SERVER EMAIL : SIGNUP"
set sellannounce to "AUTOMATIC SERVER EMAIL : SELL"
set nowsignup to "0"
set announce to "AUTOMATIC SERVER EMAIL"
set ¬
currentSignups ¬
to the text returned ¬
of (display dialog ¬
¬
"How many current signups?" default answer "")
tell application "Mail"
set unreadMessages to (get every message of mailbox "INBOX" of account "Yahoo" whose read status is true)
repeat with eachMessage in unreadMessages
if announce is in (get content of eachMessage) then
if buyannounce is in (get content of eachMessage) then
--buy email
end if
if transferannounce is in (get content of eachMessage) then
--transfer email
end if
if signupannounce is in (get content of eachMessage) then
set nowsignup to nowsignup + 1
set eachMessageTrimmed to ((characters 33 thru -1 of (get content of eachMessage)) as string)
display dialog nowsignup
set filepath to POSIX path of "/Users/obleopold/Dropbox/Accounts.csv"
try
set command to "open " & quoted form of filepath
do shell script command
end try
delay 10
repeat currentSignups times
tell "System Events" to keystroke return
end repeat
repeat nowsignup times
tell "System Events"
keystroke eachMessageTrimmed --here is where I am getting the error
end tell
tell "System Events" to keystroke return
currentSignups = currentSignups + nowsignup
set nowsignup to "0"
end repeat
end if
if sellannounce is in (get content of eachMessage) then
--sell email
end if
end if
end repeat
end tell
end
end
end
end
最佳答案
我没有检查您的代码是否正常工作,但这是编写代码以避免问题的一种方法。您可以使用子程序。当你从一个“tell”代码块中调用一个子程序时,你需要在它前面加上“my”这个词。这告诉脚本子例程属于脚本而不是您正在告诉的应用程序。
请注意,您可以通过获取消息内容一次来优化您的代码。每次您“获取每个消息的内容”时,都会对性能产生影响......所以只做一次。另请注意,我在您的击键命令之间添加了一些延迟。通常你需要这些小的延迟来防止在你做这样的事情时出错。它使您的计算机有一点额外的时间来执行击键。
祝你好运。
set buyannounce to "AUTOMATIC SERVER EMAIL : BUY"
set transferannounce to "AUTOMATIC SERVER EMAIL : TRANSFER"
set signupannounce to "AUTOMATIC SERVER EMAIL : SIGNUP"
set sellannounce to "AUTOMATIC SERVER EMAIL : SELL"
set nowsignup to "0"
set announce to "AUTOMATIC SERVER EMAIL"
set currentSignups to the text returned of (display dialog "How many current signups?" default answer "")
tell application "Mail"
set unreadMessages to (get every message of mailbox "INBOX" of account "Yahoo" whose read status is true)
repeat with eachMessage in unreadMessages
set messageContent to content of eachMessage
if announce is in messageContent then
if buyannounce is in messageContent then
--buy email
end if
if transferannounce is in messageContent then
--transfer email
end if
if signupannounce is in messageContent then
set nowsignup to nowsignup + 1
set eachMessageTrimmed to my trimMessageText(messageContent)
display dialog nowsignup
my openFilePath(POSIX path of "/Users/obleopold/Dropbox/Accounts.csv")
delay 10
repeat currentSignups times
my keystrokeSomething(return)
delay 0.2
end repeat
repeat nowsignup times
my keystrokeSomething(eachMessageTrimmed)
delay 0.2
my keystrokeSomething(return)
delay 0.2
currentSignups = currentSignups + nowsignup
set nowsignup to "0"
end repeat
end if
if sellannounce is in messageContent then
--sell email
end if
end if
end repeat
end tell
(************* SUBROUTINES *****************)
on trimMessageText(messageText)
try
return text 33 thru -1 of messageText
on error
return messageText
end try
end trimMessageText
on keystrokeSomething(something)
tell application "System Events"
keystroke something
end tell
end keystrokeSomething
on openFilePath(filepath)
try
do shell script "open " & quoted form of filepath
end try
end openFilePath
tell application "Mail"
-- do something
end tell
set eachMessageTrimmed to text 33 thru -1 of messageText
tell application "System Events"
-- do something
end tell
do shell script "something"
tell application "Mail"
-- do something
end tell
关于error-handling - 邮件的 Applescript 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18420572/
还有人在用applescript吗,苹果把文档存档了,好久没更新语言了。这是否意味着语言已死? 最佳答案 自从苹果在 2016 年解散 Mac 自动化团队并(迟迟)解雇了负责它的产品经理以来,整个 A
我无法弄清楚如何检测 AppleScript 中按下的键以及如何延迟直到该键被释放。我想切换缩放,我拥有其他一切(我认为)。这是我当前的代码 on idle set ztoggle to 0
是否可以为使用 AppleScript 创建的应用程序保存某种设置? 设置应在脚本开始时加载,并在脚本结束时保存。 例子: if loadSetting("timesRun") then se
我正在尝试显示我选择的文件的扩展名。我做错了什么? set theFile to (choose file with prompt "Select a file to transfer:")
我正在尝试制作一个将在后台运行并且每周只在特定时间执行一次的 applescript,有什么建议吗? 最佳答案 您可能想要的是 idle handler .首次打开 AppleScript 应用程序时
我希望能够引用与 Controller 位于同一目录中的模型文件。 最初,它们位于项目的根文件夹中,但当它们被编译(使用 osacompile)时,它们都将位于 Controller.scptd/Co
我不知道如何使用 AppleScript,一开始我是如何让我的小 bash 脚本工作的,这超出了我的能力。我目前正在使用 AppleScript 来运行我的 bash 脚本,它工作得非常好。它在下面。
我有一系列 AppleScript 命令需要在一行 AppleScript 中实现。代码如下。 delay 2 tell application "System Events" to keystrok
在 VBA 中,用不同的子字符串替换子字符串非常容易,例如 objMsg.Body = Replace(objMsg.Body, ""在电子邮件正文中使用当前月份。我以前见过与此类似的问题,但它们已经
就目前情况而言,这个问题不太适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、民意调查或扩展讨论。如果您觉得这个问题可以改进并可能重新开放,visit
我已被任命创建一个必须 当网页加载完后,显示一个对话框,显示"The webpage has finished loading." 确定当前正在下载的项目数量 对于数字1,我尝试做if the U
我有一个用于创建作业文件夹的 Applescript。 Applescript 要求提供项目名称和文件夹的存储位置。输入作业名称和文件夹位置后,脚本会创建主文件夹和四个子文件夹。 现在我希望脚本在当前
我有一个字符串,其中包含要删除的非法字符,但我不知道可能存在哪种字符。 我建立了一个我不希望被过滤的字符列表,并建立了这个脚本(来自我在网络上找到的另一个脚本)。 on clean_string(Th
我很困惑 - 我已经用谷歌搜索了一个小时,并尝试了大约十种不同形式的 set posixDirectory to POSIX path of (parent of (path to aFile) as
我在 Automator 中有一个小的 applescript: do shell script "osascript ~/Focus-On.scpt" delay 60 do shell scrip
我想打开一个默认为应用程序设置文件夹的文件夹: /Users/XXX/Library/Application Support/Tunnelblick/Configurations 我不想“硬编码”“X
我试图找出最前面的应用程序 x 是什么,运行脚本,然后使用 applescript 将 x 设置为最前面的应用程序。 tell application "System Events" set
有一个 AppleScript 方法: on displayError(theErrorMessage) display dialog theErrorMessage return "
我正在尝试编写一个脚本来记录当前应用程序、切换到另一个应用程序、执行一些任务并返回到原始应用程序。这就是我所拥有的 set currentApp to my getCurrentApp() activ
我正在尝试根据其文本使用 AppleScript 选择大纲的特定行。 这是我正在考虑的(但不起作用): repeat with aRow in rows of outline 1 of scroll
我是一名优秀的程序员,十分优秀!