-, FnFn NSText (, , NSTextView?) Cocoa. , . ( .) , NSTextView, "", " " , FnFn - , , , , , , , .
, GUI, , .
, - NSMenu ,
- , PyQt Tkinter, . , Cocoa ( PyObjC, Python Apple, pip install, Python):
import AppKit
mb = AppKit.NSApp.mainMenu()
edit = mb.itemWithTitle_('Edit').submenu()
sd = edit.indexOfItemWithTitle_('Start Dictation')
edit.performActionForItemAtIndex_(sd)
, ( Terminal.app , iTerm), , , "", .
, , . OS X " " . 10.10 "" " " " " "", , . , , , , , , , , , - .
AppleScript :
tell application "System Events"
click (menu item "Start Dictation" of menu of menu bar item "Edit"
of menu bar of (first process whose frontmost is true))
end tell
"" Python - ScriptingBridge, PyObjC... appscript:
from appscript import app, its
se = app('System Events')
proc = app.processes[its.frontmost == True]
mi = proc.menu_bars[1].menu_bar_items['Edit'].menus[1].menu_items['Start Dictation']
mi.click()
Fn, API Quartz Events Services, ( API- CoreFoundation C, API- Cocoa ObjC) PyObjC. , , , , . , Fn-key, :
evt = Quartz.CGEventCreateKeyboardEvent(None, 63, True)
Quartz.CGEventPost(Quartz.kCGSessionEventTap, evt)
, True False.