Sending an apple event from C (not iPhone)

I'm trying to send an "open documents" event. It's giving me a -50 error (incorrect parameter) so I think it's in the aeDirDesc that gets added as the parameter, but I can't seem to find enough documentation to see what's wrong. Here's my code which is altered from a (working) chunk of code which tells finder to open an app.
Sorry about the large code fragment...
<pre>
OSErr errT;
OSType desc;
AEDesc progAddr, aeDirDesc;
char preview[PATHLEN];
uchar previewU[PATHLEN];
uchar doc[PATHLEN];
AppleEvent someAE;
FSSpec fspT, fspP;
AliasHandle DirAlias = NULL;
AEDesc fileList;
strcpy(preview,"file://Applications/Safari.app");
pstrcpy(previewU, "\pMacintosh HD:Applications:Safari.app");
pstrcpy(doc, "\pMacintosh HD:tmp:dockeepimages:Page-001");
errT = FSMakeFSSpec(0,0,doc, &fspT);
errT = FSMakeFSSpec(0,0,previewU, &fspP);
SendOpenToFinder(&fspP);
errT = NewAlias(nil, &fspT, &DirAlias);
HLock((Handle)DirAlias);
errT = AECreateDesc(typeAlias, (Ptr)*DirAlias,
GetHandleSize((Handle)DirAlias), &aeDirDesc);
HUnlock((Handle)DirAlias);
errT = AECreateDesc(typeApplicationURL, preview, strlen(preview) +1,
&progAddr);
if(errT == noErr)
errT = AECreateAppleEvent(kCoreEventClass, kAEOpenDocuments, &progAddr,
kAutoGenerateReturnID, kAnyTransactionID,
&someAE);
AEDisposeDesc(&progAddr);
if(errT == noErr)
errT = AEPutParamDesc(&someAE, keyDirectObject, &aeDirDesc);
AEDisposeDesc(&aeDirDesc);
if(errT == noErr)
if ((errT = AECreateList(nil, 0, false, &fileList)) == noErr) {
errT = AEPutDesc(&fileList, 0, &aeDirDesc);
AEDisposeDesc(&fileList);
if(errT == noErr)
errT= AESend(&someAE, 0, kAENoReplykAEAlwaysInteractkAECanSwitchLayer,
kAENormalPriority, kAEDefaultTimeout, 0, 0);
</pre>
There's no error until the AESend which gives a -50...

etresoft wrote:
I wouldn't mind use AppleEvents (not the same as Applescript!) via the Script bridge or something. However, I thoroughly detest Applescript.
The AppleScript language has one major defect: in order to provide high-level readability, it sacrifices low-level semantics. i.e. Even a complete non-programmer can look at an existing AppleScript script and get a general idea of what it does, but actually figuring out the precise mechanics of how it works requires a load of effort by newbies and expert programmers alike. "English-like" syntax is all well and good, but without all those ugly brackets and braces, it can be a real PITA figuring out what's a variable name, what's a property name, what's a command, and so on. You can't tell from syntax alone as all the different structures look exactly the same - it's hopelessly ambiguous. Allowing whitespace in application-defined keywords also makes it tricky to tell where each keyword begins and ends. e.g. Is 'foo bar' a property name, or a constant name, or a command name, or a command name followed by a property name, something else? (One tip for you: in Script Editor's preferences, set the 'application keyword' style to use underlines.)
(AppleScript also has a whole bunch of lesser defects, of course... but hey, find me a language that doesn't. Come to think of it, even Apple events themselves are a bit wonky; and don't get me started on the mess that is the Apple Event Object Model or the Cocoa Scripting framework.)
OTOH, I will say two things in the AppleScript language's defense:
1. AppleScript frequently gets blamed for the bugs, inconsistencies, appallingly inadequate documentation and other defects of individual applications' scripting interfaces. This is not AppleScript's fault, however; it's the developers who wrote those applications who are to blame - and their failings affect all Apple event-capable languages, not just AppleScript.
2. It still has the best Apple event support of any language. Scripting Bridge, which you mention, doesn't work properly (various bugs, lacks various bits of functionality, and is prone to application incompatibilities), and [ironically] obfuscates and confuses the process of building and sending Apple events much worse than AppleScript does. Even appscript, which [AFAIK] provides the next best Apple event bridge after AppleScript, still chokes on the occasional application command that works without problem in AppleScript. (Of course, some of those compatibility problems are due to applications relying on behaviours that in turn rely on AppleScript's own undocumented quirks; but hey, you work with the APIs you've got, not the ones you wish you had.)
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net

