AXUIElement.pas 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. {
  2. * AXUIElement.h
  3. *
  4. * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
  5. *
  6. }
  7. { Pascal Translation: Peter N Lewis, <[email protected]>, 2004 }
  8. { Pascal Translation Updated: Gale R Paeper, <[email protected]>, 2006 }
  9. {
  10. Modified for use with Free Pascal
  11. Version 200
  12. Please report any bugs to <[email protected]>
  13. }
  14. {$mode macpas}
  15. {$packenum 1}
  16. {$macro on}
  17. {$inline on}
  18. {$CALLING MWPASCAL}
  19. unit AXUIElement;
  20. interface
  21. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  22. {$setc GAP_INTERFACES_VERSION := $0200}
  23. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  24. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  25. {$endc}
  26. {$ifc defined CPUPOWERPC and defined CPUI386}
  27. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  28. {$endc}
  29. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  30. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  31. {$endc}
  32. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  33. {$setc __ppc__ := 1}
  34. {$elsec}
  35. {$setc __ppc__ := 0}
  36. {$endc}
  37. {$ifc not defined __i386__ and defined CPUI386}
  38. {$setc __i386__ := 1}
  39. {$elsec}
  40. {$setc __i386__ := 0}
  41. {$endc}
  42. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  43. {$error Conflicting definitions for __ppc__ and __i386__}
  44. {$endc}
  45. {$ifc defined __ppc__ and __ppc__}
  46. {$setc TARGET_CPU_PPC := TRUE}
  47. {$setc TARGET_CPU_X86 := FALSE}
  48. {$elifc defined __i386__ and __i386__}
  49. {$setc TARGET_CPU_PPC := FALSE}
  50. {$setc TARGET_CPU_X86 := TRUE}
  51. {$elsec}
  52. {$error Neither __ppc__ nor __i386__ is defined.}
  53. {$endc}
  54. {$setc TARGET_CPU_PPC_64 := FALSE}
  55. {$ifc defined FPC_BIG_ENDIAN}
  56. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  57. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  58. {$elifc defined FPC_LITTLE_ENDIAN}
  59. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  60. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  61. {$elsec}
  62. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  63. {$endc}
  64. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  65. {$setc CALL_NOT_IN_CARBON := FALSE}
  66. {$setc OLDROUTINENAMES := FALSE}
  67. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  68. {$setc OPAQUE_UPP_TYPES := TRUE}
  69. {$setc OTCARBONAPPLICATION := TRUE}
  70. {$setc OTKERNEL := FALSE}
  71. {$setc PM_USE_SESSION_APIS := TRUE}
  72. {$setc TARGET_API_MAC_CARBON := TRUE}
  73. {$setc TARGET_API_MAC_OS8 := FALSE}
  74. {$setc TARGET_API_MAC_OSX := TRUE}
  75. {$setc TARGET_CARBON := TRUE}
  76. {$setc TARGET_CPU_68K := FALSE}
  77. {$setc TARGET_CPU_MIPS := FALSE}
  78. {$setc TARGET_CPU_SPARC := FALSE}
  79. {$setc TARGET_OS_MAC := TRUE}
  80. {$setc TARGET_OS_UNIX := FALSE}
  81. {$setc TARGET_OS_WIN32 := FALSE}
  82. {$setc TARGET_RT_MAC_68881 := FALSE}
  83. {$setc TARGET_RT_MAC_CFM := FALSE}
  84. {$setc TARGET_RT_MAC_MACHO := TRUE}
  85. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  86. {$setc TYPE_BOOL := FALSE}
  87. {$setc TYPE_EXTENDED := FALSE}
  88. {$setc TYPE_LONGLONG := TRUE}
  89. uses MacTypes,CFBase,CFArray,AXErrors,CFRunLoop,CGRemoteOperation,MacOSXPosix;
  90. {$ALIGN MAC68K}
  91. function AXAPIEnabled: Boolean; external name '_AXAPIEnabled';
  92. function AXIsProcessTrusted: Boolean; external name '_AXIsProcessTrusted';
  93. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  94. // must be called with root privs
  95. function AXMakeProcessTrusted( executablePath: CFStringRef ): AXError; external name '_AXMakeProcessTrusted';
  96. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  97. type
  98. AXUIElementRef = ^SInt32; { an opaque 32-bit type }
  99. const
  100. kAXCopyMultipleAttributeOptionStopOnError = $1;
  101. type
  102. AXCopyMultipleAttributeOptions = UInt32;
  103. function AXUIElementGetTypeID: CFTypeID; external name '_AXUIElementGetTypeID';
  104. function AXUIElementCopyAttributeNames( element: AXUIElementRef; var names: CFArrayRef ): AXError; external name '_AXUIElementCopyAttributeNames';
  105. function AXUIElementCopyAttributeValue( element: AXUIElementRef; attribute: CFStringRef; var value: CFTypeRef ): AXError; external name '_AXUIElementCopyAttributeValue';
  106. function AXUIElementGetAttributeValueCount( element: AXUIElementRef; attribute: CFStringRef; var count: CFIndex ): AXError; external name '_AXUIElementGetAttributeValueCount';
  107. function AXUIElementCopyAttributeValues( element: AXUIElementRef; attribute: CFStringRef; index: CFIndex; maxValues: CFIndex; var values: CFArrayRef ): AXError; external name '_AXUIElementCopyAttributeValues';
  108. function AXUIElementIsAttributeSettable( element: AXUIElementRef; attribute: CFStringRef; var settable: Boolean ): AXError; external name '_AXUIElementIsAttributeSettable';
  109. function AXUIElementSetAttributeValue( element: AXUIElementRef; attribute: CFStringRef; value: CFTypeRef ): AXError; external name '_AXUIElementSetAttributeValue';
  110. function AXUIElementCopyMultipleAttributeValues( element: AXUIElementRef; attributes: CFArrayRef; options: AXCopyMultipleAttributeOptions; var values: CFArrayRef ): AXError; external name '_AXUIElementCopyMultipleAttributeValues';
  111. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  112. function AXUIElementCopyParameterizedAttributeNames( element: AXUIElementRef; var names: CFArrayRef ): AXError; external name '_AXUIElementCopyParameterizedAttributeNames';
  113. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  114. function AXUIElementCopyParameterizedAttributeValue( element: AXUIElementRef; parameterizedAttribute: CFStringRef; parameter: CFTypeRef; var result: CFTypeRef ): AXError; external name '_AXUIElementCopyParameterizedAttributeValue';
  115. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  116. function AXUIElementCopyActionNames( element: AXUIElementRef; var names: CFArrayRef ): AXError; external name '_AXUIElementCopyActionNames';
  117. function AXUIElementCopyActionDescription( element: AXUIElementRef; action: CFStringRef; var description: CFStringRef ): AXError; external name '_AXUIElementCopyActionDescription';
  118. function AXUIElementPerformAction( element: AXUIElementRef; action: CFStringRef ): AXError; external name '_AXUIElementPerformAction';
  119. function AXUIElementCopyElementAtPosition( application: AXUIElementRef; x: Float32; y: Float32; var element: AXUIElementRef ): AXError; external name '_AXUIElementCopyElementAtPosition';
  120. function AXUIElementCreateApplication( pid: pid_t ): AXUIElementRef; external name '_AXUIElementCreateApplication';
  121. function AXUIElementCreateSystemWide: AXUIElementRef; external name '_AXUIElementCreateSystemWide';
  122. function AXUIElementGetPid( element: AXUIElementRef; var pid: pid_t ): AXError; external name '_AXUIElementGetPid';
  123. // pass the SystemWide element (AXUIElementCreateSystemWide) if you want to set the timeout globally for this process
  124. // setting the timeout on another AXUIElementRef sets it only for that ref, not for other AXUIElementRef(s) that are
  125. // equal to it.
  126. // setting timeout to 0 makes this element use the global timeout
  127. function AXUIElementSetMessagingTimeout( element: AXUIElementRef; timeoutInSeconds: Float32 ): AXError; external name '_AXUIElementSetMessagingTimeout';
  128. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  129. // see CGRemoteOperation.h for documentation of parameters
  130. // you can only pass the root or application uielement
  131. function AXUIElementPostKeyboardEvent( application: AXUIElementRef; keyChar: CGCharCode; virtualKey: CGKeyCode; keyDown: Boolean ): AXError; external name '_AXUIElementPostKeyboardEvent';
  132. // Notification APIs
  133. type
  134. AXObserverRef = ^SInt32; { an opaque 32-bit type }
  135. type
  136. AXObserverCallback = procedure( observer: AXObserverRef; element: AXUIElementRef; notification: CFStringRef; refcon: UnivPtr );
  137. function AXObserverGetTypeID: CFTypeID; external name '_AXObserverGetTypeID';
  138. function AXObserverCreate( application: pid_t; callback: AXObserverCallback; var outObserver: AXObserverRef ): AXError; external name '_AXObserverCreate';
  139. function AXObserverAddNotification( observer: AXObserverRef; element: AXUIElementRef; notification: CFStringRef; refcon: UnivPtr ): AXError; external name '_AXObserverAddNotification';
  140. function AXObserverRemoveNotification( observer: AXObserverRef; element: AXUIElementRef; notification: CFStringRef ): AXError; external name '_AXObserverRemoveNotification';
  141. function AXObserverGetRunLoopSource( observer: AXObserverRef ): CFRunLoopSourceRef; external name '_AXObserverGetRunLoopSource';
  142. end.