我们是否能够通过按钮点击呼叫山狮的听写功能

时间:2013-04-18 08:26:42

标签: objective-c cocoa wxwidgets

默认情况下,在文本控件中按两次fn键时会调用Mountain Lion听写功能。

我想知道是否可以从其他控件和事件中调用相同的功能,例如在按钮单击事件后调用它?

我希望我的应用程序使用Mountain Lion提供的默认听写功能。我的跨平台应用程序(wxWidgets)有一个源自wxControl的编辑器,它没有调用此听写功能的默认行为;如果我使用默认文本控件,该功能的工作正常。

请建议。

由于

1 个答案:

答案 0 :(得分:0)

您可以尝试这样的事情:

NSAppleScript *scriptForCMDKey = [[NSAppleScript alloc] initWithSource:@"tell application \"System Events\"\nset theProcess to first process whose frontmost is true\ntell theProcess\nrepeat 2 times\nkey down {command}\nkey up {command}\nend repeat\nend tell\nend tell"];
[scriptForCMDKey executeAndReturnError:nil];

NSAppleScript *scriptForFNKey = [[NSAppleScript alloc] initWithSource:@"tell application \"System Events\"\nset theProcess to first process whose frontmost is true\ntell theProcess\nrepeat 2 times\nkey code 63\nkey code 63\nend repeat\nend tell\nend tell"];
[scriptForFNKey executeAndReturnError:nil];