Skip to content
This repository was archived by the owner on Mar 22, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
.Trashes
xcuserdata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 17 additions & 1 deletion CocoaActivityCounter/DBAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theAppl
return YES;
}

-(void)logMessageToLogView:(NSString*)message {
- (void)logMessageToLogView:(NSString*)message {
[logView setString: [[logView string] stringByAppendingFormat:@"%@: %@\n", [self.logDateFormatter stringFromDate:[NSDate date]], message]];
}

Expand All @@ -56,6 +56,15 @@ - (IBAction)startButtonPressed:(id)sender {
if (self.loggingEnabled) {
return;
}


if (checkAccessibility()) {
[self logMessageToLogView:@"Accessibility Enabled"];
}
else {
[self logMessageToLogView:@"Accessibility Disabled"];
}

self.loggingEnabled = true;
monitorLeftMouseDown = [NSEvent addGlobalMonitorForEventsMatchingMask:NSLeftMouseDownMask handler:^(NSEvent *evt) {
[self logMessageToLogView:[NSString stringWithFormat:@"Left mouse down!"]];
Expand Down Expand Up @@ -91,4 +100,11 @@ - (BOOL)validateToolbarItem:(NSToolbarItem *)theItem {
return YES;
}


BOOL checkAccessibility()
{
NSDictionary* opts = @{(__bridge id)kAXTrustedCheckOptionPrompt: @YES};
return AXIsProcessTrustedWithOptions((__bridge CFDictionaryRef)opts);
}

@end