NSSharingService on mountain lion without sharing window

On mountain lion, I try the new sharing possiblities with the NSSharingService class of AppKit.framework

Everything goes fine with this three lines of code


NSArray* array = @[ @"myText", [NSImage imageNamed:@"myImageFile"] ];
NSSharingService* sharingServiceFB = [NSSharingService sharingServiceNamed:NSSharingServiceNamePostOnFacebook];
[sharingServiceFB performWithItems:array];


But, when I run this code awindow appears asking me if I want to "Publish" or "Cancel"

User uploaded file

I'd like to do the same sharing without this window generated by the performWithItems function.

As I'm considering that the user of my application don't want to confirm.

I've looked in the NSSharingService reference and I don't see any functions that can help me.

I figure that I need send a "Publish" command to this window. I'm new to objective c and I don't really know how to figure it out (or even if it's the best solution).

Any help would be appreciated.

MacBook Pro (15-inch Early 2011), OS X Mountain Lion (10.8.2)

Posted on Dec 29, 2012 3:38 AM

Reply
3 replies

Dec 30, 2012 2:26 PM in response to etresoft

Thanks etresoft.

Learning the facebook API and building an app is one way.

I'm trying to find the quickiest way, at first.😉


The only way I managed that is using a virtuall mouse with this kind of command from an other program


CGPoint pt;

pt.x = 1000;

pt.y = 400;

CGEventRef moveMouse = CGEventCreateMouseEvent (NULL,kCGEventMouseMoved,pt,NULL);

CGEventPost (kCGHIDEventTap, moveMouse);


CGEventRef cam move, click, drag, ...like an real mouse.

So, I'm using it to click on the publish button.


It's not a great solution but it works.


I wonder if it's possible in macOS developpement to have a pointer on a window (the front window of an application for example) and sends command to it (like enter-which means public in my case- or cancel).

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

NSSharingService on mountain lion without sharing window

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.