如何在“系统偏好设置>”中更改修饰键。键盘>修改键...“ [英] How can I change modifier keys in "System Preferences > Keyboard > Modifier Keys..."
本文介绍了如何在“系统偏好设置>”中更改修饰键。键盘>修改键...“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要以编程方式更改系统偏好设置>键盘>修改键...中的Caps Lock,Control,Option和Command键的值
I
解决方案
div>
这里是苹果脚本capsLockOff.scpt:
告诉应用程序系统首选项
activate
将当前窗格设置为窗格com.apple.preference.keyboard
end tell
告诉应用程序系统事件
告诉应用程序进程系统首选项
获取属性
单击窗口键盘的选项卡组1的修改键...
显示窗口键盘的表1
单击弹出按钮4
点击弹出按钮4的菜单1的菜单项无操作
延迟1
点击按钮确定
end tell
end tell
end tell
让应用程序System Preferences退出
以下是可可代码调用上面的脚本。希望这将有助于
- (void)runAppleScript {
NSString * fileName = @capsLockOff ;
NSString * path = [[NSBundle mainBundle] pathForResource:fileName ofType:@scpt];
NSURL * url = [NSURL fileURLWithPath:path]; NSDictionary * errors = [NSDictionary dictionary];
NSAppleScript * appleScript = [[NSAppleScript alloc] initWithContentsOfURL:url error:& errors];
[appleScript executeAndReturnError:nil];
[appleScript release];
}
I need to programmatically change the values of the Caps Lock, Control, Option and Command keys in "System Preferences > Keyboard > Modifier Keys..."
I dont want to use AppleScript.
Could someone point me in the right direction?
解决方案
Here is apple script capsLockOff.scpt:
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.keyboard"
end tell
tell application "System Events"
tell application process "System Preferences"
get properties
click button "Modifier Keys…" of tab group 1 of window "Keyboard"
tell sheet 1 of window "Keyboard"
click pop up button 4
click menu item "No Action" of menu 1 of pop up button 4
delay 1
click button "OK"
end tell
end tell
end tell
tell application "System Preferences" to quit
Following is cocoa code to call above script. Hope this will help
-(void)runAppleScript{
NSString *fileName = @"capsLockOff";
NSString* path = [[NSBundle mainBundle] pathForResource:fileName ofType:@"scpt"];
NSURL* url = [NSURL fileURLWithPath:path];NSDictionary* errors = [NSDictionary dictionary];
NSAppleScript* appleScript = [[NSAppleScript alloc] initWithContentsOfURL:url error:&errors];
[appleScript executeAndReturnError:nil];
[appleScript release];
}
这篇关于如何在“系统偏好设置>”中更改修饰键。键盘>修改键...“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文