pasteboardAsString
pasteboardAsString.scpt
use framework "AppKit"
use framework "Foundation"
return my pasteboardAsString()
on pasteboardAsString()
--require framework: AppKit, Foundation
set pasteboard to current application's NSPasteboard's generalPasteboard
return (pasteboard's stringForType:(current application's NSPasteboardTypeString)) as text
end pasteboardAsString
更新履歴
- 2016-02-01: AppKitフレームワークのNSPasteboardクラスとNSAttributedStringクラスを使って作成
- 2016-09-24:
stringForType
メソッドを使用
pasteboardAsHTML
pasteboardAsHTML.scpt
use framework "AppKit"
use framework "Foundation"
return my pasteboardAsHTML()
on pasteboardAsHTML()
--require framework: AppKit, Foundation
set pasteboard to current application's NSPasteboard's generalPasteboard
set HTML to pasteboard's stringForType:(current application's NSPasteboardTypeHTML)
if HTML = missing value then
set RTF to pasteboard's dataForType:(current application's NSPasteboardTypeRTF)
if RTF = missing value then
error
end if
set attributedString to current application's NSAttributedString's alloc()'s initWithRTF:RTF documentAttributes:(missing value)
set attributes to current application's NSDictionary's dictionaryWithObject:(current application's NSHTMLTextDocumentType) forKey:(current application's NSDocumentTypeDocumentAttribute)
set HTMLData to attributedString's dataFromRange:{location:0, |length|:attributedString's |length|()} documentAttributes:attributes |error|:(missing value)
set HTML to current application's NSString's alloc()'s initWithData:HTMLData encoding:(current application's NSUTF8StringEncoding)
end if
return HTML as text
end pasteboardAsHTML
更新履歴
- 2016-02-01: AppKitフレームワークのNSPasteboardクラスとNSAttributedStringクラスを使って作成
- 2016-09-24:
stringForType
メソッドとdataForType
メソッドを使用