2014-09-09 3 views
0

AppleScript로 시작하고 받아쓰기를 중지 할 수 있습니다. 나는 그것들을 함께 실행하려고 시도했지만 받아쓰기 만 시작하지만 멈추지는 않습니다. 키 코드 방식을 시도했지만이 스크립트는 VoiceOver와 함께 사용되며 그 방법은 작동하지 않습니다. 시작/정지가 준비되었는지 여부에 따라 스크립트 확인을 수행하고 그에 따라 행동 할 수있는 방법이 있습니까?메뉴에 따라 "받아쓰기 시작"및 "받아쓰기 중지"AppleScript로

tell application "System Events" 
     tell (get first process whose frontmost is true) 
      tell menu bar 1 
       tell menu bar item "Edit" 
        tell menu 1 
         click menu item "Start Dictation" 
        end tell 
       end tell 
      end tell 
     end tell 
    end tell 
    tell application "System Events" 
     tell (get first process whose frontmost is true) 
      tell menu bar 1 
       tell menu bar item "Edit" 
        tell menu 1 
         click menu item "Stop Dictation" 
        end tell 
       end tell 
      end tell 
     end tell 
    end tell 

답변

0

당신은 exists 명령

tell application "System Events" 
    tell (get first process whose frontmost is true) 
     tell menu 1 of menu bar item "Edit" of menu bar 1 
      if exists of menu item "Start Dictation" then 
       click menu item "Start Dictation" 
      else if exists of menu item "Stop Dictation" then 
       click menu item "Stop Dictation" 
      end if 
     end tell 
    end tell 
end tell 

사용할 수 있습니다 -

를 혹은 다음과 같이, 메뉴의 이름으로 단어를 사용할 수 있습니다에 대한

tell application "System Events" 
    tell (get first process whose frontmost is true) 
     tell menu 1 of menu bar item "Edit" of menu bar 1 
      click (first menu item whose name contains " Dictation") -- start or stop 
     end tell 
    end tell 
end tell 
+0

감사합니다 도움. 더 나은 터치 도구와 같은 스크립트 실행기를 사용하여 스크립트를 실행하면 두 스크립트 모두 정상적으로 작동하지만, VoiceOver 유틸리티 (Trackpad Commander)가 내장 된 OSX의 제스처에이 스크립트를 할당하려고합니다. 명령 또는 제스처를 오른쪽으로 움직이는 것과 같은 제스처에 할당되면 받아쓰기를 시작하고 다시 제스처를 호출하면이를 중지하는 대신 받아쓰기를 다시 시작합니다. 왜 이런 일이 일어나고 있는지에 대한 아이디어가 있습니까? 나는 성공하지 못한 딜레이를 추가하려고 노력했다. – Elias

+0

에뮬레이션, 클릭 또는 바로 가기로 메뉴를 여는 서비스를 시작할 때 구술이 자동으로 중지되므로 스크립트로 구술을 중지하는 것은 불가능합니다. – jackjr300

관련 문제