Similar Messages

  • HT5557 since i updated my Apple ID with correct email address I can now only send imessages to email addresses and not iphone numbers - any idea how to fix this problem ?

    since i updated my Apple ID with correct email address I can now only send imessages to email addresses and not iphone numbers - any idea how to fix this problem ?

    You might want to try contacting Apple for assistance by going to https://expresslane.apple.com, then click See All Products and Services>iTunes>iTunes Store>Passwords & Security Questions>Lost or Forgotten Apple ID password.  They should be able to explain what's going on and help you reset the password for the old ID if necessary.  The call should be free.

  • How to send a message(apple event) from mac os to our application

    on developer.apple.com i found a method which opens a given documetns through an apple event.
    my question is how to send open document event from mac to our application on xcode

    Assuming you're using Cocoa, the simplest solution is to call -[NSWorkspace openFile:withApplication:]. Example:
    NSWorkspace *ws = [NSWorkspace sharedWorkspace];
    NSString *appPath = [ws absolutePathForAppBundleWithIdentifier: @"com.apple.textedit"];
    [ws openFile: @"/path/to/file" withApplication: appPath];

  • Until yesterday I could text to non-Apple friends from both my iPhone

    Until yesterday I could text to non-Apple friends from both my iPhone 5S (iOS 8.1.2) and my iPad Air 2 (iOS 8.1.2). Then for several hours last nothing was deliverable unless to another iPhone or iPad. Today, once again, I can text to non-Apple friends from my iPhone but not my iPad. On the iPhone there are buttons for MMS & SMS messaging, but not on the iPad. What happened?
    Thank you,
    bobbi

    I was having this problem today with my 6 plus and my air 2.  Additionally, I kept getting the message that iMessage needed to be turned on to send my messages.  It was turned on in both devices.  I wonder if there was a problem at Apple.  My carrier is t-mobile, perhaps there could be a problem there.

  • How to export events from iPhoto in Iphone 5 to Mac?

    How to export events from iPhoto in Iphone 5 to Mac? Thanks

    Is this waht you want to do?
    It's built into the File Export function of iPhoto 9 (11).  Select what every photos you want and use that option to put each photo in a folder with the Event title it came from as in this test of six randomly picked photos:
    OT

  • Is there any app that support to send or recieve files from another non-iphone?

    is there any app that support to send or recieve files from another non-iphone?

    if an app was made for both the iphone and the other phone then yes
    one can always use dropbox and google drive and the likes

  • How do i get my apple ID from my old iphone 5 to my new iphone 6 ? what are the steps? because last time i tried getting my apple ID from my old to new phone it all went wrong and i could not sign in or use imessage? thanks

    How do i get my apple ID to work from my old iphone 5 to my new iphone 6? what are the steps? as last time i tried this everything went wrong my imessage would not work and it would not let me sign in?

    Try TransPhone, it's working fine, but a bit expensive...
    After installing this, you'll Be able to send/recieve music, contacts, text messages, photos and Videos over bluetooth. Works fine with all mobile phones and computers...
    I may receive some form of compensation, financial or otherwise, from my recommendation or link
    <Edited by Host>

  • How can I remove Apple ID from my old Iphone? I want to sell it.

    I want to sell my Iphone, how do I need to remove my Apple Id from there. The one why buys needs to create a new Apple ID. Can I use my old Apple ID when I have a new Iphone? Thanks!

    AnastasiyaZ wrote:
    I want to sell my Iphone,...
    What to do before selling or giving away your iPhone, iPad, or iPod touch
    AnastasiyaZ wrote:
    ... Can I use my old Apple ID when I have a new Iphone?
    Yes and you should.
    NOTE: Anything Downloaded with a Particular Apple ID is tied to that Apple ID and Cannot be Merged or Transferred to a Different Apple ID
    Apple ID FAQs  >  http://support.apple.com/kb/HT5622
    Apple ID Support  >  http://www.apple.com/support/appleid/

  • Send a keyboard event from labview to C#

    Hi,
    We currently have a program in c# that takes keyboard inputs from a user and will fly a quadrotor. We aim to have a LabView .vi generate keyboard commands based on our experiment and send the commands to the c# code creating a feedback loop where the .vi will keep track of sensor and experimental data.
    Our problem is that we have tried many different methods to send the keyboard commands in LabView. 
    1) http://zone.ni.com/devzone/cda/epd/p/id/3711
    2) http://forums.ni.com/t5/LabVIEW/Send-keyboard-commands-to-another-windows-program/td-p/330670/page/2
    as well as other variations and similar .vi's that do the same thing. Here is an example of a .vi used to press the letter "t" once.
    http://i.imgur.com/hwmjZ.png
    All of them can write the string to a text (open notepad put cursor in blank window) file but none can do it in such a way that it is detected by the c# code. On my own I can open and run the c# code and press keyboard buttons myself and the commands are recognized, so I think it could be an issue with how LabView sends the keyboard events and how c# reads them. Here is the c# code segment that we are using to read the input commands:
    public override List<String> GetPressedButtons()
              KeyboardState state = device.GetCurrentKeyboardState();
              List<String> buttonsPressed = new List<String>();
              foreach (Key key in Enum.GetValues(typeof(Key)))
                        if (state[key])
                                  if (!buttonsPressed.Contains(key.ToString()))
                                            buttonsPressed.Add(key.ToString());
              return buttonsPressed;
    Can anyone help trying to figure out why using the keybd_event function in LabView can not interface correctly with the above detection code in c#? I can provide any code and clarification if you think it can be helpful.
    Thanks,
    Andy

    Hi,
    I can't say with certainty where the problem is or even how many there are. I do know that the KeyboardListener.cs class should work according to what I have read online. I also know that if I press the keyboard myself then the state is changed and the correct action is taken. If I try to issue an event from Labview then the event is not captured. Here is the code, it is rather large ~20 MB.
    https://www.dropbox.com/s/vsvcje1ro364otu/ARDrone.zip
    https://www.dropbox.com/s/p3h3tj8bcqc29gk/Forward_backward0924.vi
    The key listener is in ARDroneInput>Utils>KeyboardListener.cs and the polling takes place in ARDroneInput>KeyboardInput.cs
    The reason I wanted to use keyboard inputs is because the quadrotor we are using takes keyboard commands W,A,S,D,T and L. Initially I thought having Labview issue these commands would be the simplest method. That may not be the case.
    I was just thinking that it is not necessary that key events are sent from Labview. Instead, one could send an array representing the frequency of each button press rather than the button press directly. In that case an array that is updated continuously from Labview will just have to be kept track of in the C# code. The C# can then convert that to whatever control input we want. Can it be easier to send a vector of numbers in real time to C#?
    If you think it is better to establish a connection between Labview and C# using .NET to send keyboard commands (rather than the vector idea above) can you explain that a little more? How does one go about doing that? If you think the vector idea is simpler how should the interface be set-up?
    I just talked with my collegue and we think that maintaing a .txt file in Labview and having C# read it is the best option. We will begin working on that and will update you tomorrow.
    Thanks,
    Andy 

  • How do I send the iPhoto events from my iMac to my iPad when the two devices are connected by USB port?

    I connected my iPad to my iMac via USB port.  I want to send my iPhoto events/files to my iPad.  I cannot find the right instructions.  It appears to me that the iPad sync only transmits data from the iPad to the iMac, but I am trying to send iPhotos from the iMac to the iPad.  Do I use export or sync?

    You need to use iTunes to sync photos.
    Connect your iPad to your computer. Launch iTunes. Select Photos from the menu. Click the Sync button bottom right side of the iTunes window.
    Syncing iPad, iPhone, or iPod touch with iTunes
    iPad User Guide

  • HT1918 I am unable to sign in to my apple account from my ipad & iphone

    When I try to sign in to my Apple account from either my iPad or my iPhone, I enter my password and it just blanks it out.
    I can sign in to my account from my MacBook Pro, though.
    When I try to add a device to my list of authorized devices to download music or software, I can't.
    My devices used to be authorized, and now they aren't. 
    I never changed them, so how did they get deauthorized? 
    How do I authorize them as devices that can download music and apps?

    You will have to contact Apple Care and ask for account security for help. Apple ID: Contacting Apple for help with Apple ID account security

  • The Air Drop Icon is not available.  Cannot send or receive messages from anyone not using Messenger.

    I have checked to see that my iPad is using the latest software available and it is.  I have followed on-line directions to access Air Drop, but I do not have the Icon for it anywhere.
    I am not able to send or receive messages to anyone not using Messenger.  Thee Apple page says I should be able to.
    Any help appreciated.

    Yes, it is 2 questions. 
    My iPad is Model MC763LL/A - I hope that is the answer!  I do have Blue Tooth on.  I am not connected to WiFi, but am on Cellular Data here.  That should not have a bearing on the icon being loaded, should it?

  • Send to Apple TV From Final Cut Server

    This was pretty simple, but clients really seem to appreciate having the functionality. Basically all you have to do is follow these steps to create a checkbox that can send any asset to your Apple TV for client viewing.
    1. Create the field "Send to Apple TV".
    2. Add that field to your Asset Search MD group and the MD goup that you wish people to access it in.
    3. Create a Final Cut Server Playlist in iTunes
    4. Open Automator in OSX. Create a Folder Action using the "Add Songs to Playlist" action from iTunes.
    - Choose your Final Cut Server Playlist
    5. Assign the folder action to a folder of your choice.
    6. Create a Device "Apple TV" in Final Cut Server that points to that folder.
    7. Create a transcode setting for "Apple TV H.264" and import to Final Cut Server
    - Assign this transcode setting to your Apple TV Device
    8. Create a "Send to Apple TV" Copy Response
    - The destination device is "Apple TV"
    - Transcode Setting is "Apple TV H.264"
    9. Open Itunes on the Final Cut Server
    - Setup your Apple TV
    - Have the Apple TV automatically get the latest files from your Final Cut Server Playlist and send them to your Apple TV.
    Done!
    - Jason
    Jason Perr
    Systems Integration Consultant
    Sr. Systems Engineer / Partner
    MacHarmony
    www.macharmony.com
    213-268-1248 (cell)
    [email protected]

    Good job Jason. About time to you contributing back to the community that's been so good to you.
    Now how do you get the Apple TV box to automatically query FCSvr directly?
    Nicholas Stokes
    XPlatform Consulting

  • How do i remove my old apple id from an old iphone...i cannot access via email nor security questions, pw does not work.

    I got rid of my old iphone and opened new apple id and pw on this new ip4s. I cannot access the old apple ID via usual
    access ie., security questions, password or email verification. The email never arrives and when I answer the security it states incorrect answer.
    I just want to delete that old apple id account for security reasons, hackers, thieves, potential unknown risks.
    Please advise.
    Thanks.
    C.

    The Apple ID exists. The email address you used to create it may not, but the Apple ID does. Call AppleCare and ask to speak to someone in account security.

  • How do i get calendar syncing recurring events from outlook to iphone to handle daylight saving time

    When I sync recurring events of my PC Outlook on to the iPhone calendar they appear one hour later during summer i.e. between Mar 26th and October 27. I have a weekly thing every wednesday at 8pm that appears at 9pm in summer - so outlook seems to be sending the info in UTC time but the IPhone isn't compensating for summer time.

    What do you mean "correctly". If I enter a recurring (weekly) event in Outlook at say 8pm every Monday from February till December, then Outlook calendar propagates it at 8pm every Monday from February till December, and I can see it on each Monday regardless of whether it's standard time or summer time. However when I sync with the iPhone calendar through iTunes it transmits just the start date/time and end date, and the iPhone then recreates the series of events (provable because it creates occurences that I have deleted on Outlook). However it propagates the UTC time at the start date, and gets confused by the change to Summer Time in March (and Ocotber). The iphone "corrects" the (UTC) time for Summer Time so it starts at 8pm, all summer the event appears at 7pm, and goes back to 8 in November. I have tested across both boundaries - if a recurrence starts in summer time at 8pm then from November it gets an hour later, 9pm. And you can't solve it by turning off Local Time handling on the iPhone because then all individual events through the summer are an hour out. This is a bug.
    Workaround - enter separate recurrent events for each time period, so in a calendar year 3 events: Jan-end March, April-end October, Nov-Dec

Maybe you are looking for

  • How do you get FaceTime to work on my MacBook Air?

    I got my MacBook Air yesterday, I set up an Apple I.D, and I logged into FaceTime. It kept saying that it was was still "Sigining in..." so I pressed cancel and made a new I.D. It STILL doesn't work! My mom even used her Apple I.D that she uses for h

  • Help!!  "This does not appear to be a valid Podcast URL" -- but it is!

    I'm having trouble subscribing to the Vatican Radio podcast (English version). I recently moved to a new computer and resubscribed to all my podcasts. This is the only one that won't work for me. I've contacted the Radio Vatican webmaster and he's co

  • Process Flow Exit Parameters, Possible?

    I want to send through variables from One process to Another within a Process Flow Package, is this possible. I'm not able to add EXIT parameters to the END Object through which I can hand over values to the next process, how is this done?

  • Regarding AUTOCAD interface

    Hello Frds, I'm working for a real estate project where i have excel sheet data of AUTOCAD and i need to convert that in to SAP/ABAP with an interface. How i can do it. PLZ help me with the tips THANKS in advance.

  • Max length name of Attribute/Entity

    Hello! I want create name of Attribute more than 50 characters, but MDS 2014 does not do it. Is it possible?