Как я могу программно запустить клавиатуру на Catalina (10.15)? - PullRequest
0 голосов
/ 23 октября 2019

Я хочу запустить экранную (виртуальную) клавиатуру с помощью NSAppleScript на MacOS APP.

Следующий код прекрасно работает до MacOS Catalina (10.15). Все права доступа

разрешены.

NSString *theApplication = @"\"KeyboardViewer\"";
NSString *thePath = @"\"/System/Library/Input Methods/KeyboardViewer.app\"";

NSString *source = [NSString stringWithFormat:@"set HFSPath to ((POSIX file %@) as string)\n\
                    tell application \"System Events\" to ¬\n\
                    set isRunning to 0 < (count (application processes whose name is %@))\n\
                    if isRunning then\n\
                    tell application HFSPath to quit\n\
                    else\n\
                    ignoring application responses\n\
                    tell application HFSPath to activate\n\
                    end ignoring\n\
                    end if",thePath,theApplication];

NSAppleScript *script = [[NSAppleScript alloc] initWithSource:source];
NSDictionary  *dict   = nil;
[script executeAndReturnError:&dict];

Я получил сообщение об ошибке (файл не найден 「Macintosh HD: Система: Библиотека: Методы ввода: KeyboardViewer.app)

Как я мог это исправить?

...