1
我想以編程方式強制Finder在Mountain Lion中刷新。在以前版本的OSX的,後續片斷工作:osx 10.8刷新發現者
OSStatus SendFinderSyncEvent(const FSRef* inObjectRef)
{
AppleEvent theEvent = { typeNull, NULL };
AppleEvent replyEvent = { typeNull, NULL };
AliasHandle itemAlias = NULL;
const OSType kFinderSig = 'MACS';
OSStatus err = FSNewAliasMinimal(inObjectRef, &itemAlias);
if (err == noErr)
{
err = AEBuildAppleEvent(kAEFinderSuite, kAESync, typeApplSignature,
&kFinderSig, sizeof(OSType), kAutoGenerateReturnID,
kAnyTransactionID, &theEvent, NULL, "'----':alis(@@)", itemAlias);
if (err == noErr)
{
err = AESendMessage(&theEvent, &replyEvent, kAENoReply,
kAEDefaultTimeout);
AEDisposeDesc(&replyEvent);
AEDisposeDesc(&theEvent);
}
DisposeHandle((Handle)itemAlias);
}
return err;
}
有誰知道的替代方法做到這一點的山獅?謝謝
[Finder update/refresh applescript不能在10.8中工作]的可能的重複(http://stackoverflow.com/questions/11781373/finder-update-refresh-applescript-not-working-in-10-8) – 2013-03-21 06:55:46