« [Maps]Mapの場所をChromeで開き直す | トップページ | [YouTube Api] oEmbed JSONを利用して各種値を取得する »

[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

*)

|

« [Maps]Mapの場所をChromeで開き直す | トップページ | [YouTube Api] oEmbed JSONを利用して各種値を取得する »

AppleScript NSPasteboard」カテゴリの記事