这是我的原始脚本。它会返回Safari的当前网址如何使用[[NSAppleScript alloc] initWithSource来检查应用程序是否正在运行:
NSAppleScript *scriptURL= [[NSAppleScript alloc] initWithSource:@"tell application \"Safari\" to return URL of front document as string"];
如果我想在查询脚本返回URL之前检查Safari浏览器是否打开,该怎么办?
这是我在的AppleScript编辑器怎么办。所以这个脚本会检查是否Safari浏览器正在运行或不..这适用于AppleScript的编辑
tell application "Safari"
if it is running then
//return url code here
end if
end tell
我现在需要的是马上叫从使用我的可可应用程序脚本“[[NSAppleScript页头] initWithSource:”
我已经试过,但它不工作
NSAppleScript *scriptURL= [[NSAppleScript alloc] initWithSource:@"tell application \"Safari\" if it is running to return URL of front document as string"];
你有看'NSRunningApplication'?这将给你所需的信息,而不诉诸于AppleScript。 –