Pregunta

¿es posible obtener la ruta POSIX o de destino a la ventana del primer plano usando la estructura del puente de secuencias de comandos?

Estoy usando

FinderApplication *theFinder = [SBApplication aplicationWithBundleIdentifier:@"com.apple.Finder";

pero no puedo encontrar nada en "Finder.h" que podría funcionar.

¿Fue útil?

Solución

Esto podría ser lo que está después usando ScriptingBridge y 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);

Otros consejos

Ejecución de código de drawnonward través de appscript herramienta ASTranslate me da esto:

#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];

El resultado será una instancia ASAlias; uso -. [ASAlias ??ruta] para obtener la ruta POSIX

Usted no puede hacerlo en SB corta de recurrir a los códigos de eventos prima de Apple ya que es una de las características de los ingenieros de Apple se olvidó / no se molestó en poner en menos que estelar API .

No he utilizado ScriptingBridge. Como parte de un NSAppleScript sería:

get POSIX path of (target of window 1 as alias)

Con suerte que ayuda. Creo que la parte POSIX es del StandardAdditions ScriptingAddition, no el propio Finder.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top