tags:

views:

39

answers:

2

Hi :-)

I have a simple problem, I will be straighforward.

Suppose I have a third-party cocoa application running that has a chat box inside. Well, I need to capture the text inside that chat-box in real time from another application and write a logfile in real time with that information.

I am sure there is a way, I just don't know where to start. I have experience with cocoa and objective C, I have some apps in the iphone app store.

Thank you very much

+1  A: 

Unless the app is suitably scriptable (e.g. AppleScript) or has some kind of external API then you're not going to be able to do this.

Paul R
Or is accessible and can thereby be mined using the Accessibility API.
Peter Hosey
@Peter: good point, although I'm not sure how many apps are likely to fall into this category.
Paul R
Hello :-) Thanks for your answers. I have tried to use F-script and imlib to study and inject code but it turns out the application is not a cocoa application, is a carbon application. Any ideas? :) Thank you very very much.
flaab
I will have a look into the accesibility API! What can it do for me? Thank you!
flaab
+1  A: 

In short: Contact the developer of the application, but don't get your hopes up.

Unfortunately, in this day and age of protected memory and whatnot, we more or less have to be content with what the applications give us to work with.

However: You are not entirely without recourse. Using F-Script you might be able to attach to the process and cause some controller or other to emit notifications that you can capture and log.

Edit: If, as appears to be the case, it's a Carbon application, you are well and truly hosed:

  1. F-script and similar is unlikely to be possible.
  2. Even if it is, trying injection on a Carbon app, that is to say, a C++ app, is likely to be an exercise in futility and disappointment, if not completely impossible.
  3. Seeing as how Carbon is deprecated (and how!), the application is unlikely to be updated with a proper API for that sort of thing.
  4. All of the above.

Reedit: One tiny little aber; it is possible, although unlikely, that you can achieve something using Interface Scripting, but again; I wouldn't get my hopes up.

Williham Totland
Thanks for your answers. I have tried to use F-script and imlib to study and inject code but it turns out the application is not a cocoa application, is a carbon application. Any ideas? :) Thank you very very much.
flaab
Yeah, see updated answer.
Williham Totland
Hello :-) I've tried to replace some C functions useing LD_PRELOAD and dlsym library for dinamic linking. It worked well under linux for other applicattion but it does not seem to work for this app. Mac OS X uses another preload directive and GCC fails to compile it under mac. The code is here next:
flaab
#define _GNU_SOURCE#include <stdint.h>#include <stdio.h>#include <string.h>#include <stdarg.h>#include <dlfcn.h>/** * Interponemos nuestra funcion open * * @param char* filename * @param int flags **/int open(char * filename, int flags){ static int (*real_open)(char*, int) = NULL; if (!real_open) real_open = dlsym(RTLD_NEXT, "open"); // Entero int p = real_open(filename, flags); fprintf(stderr, "Abrimos %s) = %i\n", filename, flags); // Devolvemos return p;}
flaab
That worked under linux but gcc won't compile it under mac and preload does not work!
flaab