Re: Inserting a button into another application's toolbar
Thank you for the suggestions! 2017-09-19 10:36 GMT+03:00 Alastair Houghton: > > On 19 Sep 2017, at 06:01, Jack Brindle wrote: > > > > Actually, there may be a way. It all depends on exactly where in the > menu bar you want to place the menu item. > > I think the OP wanted to inject a *toolbar* item into another app’s > window’s toolbar, not a menu bar item/status item. > > FWIW, a status bar item might be an appropriate alternative, depending on > what the app does and how it works. Other alternatives worth considering > are the Scripts menu (this is AppleScript, so if you go to Script Editor’s > Preferences window, you’ll see you can turn on the Script menu in the > status bar), and making your code run as a system service (so you can > choose it from App > Services). > > > On Sep 18, 2017, at 4:15 PM, Jens Alfke wrote: > > > >> Sorry, there's no reasonable way to do that if the app doesn't already > support plugins. There used to be some awful hacks that patched into the > app-launching mechanism and made it possible to inject code into other > apps, but that approach causes stability problems and is in general > terrible for security. > > There were also quite a number that abused the Input Manager mechanism as > if it was a general purpose way of plugging in to other applications. On > the one hand, some of these extensions were fine, worked nicely, and didn’t > cause problems. On the other, *some* of them did cause trouble on a fairly > routine basis. > > Certainly I’d caution against writing anything other than a > personal-use-only project or some kind of debug tool that does things like > that; at the very least, your users are going to find that many developers > take one look at their crash logs and reply that you’ve got some kind of > system hack installed and that if you can reproduce it without that, > they’ll look at it. That’s a little unfair, of course - many times these > system hacks weren’t to blame at all - but after the handful of cases where > they *are* to blame hit your desk, sending you on a wild goose chase until > you finally realise that some kind of tampering has been going on, you’ll > probably end up as grumpy about them as Jens :-) > > Kind regards, > > Alastair. > > -- > http://alastairs-place.net > > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Inserting a button into another application's toolbar
> On 19 Sep 2017, at 06:01, Jack Brindlewrote: > > Actually, there may be a way. It all depends on exactly where in the menu bar > you want to place the menu item. I think the OP wanted to inject a *toolbar* item into another app’s window’s toolbar, not a menu bar item/status item. FWIW, a status bar item might be an appropriate alternative, depending on what the app does and how it works. Other alternatives worth considering are the Scripts menu (this is AppleScript, so if you go to Script Editor’s Preferences window, you’ll see you can turn on the Script menu in the status bar), and making your code run as a system service (so you can choose it from App > Services). > On Sep 18, 2017, at 4:15 PM, Jens Alfke wrote: > >> Sorry, there's no reasonable way to do that if the app doesn't already >> support plugins. There used to be some awful hacks that patched into the >> app-launching mechanism and made it possible to inject code into other apps, >> but that approach causes stability problems and is in general terrible for >> security. There were also quite a number that abused the Input Manager mechanism as if it was a general purpose way of plugging in to other applications. On the one hand, some of these extensions were fine, worked nicely, and didn’t cause problems. On the other, *some* of them did cause trouble on a fairly routine basis. Certainly I’d caution against writing anything other than a personal-use-only project or some kind of debug tool that does things like that; at the very least, your users are going to find that many developers take one look at their crash logs and reply that you’ve got some kind of system hack installed and that if you can reproduce it without that, they’ll look at it. That’s a little unfair, of course - many times these system hacks weren’t to blame at all - but after the handful of cases where they *are* to blame hit your desk, sending you on a wild goose chase until you finally realise that some kind of tampering has been going on, you’ll probably end up as grumpy about them as Jens :-) Kind regards, Alastair. -- http://alastairs-place.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Inserting a button into another application's toolbar
Actually, there may be a way. It all depends on exactly where in the menu bar you want to place the menu item. If you want to add it on the right side as a status item, then you need to check out NSStatusBar. This would allow you to add a separate application (more likely a user Agent which can be launched when the user logs in). You can place normal menu items in the NSStatusBar menu which refer to things in your app. It, of course, would communicate with the target app using Apple Events. I would add an extra touch to determine when the target app is active and have the status bar item (along with its UI) enabled then, disabling it when the target app is not active (either launched or frontmost). Note that running your app as a user agent also means there is no main menu or dock icon, which is probably a good thing. You will also want to treat the windows and controls carefully so that they can accept clicks but do not take over as the frontmost application, instead leaving the target app as the frontmost application. This may not be exactly what you want - like others I don’t know of any legitimate way to add an item to the left side of an apps menu bar, but it certainly is doable, and is even within the security guidelines, as long as using AppleEvents works with the target app. - Jack > On Sep 18, 2017, at 4:15 PM, Jens Alfkewrote: > > > >> On Sep 18, 2017, at 2:35 PM, Nick wrote: >> >> adding/injecting a toolbar icon >> with a custom handler code into the main window of the application. > > Sorry, there's no reasonable way to do that if the app doesn't already > support plugins. There used to be some awful hacks that patched into the > app-launching mechanism and made it possible to inject code into other apps, > but that approach causes stability problems and is in general terrible for > security. > > —Jens > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/cocoa-dev/jackbrindle%40me.com > > This email sent to jackbrin...@me.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Inserting a button into another application's toolbar
> On Sep 18, 2017, at 2:35 PM, Nickwrote: > > adding/injecting a toolbar icon > with a custom handler code into the main window of the application. Sorry, there's no reasonable way to do that if the app doesn't already support plugins. There used to be some awful hacks that patched into the app-launching mechanism and made it possible to inject code into other apps, but that approach causes stability problems and is in general terrible for security. —Jens ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Inserting a button into another application's toolbar
On Sep 18, 2017, at 14:35 , Nickwrote: > > adding/injecting a toolbar icon with a custom handler code into the main > window of the application Isn’t that a massive security violation? Assuming you could get an icon into the toolbar (NSToolbar), it would need an action method to handle a click on the icon. If you could inject an action method, a malicious actor could inject arbitrary code into any app. You might be able to get *near* your intended approach by using a service: developer.apple.com/documentation/appkit/core_app/services_functions ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Inserting a button into another application's toolbar
Hello I am developing an add-in for an application that does not officially support add-ins. Everything can be done using AppleScript, except for a method to activate this add-in, to make it work more or less seamlessly with the application, which is basically adding/injecting a toolbar icon with a custom handler code into the main window of the application. Could you please advice what approaches to look at on modern versions of macOS and what keywords to search with? Thank you! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com