有没有什么方法可以检查finder是否在忙,比如复制文件?我不想在文件级别检查它;我只想知道一般情况下finder是否正在忙于复制。
我认为这是不可能的,但在这里总是值得一试的:)
发布于 2011-10-28 06:51:13
不幸的是,Apple没有提供任何方法来检索这类信息。
然而,有一些“脏”的方法可能会起作用,例如使用AppleScript。
以下脚本检测Finder的“复制窗口”是否处于活动状态:
(编写速度很快,没有经过彻底的测试,但似乎工作得很好。)
set thestatus to "not copying"
tell application "System Events"
set theList to get the title of every window of process "Finder"
repeat with theItem in theList
if theItem contains "Copy" then
set thestatus to "copying"
end if
end repeat
end tell
thestatus最后,使用NSAppleScript从Objective-C运行此AppleScript
NSString *theScript = @"set theStatus to \"not copying\"\n"
"tell application \"System Events\"\n"
"set theList to get the title of every window of process \"Finder\"\n"
"repeat with theItem in theList\n"
"if theItem contains \"Copy\" then\n"
"set theStatus to \"copying\"\n"
"end if\n"
"end repeat\n"
"end tell\n"
"theStatus";
NSDictionary *errorInfo = nil;
NSAppleScript *run = [[NSAppleScript alloc] initWithSource:theScript];
NSAppleEventDescriptor *theDescriptor = [run executeAndReturnError:&errorInfo];
if ([[theDescriptor stringValue] isEqualTo:@"copying"]) {
NSLog(@"Finder is copying");
} else {
NSLog(@"Finder is not copying");
}https://stackoverflow.com/questions/7921378
复制相似问题