jsh*_*erk 10 variables applescript types
我有两个问题......
这是一个非常简单的示例脚本,它会导致错误:
系统事件出错:无法将每个应用程序进程的第1项(其visible = true)转换为类型字符串.
tell application "System Events"
repeat with appProc in (every application process whose visible is true)
display dialog appProc
end repeat
end tell
Run Code Online (Sandbox Code Playgroud)
这将有助于将来的参考,所以我可以弄清楚我正在处理什么样的数据类型
我尝试添加:
appProc as string
Run Code Online (Sandbox Code Playgroud)
但后来又收到另一个错误:
不能将应用程序"System Events"的"class pcap""myapplication"变成类型字符串.
reg*_*633 14
要获取数据类型 ...使用类...
set a to "some text variable"
return class of a
Run Code Online (Sandbox Code Playgroud)
转换为字符串?...尝试"as text"或"as string".它主要起作用.但是在你的情况下,appProc有属性(如提到的Red_menace),你想要显示它的名字属性......
display dialog (name of appProc)
Run Code Online (Sandbox Code Playgroud)