Extending the UI of an existing application.

I would appreciate if the response was in JXA, but Applescript would at least give me an idea of what calls I need to make.

I have already seen some examples of creating buttons with windows:

So I would assume my code would be something like this:


//If no superclass is provided, NSObject is subclassed.
				//My button implementation

var window=Application('Some Application').window[0]

var appDelegate=$.AppDelegate.alloc.init;

var btn=$.NSButton.alloc.initWithFrame($.NSMakeRect(25,(height-100),200,25));
btn.title="Run JXA";
//NOTE:See NSButton docs for info on target/action
btn.keyEquivalent="\r"; //Enterkey


However I have very little experience with Applescript or Objective C, so am wondering whether I am on the right track (or even if what I’m trying to do is possible!)


I’m rusty on JXA, and I’m not sure where you’re getting your window from. But unless you own the window, it’s not going to work. I doubt that you need the AppDelegate stuff – the main thing is to make the script the target of the button.

Gosh darn it! I was hoping you could get the window from the processes class:


If I need to own the window… I guess the only option would be to have an invisible window made in AS with visible UI elements which tracks the size of the window (and controls) of the other application?

Hmm… I also remember that F-Script, after being injected into applications, created it’s own menu item, so perhaps you can inject menu items into other applications with ASObjC/JXA?

That’s fine, If I can get my hands on some AS code I can hopefully port it :slight_smile:

I hope not. It would be a massive security hole.

I’m not entirely sure why it would be a security issue? As far as I am aware, software developers shouldn’t have to concern themselves with security… An applescript by itself is a security risk after all…

Surely it would be nothing but a good thing for scripters? One of the most important things, in my mind, when developing scripts is to make them easy for users to use… Adding menu items for instance is a great way to achieve this - equivalently adding window elements.

It’s one of the reasons why I love HTML/JS. Because it’s easy to take someones website and just add features to it… (With JS script injection I mean)


Extending the UI of finder can be seen here:

F-Script Anywhere:

F-Script framework: