2017-02-09 8 views

答えて

2

このお試しください:純粋のAppleScriptでクリップボードに画像をコピーするには

tell application "Finder" to set theFiles to sort (get files of folder "Screenshots" of desktop) by creation date 
set the clipboard to last item of theFiles as alias 

を面倒です。 AppleScriptObjC:

use framework "Foundation" 

tell application "Finder" to set theFiles to sort (get files of folder "Screenshots" of desktop) by creation date 
set imageFile to last item of theFiles as text 
set theData to current application's NSData's dataWithContentsOfFile:(POSIX path of imageFile) 
set pasteBoard to current application's NSPasteboard's generalPasteboard() 
pasteBoard's clearContents() 
pasteBoard's setData:theData forType:(current application's NSPasteboardTypeTIFF) 
+0

私のクリップボードは何も消去されていないようです。しかし、画像はクリップボードのように設定されていません。 – unska

+0

オススメして申し訳ありません! – unska

+0

ファイルの**コンテンツ**ではなく、最新のファイル*を(クリップボードに)コピーしました。イメージをコピーするには、AppleScriptObjC(Cocoa)から少しの助けが必要です。私は答えを更新しました。 – vadian

関連する問題