Scriptingbridge Finder Posix Path
-
28-09-2019 - |
سؤال
هل من الممكن الحصول على مسار POSIX أو الهدف إلى النافذة الأمامية باستخدام إطار جسر البرمجة النصية؟
أنا استخدم
FinderApplication *theFinder = [SBApplication aplicationWithBundleIdentifier:@"com.apple.Finder";
لكن لا يمكنني العثور على أي شيء في "Finder.h" يمكن أن ينجح.
المحلول
قد يكون هذا ما أنت عليه بعد استخدام Scriptingbridge و Nsurl
FinderApplication *finder = [SBApplication applicationWithBundleIdentifier:@"com.apple.finder"];
SBElementArray *windows = [finder windows ]; // array of finder windows
NSArray *targetArray = [windows arrayByApplyingSelector:@selector(target)];// array of targets of the windows
//gets the first object from the targetArray,gets its URL, and converts it to a posix path
NSString * newURLString = [[NSURL URLWithString: (id) [[targetArray objectAtIndex:0]URL]] path];
NSLog(@"newURLString %@ ", newURLString);
نصائح أخرى
تشغيل رمز Drawnonward من خلال appscript أداة Astranslate تعطيني هذا:
#import "FNGlue/FNGlue.h"
FNApplication *finder = [FNApplication applicationWithName: @"Finder"];
FNReference *ref = [[[finder windows] at: 1] target];
FNGetCommand *cmd = [[ref get] requestedType: [ASConstant alias]];
id result = [cmd send];
ستكون النتيجة مثالاً للاسالاس ؛ استخدم -[مسار Asalias] للحصول على مسار Posix.
لا يمكنك القيام بذلك في SB أقل من اللجوء إلى رموز أحداث Apple Raw لأن هذه واحدة من الميزات التي نسيها/مهندسي Apple/لم تهتم بوضعها في SB أقل من واجهة برمجة التطبيقات النجمية.
لم أستخدم Scriptingbridge. كجزء من nsapplescript ، سيكون:
get POSIX path of (target of window 1 as alias)
نأمل أن يساعد ذلك. أعتقد أن جزء POSIX هو من STINDAYDDITIONS Scriptingaddition ، وليس الباحث نفسه.
لا تنتمي إلى StackOverflow