[clipboard] NSPasteboard
#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions
set strText to "AAAAA"
tell application "Finder"
set the clipboard to strText as text
end tell
tell application "Finder"
set strText to the clipboard as text
end tell
#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions
property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
set strText to "AAAAA"
###NSStringに変換
set ocidText to objNSString's stringWithString:(strText)
###クリップボードを定義
set objPasteboard to objMe's NSPasteboard's generalPasteboard()
###クリップボードを初期化
objPasteboard's clearContents()
###クリップボードに書き込み
objPasteboard's writeObjects:{ocidText}
###クリップボードの内容をtheDataに格納
set ocidPbData to objPasteboard's dataForType:(objMe's NSPasteboardTypeString)
#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions
property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
set strText to "AAAAA"
####テキストをNSStringに
set ocidText to objNSString's stringWithString:(strText)
####ペーストボードを定義
set objPasteboard to objMe's NSPasteboard's generalPasteboard()
####ペーストボード初期化
objPasteboard's clearContents()
####テキストを格納
objPasteboard's writeObjects:{objMe's NSAttributedString's alloc()'s initWithString:ocidText}
####ペーストボードの内容をテキストで確定
set ocidPbData to objPasteboard's dataForType:(objMe's NSPasteboardTypeString)
(*
NSPasteboardTypeURL
NSPasteboardTypeColor
NSPasteboardTypeFileURL
NSPasteboardTypeFont
NSPasteboardTypeHTML
NSPasteboardTypeMultipleTextSelection
NSPasteboardTypePDF
NSPasteboardTypePNG
NSPasteboardTypeRTF
NSPasteboardTypeRTFD
NSPasteboardTypeRuler
NSPasteboardTypeSound
NSPasteboardTypeString
NSPasteboardTypeTabularText
NSPasteboardTypeTextFinderOptions
NSPasteboardTypeTIFF
NSFindPanelSearchOptionsPboardType
NSFileContentsPboardType
*)
| 固定リンク
「NSPasteboard」カテゴリの記事
- [NSOpenPanel]対象のファイルのUTIを限定する『開く』パネル(2024.12.07)
- クリップボード内のテキストに改行を<br />に変更して戻す 修正(2024.11.15)
- ペーストボードの内容の種類の確認(2024.10.06)
- [NSPasteboard]ペーストボードからテキストの取り出し(修正)(2024.07.02)
- 画像データをクリップボードにPDF形式で入れる(2024.06.28)