Skip to content

Instantly share code, notes, and snippets.

@szk-3
szk-3 / make_new_list_in_Reminders_from_ASObjC.scpt
Created August 26, 2016 15:43
Cocoaの機能を使ってRemindersで新規リストを作成するAppleScript ref: http://qiita.com/szk-3/items/eb0d91d6ad9827a8e644
use framework "EventKit"
set eventStore to current application's EKEventStore's alloc()'s initWithAccessToEntityTypes:(current application's EKEntityMaskReminder)
set calendar to current application's EKCalendar's calendarForEntityType:(current application's EKEntityTypeReminder) eventStore:eventStore
set calendar's title to "New List from ASObjC"
set calendar's source to eventStore's defaultCalendarForNewReminders's source
eventStore's saveCalendar:calendar commit:true |error|:(missing value)
@szk-3
szk-3 / make_new_reminder_from_ASObjC.scpt
Created August 26, 2016 09:41
Cocoaの機能を使ってRemindersで新規リマインダーを作成するAppleScript ref: http://qiita.com/szk-3/items/6fe8643534e4836e8371
use framework "EventKit"
set eventStore to current application's EKEventStore's alloc()'s initWithAccessToEntityTypes:(current application's EKEntityMaskReminder)
set reminder to current application's EKReminder's reminderWithEventStore:eventStore
set reminder's title to "New Reminder from ASObjC"
set reminder's calendar to eventStore's defaultCalendarForNewReminders
eventStore's saveReminder:reminder commit:true |error|:(missing value)
@szk-3
szk-3 / everyAuthorInEvernote.scpt
Created March 5, 2016 06:32
Evernoteの全ノートに含まれる作成者を取得するAppleScriptハンドラ ref: http://qiita.com/szk-3/items/364daf73eafbd03d7c34
use scripting additions
use framework "Foundation"
my everyAuthorInEvernote()
on everyAuthorInEvernote()
return text of my everyParameterOfNotesInEvernote("author")
end everyAuthorInEvernote
on everyParameterOfNotesInEvernote(noteParameter as text)
@szk-3
szk-3 / connectToWifi.scpt
Created February 15, 2016 08:33
Cocoaの機能を使ってWi-Fiに接続するAppleScript ref: http://qiita.com/szk-3/items/57bff1e27a7e7466fc6f
use scripting additions
use framework "CoreWLAN"
use framework "Foundation"
--SSID選択
set chooseResult to choose from list my listWiFi()
if chooseResult = false then
error number -128
end if
set networkSSID to item 1 of chooseResult
@szk-3
szk-3 / switchWiFi.scpt
Created February 14, 2016 04:30
Cocoaの機能を使ってWi-FiのON/OFFを切り替えるAppleScriptハンドラ ref: http://qiita.com/szk-3/items/eb806069b609a256afab
use framework "CoreWLAN"
--Wi-Fi ON
my switchWiFi(true)
--Wi-Fi OFF
my switchWiFi(false)
on switchWiFi(onOrOff as boolean)
--require framework: CoreWLAN
@szk-3
szk-3 / file0.txt
Last active March 5, 2016 04:48
RRULE文字列とEKRecurrenceRuleを変換するAppleScriptハンドラ ref: http://qiita.com/szk-3/items/e8c2cfb5d4e9829f2659
use scripting additions
use framework "EventKit"
use framework "Foundation"
--Every other day
set recurrenceRule to my recurrenceRuleFromString("FREQ=DAILY;INTERVAL=2")
--> «class ocid» id «data optr00000000200393FFB97F0000»
my stringFromRecurrenceRule(recurrenceRule)
--> "FREQ=DAILY;INTERVAL=2"
@szk-3
szk-3 / copyHTML.scpt
Last active September 24, 2016 13:32
Cocoaの機能を使ってHTML文字列をコピーするAppleScriptハンドラ ref: http://qiita.com/szk-3/items/ada884e10d4fe88eef2e
use scripting additions
use framework "AppKit"
use framework "Foundation"
my copyHTML("<p>あいうえお</p>")
the clipboard as record
(*
{«class HTML»:«data HTML3C703EE38182E38184E38186E38188E3818A3C2F703E», «class utf8»:"あいうえお
", «class RTF »:«data RTF 7B5C727466315C616E73695C616E73696370673933325C636F636F61727466313430345C636F636F617375627274663437300A7B5C666F6E7474626C5C66305C66726F6D616E5C6663686172736574302054696D65732D526F6D616E3B7D0A7B5C636F6C6F7274626C3B5C7265643235355C677265656E3235355C626C75653235353B5C726564305C677265656E305C626C7565303B7D0A5C6465667461623732300A5C706172645C7061726465667461623732305C736C3238305C73613234305C7061727469676874656E666163746F72300A0A5C66305C66733234205C636632205C6578706E64305C6578706E647477305C6B65726E696E67300A5C6F75746C305C7374726F6B65776964746830205C7374726F6B656332205C7563305C753132333534205C753132333536205C753132333538205C753132333630205C753132333632205C0A7D», «class ut16»:"あいうえお
@szk-3
szk-3 / file0.txt
Created January 31, 2016 05:51
Cocoaの機能を使ってアプリケーションを強制終了するAppleScriptハンドラ ref: http://qiita.com/szk-3/items/ae71419851b131b8b558
use scripting additions
use framework "AppKit"
my forceQuitApplication("SystemUIServer")
on forceQuitApplication(anApplication)
--require Framework: AppKit
tell application "System Events"
set bundleIdentifier to bundle identifier of my getProcess(anApplication)
end tell
@szk-3
szk-3 / useFrameworkForTextExpander.scpt
Created January 29, 2016 13:30
AppleScriptからCocoaの機能を使うためにフレームワークを取得する ref: http://qiita.com/szk-3/items/b3d1aec5a6aa7815058b
set availableFrameworks to my getEveryFramework()
return "return " & quote & "use framework " & character id {92, 34, 37} & "fillpopup:name=framework:default=" & my join(availableFrameworks, ":") & character id {37, 92, 34, 34}
on getEveryFramework()
--framework取得
set frameworkNameList to {}
tell application "Finder"
repeat with libraryFolder in {path to library folder from system domain as alias, path to library folder from local domain as alias, path to library folder from user domain as alias}
if exists items of folder "Frameworks" of libraryFolder then
set frameworkNameList to frameworkNameList & name of items of folder "Frameworks" of libraryFolder
@szk-3
szk-3 / convertHTMLToPlainText.scpt
Last active February 1, 2016 11:19
Cocoaの機能を使ってHTML文字列をプレーンテキストに変換するAppleScriptハンドラ ref: http://qiita.com/szk-3/items/a8a7c12e8a9bad5446b9
use scripting additions
use framework "AppKit"
tell application "Safari"
my convertHTMLToPlainText(source of current tab of window 1)
end tell
on convertHTMLToPlainText(HTML)
--require framework: Foundation
set attributedString to my attributedStringOfHTMLText(HTML)