I am trying to enable accessibility through my code.
Got an example source code Trust Me application.
before enabling the Accessiblity, the application prompt a dialog box for allowing access with username and password, i want to prevent this dialog box.
the code given in trust me application is as shown below :
i want to enable accessibility for my application but i dnt want it to show any authorization dialog box.
Please help.
Thanks,
ruhi.
Got an example source code Trust Me application.
before enabling the Accessiblity, the application prompt a dialog box for allowing access with username and password, i want to prevent this dialog box.
the code given in trust me application is as shown below :
Code:
- (void)makeProcessTrusted;
{
//authentication based on file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/Security/Conceptual/authorization_concepts/03authtasks/chapter_3_section_4.html
OSStatus myStatus;
AuthorizationFlags myFlags = kAuthorizationFlagDefaults;
AuthorizationRef myAuthorizationRef;
myStatus = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, myFlags, &myAuthorizationRef);
if (myStatus != errAuthorizationSuccess)
{
[self askUserToEnableAccessForAssistiveDevices];
return;
}
AuthorizationItem myItems = {kAuthorizationRightExecute, 0, NULL, 0};
AuthorizationRights myRights = {1, &myItems};
myFlags = kAuthorizationFlagDefaults |
kAuthorizationFlagInteractionAllowed |
kAuthorizationFlagPreAuthorize |
kAuthorizationFlagExtendRights;
myStatus = AuthorizationCopyRights (myAuthorizationRef, &myRights, NULL, myFlags, NULL );
if (myStatus != errAuthorizationSuccess)
{
AuthorizationFree (myAuthorizationRef, kAuthorizationFlagDefaults);
[self askUserToEnableAccessForAssistiveDevices];
return;
}
//we pass the path to our bundle to the agent so it can relaunch us when it makes us trusted
char *myArguments[] = { (char *)([[[NSBundle mainBundle]bundlePath]fileSystemRepresentation]), NULL };
const char *makeProcessTrustedAgentPath = [[[NSBundle bundleWithPath:[[NSBundle mainBundle]pathForAuxiliaryExecutable:@"MakeProcessTrustedAgent.app"]]executablePath]fileSystemRepresentation];
myFlags = kAuthorizationFlagDefaults;
myStatus = AuthorizationExecuteWithPrivileges(myAuthorizationRef,makeProcessTrustedAgentPath,myFlags,myArguments, NULL);
AuthorizationFree (myAuthorizationRef, kAuthorizationFlagDefaults);
if (myStatus!= errAuthorizationSuccess)
{
[self askUserToEnableAccessForAssistiveDevices];
return;
}
//due to a bug with AXMakeProcessTrusted(), we need to be relaunched before we will actually have access to UI Scripting
[NSApp terminate:nil];
}
i want to enable accessibility for my application but i dnt want it to show any authorization dialog box.
Please help.
Thanks,
ruhi.