[apple] 프로그래밍 방식으로 트윗 할 수 있도록 알림 센터 / 트위터에 어떤 후크가 있습니까?

특히 해당 유틸리티에서 트윗을 시작할 수 있도록 LaunchBar에 대한 사용자 지정 작업을 설계 하려고합니다. 알림 센터에는 “클릭하여 트윗”버튼이 있으므로 알림 센터에 프로그램 개발자가이 작업을 수행하는 기능을 추가 할 때까지 기다리지 않고 스크립트를 작성할 수있는 후크가 있는지 궁금합니다.



답변

앱은 새로운 NSSharingService API 를 통해 공유 옵션에 연결할 수 있습니다 . 이 같은 소리 (이 API를 활성화하는 – 사용자 정의 실행 창 작업은 어떤 UNIX 실행 파일로 만들 수 있습니다 당신은 아마 작은 명령 줄 도구를 쓸 수있다 (당신이 그것을 테스트해야합니다 또는 당신이 실제 응용 프로그램을 구축해야 할 수도 있습니다) 그래서, )를 사용 NSSharingServiceNamePostOnTwitter하면 트윗 대화 상자가 표시됩니다.

업데이트 : AppleScript에서 트윗을 시작하려면 다음을 수행하십시오.

tell application "System Events"
    tell process "Notification Center"
        -- activate notification center
        if (count of UI elements) is 1 then click first menu bar's first menu bar item
        -- click the tweet button
        click button 1 of UI element 1 of row 2 of table 1 of scroll area 1 of window "Window"
    end tell
end tell

또한 “알림 및 배너 표시”/ 방해 금지 모드를 전환 할 수 있습니다.

tell application "System Events"
    tell process "Notification Center"
        key down option
        click first menu bar's first menu bar item
        key up option
    end tell
end tell

(이것은 모두 알림 센터의 현재 창 레이아웃에만 적용되며 향후 OS X 업데이트에서 중단 될 수 있지만 쉽게 수정 될 수 있습니다.)


답변

아무도 알지 못합니다 ( 실제로 알림 영역 내에 Twitter / Facebook 빠른 게시 영역 을 갖는 것은 실제로 바보 일뿐이며 실제로는 꺼져 있다고 생각합니다)하지만 명령 줄을 사용하여 웹 페이지 에서 언급 한대로 아래 트윗을 읽어보십시오 .


트윗 목록을 표시하려면 (osxdaily를 선택한 트위터 사용자 이름으로 바꾸십시오) :

curl -s http://twitter.com/osxdaily | grep '' | cut -d">" -f2 | cut -d"<" -f1

트위터 상태를 업데이트하려면 :

curl -u your_user:your_password -d status='This is My update' https://twitter.com/statuses/update.xml


답변

한 걸음 더 나아가서 지금까지 배운 내용을 종합하면 다음과 같이 완전히 프로그래밍 가능한 트윗이 있습니다.

tell application "System Events"
    tell process "Notification Center"
        click menu bar item 1 of menu bar 1
        click button 1 of UI element 1 of row 2 of table 1 of scroll area 1 of window "window"
        keystroke "Content of the tweet"
        keystroke "D" using {command down, shift down}
    end tell
end tell

물론 이것은 깨지기 쉽지만 현재로서는 작동합니다. 나는 진짜 후크 를 찾고 싶지만 UI 스크립팅은 해결 방법입니다.


답변

화려한 커맨드 시프트 D.

첨가:

display dialog "Tweet?" default answer "" buttons {"OK"} default button 1
set mytweet to text returned of result

tell application "System Events"
    tell process "Notification Center"
        click menu bar item 1 of menu bar 1
        click button 1 of UI element 1 of row 2 of table 1 of scroll area 1 of window "window"
        keystroke mytweet
        keystroke "D" using {command down, shift down}
        keystroke space
    end tell
end tell


답변

Ewwis가 게시 한 스크립트의 일부 문제를 해결하는 다른 스크립트를 작성했습니다.

  • 처음에 대화 상자를 닫을 방법이 없었습니다.
  • 마지막 로그인 후 알림 센터가 표시되지 않은 경우 두 번째 클릭 동작이 작동하지 않았습니다.
  • 트윗 작성에 대한보기가 표시되기 전에 지연이 발생하면 스크립트가 작동하지 않았습니다. 텍스트가 이미 포함되어 있으면 지워지지 않았습니다.
  • 키 입력 명령은 현재 입력 방법으로 입력 할 수있는 문자를 삽입하는 경우에만 작동합니다.
  • 마지막에 알림 센터 사이드 바가 닫히지 않았습니다.

알림 센터 사이드 바가 열려 있으면 작동하지 않습니다.

set answer to text returned of (display dialog "" default answer "")
try
    set old to the clipboard as record
end try
try
    set text item delimiters to linefeed
    set the clipboard to paragraphs of answer as text
    tell application "System Events"
        tell process "Notification Center"
            click menu bar item 1 of menu bar 1
            try
                windows
            on error
                click menu bar item 1 of menu bar 1
                click menu bar item 1 of menu bar 1
            end try
            click button 1 of UI element 1 of row 2 of table 1 of scroll area 1 of window 1
            delay 0.1
            keystroke "av" using command down
            keystroke "d" using {shift down, command down}
            repeat 100 times
                try
                    delay 0.1
                    click menu bar item 1 of menu bar 1
                    exit repeat
                end try
            end repeat
        end tell
    end tell
end try
try
    set the clipboard to old
end try

API를 사용하는 것이 더 쉬울 것 입니다.


답변

환상적인! 세상을 다른 방식으로 보여 주셔서 감사합니다.

내 솔루션은 나를 위해 일했지만 당신도 그렇게했습니다.

나는 FAR의 Applescript 전문가는 아니지만 그것을 다루는 것을 좋아합니다.

감사!

내가 당신에게서 배운 것을 사용하여, 나를 위해 일하는 또 다른 방법이 있습니다. 이것은 대체 키보드 나 오류에 대한 귀하의 우려를 해결하지는 못하지만, AS에 손을 대는 사람에게는 빛을 비출 것입니다.

display dialog "Tweet?" default answer "" buttons {"OK"} default button 1 with icon 2
set mytweet to text returned of result

tell application "System Events"
    tell process "Notification Center"
        click menu bar item 1 of menu bar 1
        click button 1 of UI element 1 of row 2 of table 1 of scroll area 1 of window "window"
        keystroke mytweet
        keystroke "D" using {command down, shift down}
        repeat 100 times
            try
                delay 0.1
                click menu bar item 1 of menu bar 1
                exit repeat
            end try
        end repeat
    end tell
end tell


답변