PDA

View Full Version : UI login apple script not running on 10.8.3 but working fine on 10.6.x




abidkhan135
Apr 2, 2013, 01:39 AM
I had coded an applescript that login the user on back end when MAC starts.
NSAppleScript *runscript;

//NSLog(@"comes to applescript");
//////////NEW CODE FROM HERE//////////

NSString *scriptString = @"set username_ to \"Administrator\"\n"
"set password_ to \"vsi9217\"\n"
"tell application \"System Events\"\n"
"key code 125\n"
"key code 125\n"
"delay 1\n"
"key code 125\n"
"key code 125\n"
"key code 125\n"
"key code 125\n"
"key code 125\n"
"key code 125\n"
"delay 0.5\n"
"key code 36\n"
"delay 1\n"
"tell process \"SecurityAgent\" to set value of text field 1 of group 1 of window 1 to username_\n"
"tell process \"SecurityAgent\" to set value of text field 2 of group 1 of window 1 to password_\n"
"click button \"Log In\" of window 1 of application process \"SecurityAgent\"\n"
"end tell\n";

NSLog(@"%@",scriptString);





runscript = [[NSAppleScript alloc] initWithSource:scriptString];

[runscript executeAndReturnError:nil];
[runscript release];
its working fine and perfect on 10.6.x but when i updated my OS to 10.8.3 script is not working . Kindly help.