我有一个带有故障数字化板的modbook。直到我能重新屏蔽引起故障的电缆,我只想关掉数字化器。我找到了一个页面,它教会了我一些代码,昨晚我成功地使用了它。但是,在重新启动时,它不再工作了:
脚本
tell application "System Events"
set PTD to (unix id of process "PenTabletDriver") as text
do shell script "kill -STOP " & quoted form of (PTD)
end tell错误消息
错误“无法将prcs类的类idux \"PenTabletDriver\”的应用程序\“系统事件”转换为文本类型。“从prcs类的类idux到文本的编号-1700
我能以某种方式修改代码来解决这个问题吗?
PS:我读过https://stackoverflow.com/questions/5865104/applescript-error-cannot-make-to-unicode-text,虽然它类似,但我不明白如何将它应用于我的问题。
发布于 2013-11-20 20:00:47
生命太短暂,不能与AppleScript混为一谈。尝试在终端提示符下运行以下命令:
pkill -STOP PenTabletDriver此外,请检查您的登录项,以查看每次登录时是否自动启动驱动程序。(但更有可能的是,它被配置为通过launchd在启动时启动。)
发布于 2013-11-20 20:25:40
您可以将以下脚本保存在小applet中:
set shellStr to "pkill -STOP PenTabletDriver"
do shell script shellStr在你需要的时候运行。
发布于 2014-07-04 10:32:09
我认为其他答案很好,shell命令是好的和快速的。但是,如果你一定要上AppleScript,这似乎对我有用.
tell application "System Events"
set PTD to (unix id of process "iTunes")
do shell script "kill -STOP " & quoted form of (PTD as text)
end tell这会导致
tell application "System Events"
get unix id of process "iTunes"
--> 37987
do shell script "kill -STOP '37987'"
--> error number -10004
end tell
tell current application
do shell script "kill -STOP '37987'"
--> ""
end tell进程ID只是一个数字,所以没有必要引用它.
tell application "System Events"
set PTD to (unix id of process "iTunes")
do shell script "kill -STOP " & PTD
end tell以上代码就足够了。
https://stackoverflow.com/questions/20105541
复制相似问题