Call other program functions?

So, I have this program that I really like, and it does not support Applescript. I would like to automate it a bit. Now I know that I could use applescript to tell the program to tell the menu, to tell the submenu so that it says that the menu item is activated or something else, but frankly, I do not really like applescript.

When I open the NIB file in IB, I can see the messages that are sent to FirstResponder; for example, the menu item "Copy" sends " copy:". Is there a way to call this directly from another program?

+3
source share
3 answers

No. You know, this is called secure memory. Another program is completely isolated from your application. There are ways to put the code in other applications, but (a) it is very impractical (b) requires root privileges, which means that the rest of your application must be ROCK SOLID AND IMPREGNABLE and (c) writing such code is a black art requiring knowledge interfaces of the kernel of the operating system, virtual memory management, ABI, internal components of the linker / loader, assembler programming and operating parameters, and other features of the specific processor on which your application runs.

Indeed, AppleEvents and other similar IPC mechanisms exist for some reason.

( , , , , /), , ,

  • API- Accessibility ApplicationServices, , , , . ( , ).
  • API- CoreGraphics ( Framework ApplicationServices), ( ). : Command-down, C-down, C-up, Command-up.

. , , , - , , - , ..

+2

SIMBL mach_inject. SIMBL - ( , mach_inject, , - ScriptingAdditions), , SIMBL, SIMBL . mach_inject. , , , mach_inject_framework, , .

+1

, ; , , , . Cocoa ( ). API Accessibility ( , , ). Fscript Cocoa. - , SIMBL - , .

Applescript , Apple Events - , Apple . Script Editor Open Library, , Applescript? Apple Events Objective-C, Leopard Scripting Bridge. , ( Apple).

Cocoa - -. , SIMBL, . "Wolf" .

Jim is right. Many of these approaches can completely destabilize the system if done incorrectly (sometimes even if everything is done correctly). I do not do this on my production systems; I need them to work. But there are many things you can do for a Mac application, and this is a good part of learning Mac developers to understand how all the parts really work.

0
source

Source: https://habr.com/ru/post/1708381/


All Articles