Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Commit

Permalink
lots of enchencements: thread safe AXUIelement function calls. added …
Browse files Browse the repository at this point in the history
…2 classes: haxView, hawbutton + extended haxwindow: isFulscreen property. + carbon and cocoa frame capabilities.
  • Loading branch information
okocsis committed Jun 16, 2014
1 parent 0967302 commit 8d04663
Show file tree
Hide file tree
Showing 16 changed files with 677 additions and 64 deletions.
2 changes: 1 addition & 1 deletion Classes/HAXApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Created by Rob Rix on 2011-01-06
// Copyright 2011 Rob Rix

#import <Haxcessibility/HAXElement.h>
#import "HAXElement.h"

@class HAXWindow;

Expand Down
10 changes: 7 additions & 3 deletions Classes/HAXApplication.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

@implementation HAXApplication

+(instancetype)applicationWithPID:(pid_t)pid; {
+(instancetype)applicationWithPID:(pid_t)pid;
{
AXUIElementRef app = AXUIElementCreateApplication(pid);
id result = nil;
if (app) {
Expand All @@ -18,12 +19,14 @@ +(instancetype)applicationWithPID:(pid_t)pid; {
return result;
}

-(HAXWindow *)focusedWindow {
-(HAXWindow *)focusedWindow
{
NSError *error = nil;
return [self elementOfClass:[HAXWindow class] forKey:(__bridge NSString *)kAXFocusedWindowAttribute error:&error];
}

-(NSArray *)windows {
-(NSArray *)windows
{
NSArray *axWindowObjects = CFBridgingRelease([self copyAttributeValueForKey:(__bridge NSString *)kAXWindowsAttribute error:nil]);
NSMutableArray *result = [NSMutableArray arrayWithCapacity:[axWindowObjects count]];
for (id axObject in axWindowObjects) {
Expand All @@ -32,4 +35,5 @@ -(NSArray *)windows {
return result;
}


@end
13 changes: 13 additions & 0 deletions Classes/HAXButton.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// HAXButton.h
// Sopreso
//
// Created by Kocsis Olivér on 2014.05.21..
// Copyright (c) 2014 Joinect Technologies. All rights reserved.
//

#import "HAXView.h"

@interface HAXButton : HAXView
-(void)press;
@end
16 changes: 16 additions & 0 deletions Classes/HAXButton.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// HAXButton.m
// Sopreso
//
// Created by Kocsis Olivér on 2014.05.21..
// Copyright (c) 2014 Joinect Technologies. All rights reserved.
//

#import "HAXButton.h"
#import "HAXElement+Protected.h"
@implementation HAXButton
-(void)press
{
[self performAction:(__bridge NSString *)kAXPressAction error:NULL];
}
@end
5 changes: 3 additions & 2 deletions Classes/HAXElement+Protected.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
// Created by Rob Rix on 2011-01-06
// Copyright 2011 Rob Rix

#import <Haxcessibility/HAXElement.h>
#import "HAXElement.h"
#import "NSScreen+PointConvert.h"

@interface HAXElement ()

+(instancetype)elementWithElementRef:(AXUIElementRef)elementRef __attribute__((nonnull(1)));
-(instancetype)initWithElementRef:(AXUIElementRef)elementRef __attribute__((nonnull(1)));

@property (nonatomic, readonly) AXUIElementRef elementRef __attribute__((NSObject));
//@property (nonatomic, readonly) AXUIElementRef elementRef __attribute__((NSObject));

-(CFTypeRef)copyAttributeValueForKey:(NSString *)key error:(NSError **)error __attribute__((nonnull(1)));
-(bool)setAttributeValue:(CFTypeRef)value forKey:(NSString *)key error:(NSError **)error __attribute__((nonnull(1,2)));
Expand Down
9 changes: 8 additions & 1 deletion Classes/HAXElement.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
// HAXElement.h
// Created by Rob Rix on 2011-01-06
// Copyright 2011 Rob Rix

#import "Cocoa/Cocoa.h"
#import <Foundation/Foundation.h>

@protocol HAXElementDelegate;

@interface HAXElement : NSObject

@property (nonatomic, weak) id<HAXElementDelegate> delegate;
@property (nonatomic, readonly) NSString * title;
@property (nonatomic, readonly) NSString * role;
@property (nonatomic, readonly) BOOL hasChildren;
@property (nonatomic, readonly) NSArray * children;
@property (nonatomic, readonly) NSArray * attributeNames;
@property (readonly) AXUIElementRef elementRef __attribute__((NSObject));

-(bool)isEqualToElement:(HAXElement *)other;
-(NSArray *) buttons;

@end

Expand Down
Loading

0 comments on commit 8d04663

Please sign in to comment.