Swift

[AVURLAsset]AVURLAssetのビデオの全長時間の取得


サンプルコード

サンプルソース(参考)
行番号ソース
001#!/usr/bin/env swift
002//  
003//  
004//
005//
006//
007import Foundation
008import AVFoundation
009import AppKit
010import UniformTypeIdentifiers
011
012let listArguments: [String] = CommandLine.arguments
013
014if listArguments.count == 1 {
015    print("Error: ファイルパスを指定してください")
016    doPrintHelp()
017    exit(1)
018}
019let strArgText: String = listArguments[1]
020let strFilePathStr: NSString = NSString.init(string: strArgText)
021let strFilePath: String = strFilePathStr.standardizingPath
022let urlFilePath: NSURL = NSURL(fileURLWithPath:strFilePath)
023
024
025let avURLAssets: AVURLAsset = AVURLAsset(url:urlFilePath as URL, options: nil)
026let numDuration: Float64 = try await CMTimeGetSeconds(avURLAssets.load(.duration))
027let intHours: Int = Int(numDuration) / 3600
028let intMinutes: Int = (Int(numDuration) % 3600) / 60
029let intSeconds: Int = Int(numDuration) % 60
030let intMilliseconds: Int = Int((numDuration - Double(Int(numDuration))) * 1000)
031
032let strReturnString: String = String(format: "%02d:%02d:%02d.%03d", intHours, intMinutes, intSeconds, intMilliseconds)
033
034print("\(strReturnString)")
035
036func doPrintHelp() {
037print("""
038利用方法: このファイル.swift 引数としてファイルパス
039例文:
040    getDurationAsset.swift /some/dir/some.mp4
041""")
042}
043exit(0)
AppleScriptで生成しました

|

[AVAssetTrack]AVAssetTrackのトラックの全長時間の取得


サンプルコード

サンプルソース(参考)
行番号ソース
001#!/usr/bin/env swift
002//  
003//  
004//
005//
006//
007import Foundation
008import AVFoundation
009import AppKit
010import UniformTypeIdentifiers
011
012let listArguments: [String] = CommandLine.arguments
013
014if listArguments.count == 1 {
015    print("Error: ファイルパスを指定してください")
016    doPrintHelp()
017    exit(1)
018}
019let strArgText: String = listArguments[1]
020let strFilePathStr: NSString = NSString.init(string: strArgText)
021let strFilePath: String = strFilePathStr.standardizingPath
022let urlFilePath: NSURL = NSURL(fileURLWithPath:strFilePath)
023
024
025let avURLAssets: AVURLAsset = AVURLAsset(url:urlFilePath as URL, options: nil)
026let avTrackArray: ([AVAssetTrack]) = try await (avURLAssets.load(.tracks))
027let avVideoTrack: AVAssetTrack! = avTrackArray.first
028let rangeTimeRange: (CMTimeRange) = try await (avVideoTrack.load(.timeRange))
029let timeDuration: (CMTime) = (rangeTimeRange.duration)
030let intTimeScale: (CMTimeScale) = try await (avVideoTrack.load(.naturalTimeScale))
031if intTimeScale != 1000 {
032print("タイムスケールが1000ではないため、処理を終了します。")
033exit(1)
034}
035let numDuration: Double = Double(timeDuration.value) / Double(intTimeScale)
036let intHours: Int = Int(numDuration) / 3600
037let intMinutes: Int = (Int(numDuration) % 3600) / 60
038let intSeconds: Int = Int(numDuration) % 60
039let intMilliseconds: Int = Int((numDuration - Double(Int(numDuration))) * 1000)
040
041let strReturnString: String = String(format: "%02d:%02d:%02d.%03d", intHours, intMinutes, intSeconds, intMilliseconds)
042
043print("\(strReturnString)")
044
045func doPrintHelp() {
046print("""
047利用方法: このファイル.swift 引数としてファイルパス
048例文:
049    getDurationTrack.swift /some/dir/some.mp4
050""")
051}
052exit(0)
AppleScriptで生成しました

|

[swift]ビデオトラックのフレームレートの取得


サンプルコード

サンプルソース(参考)
行番号ソース
001#!/usr/bin/env swift
002//  
003//  
004//
005//
006//
007import Foundation
008import AVFoundation
009import AppKit
010import UniformTypeIdentifiers
011
012let listArguments: [String] = CommandLine.arguments
013
014if listArguments.count == 1 {
015    print("Error: ファイルパスを指定してください")
016    doPrintHelp()
017    exit(1)
018}
019let strArgText: String = listArguments[1]
020let strFilePathStr: NSString = NSString.init(string: strArgText)
021let strFilePath: String = strFilePathStr.standardizingPath
022let urlFilePath: NSURL = NSURL(fileURLWithPath:strFilePath)
023
024let avURLAssets: AVURLAsset = AVURLAsset(url:urlFilePath as URL, options: nil)
025let avTrackArray: ([AVAssetTrack]) = try await (avURLAssets.load(.tracks))
026let avVideoTrack: AVAssetTrack! = avTrackArray.first
027let numFrameRate: (Float) = try await (avVideoTrack.load(.nominalFrameRate))
028let strReturnString: String = String(format: "%.2f fps", numFrameRate)
029
030print("\(strReturnString)")
031
032func doPrintHelp() {
033print("""
034利用方法: このファイル.swift 引数としてファイルパス
035例文:
036    getFrameRate.swift /some/dir/some.mp4
037""")
038}
039
040exit(0)
AppleScriptで生成しました

|

[swift]ビデオトラックの縦横ピクセルサイズの取得


サンプルコード

サンプルソース(参考)
行番号ソース
001#!/usr/bin/env swift
002//  
003//  
004//
005import Foundation
006import AVFoundation
007import AppKit
008import UniformTypeIdentifiers
009
010let listArguments: [String] = CommandLine.arguments
011
012if listArguments.count == 1 {
013    print("Error: ファイルパスを指定してください")
014    doPrintHelp()
015    exit(1)
016}
017let strArgText: String = listArguments[1]
018let strFilePathStr: NSString = NSString.init(string: strArgText)
019let strFilePath: String = strFilePathStr.standardizingPath
020let urlFilePath: NSURL = NSURL(fileURLWithPath:strFilePath)
021
022let avURLAssets: AVURLAsset = AVURLAsset(url:urlFilePath as URL, options: nil)
023let avTrackArray: ([AVAssetTrack]) = try await (avURLAssets.load(.tracks))
024let avVideoTrack: AVAssetTrack! = avTrackArray.first
025let sizeVideoSize: (CGSize) = try await (avVideoTrack.load(.naturalSize))
026let intWidth: Int = Int(sizeVideoSize.width)
027let intHeight: Int = Int(sizeVideoSize.width)
028
029let strReturnString: String = ("\(intWidth)x\(intHeight)")
030
031print("\(strReturnString)")
032
033func doPrintHelp() {
034print("""
035利用方法: このファイル.swift 引数としてファイルパス
036例文:
037    getNaturalSize.swift /some/dir/some.mp4
038""")
039}
040
041exit(0)
AppleScriptで生成しました

|

[swift]A4縦型PDF文書をA4横型PDFに2IN1 2upで印刷PDFファイルにする(途中)


サンプルコード

サンプルソース(参考)
行番号ソース
001#!/usr/bin/env swift
002// 各ページ間にドロップシャドウが出てしますう
003//--+----1----+----2----+-----3----+----4----+----5----+----6----+----7
004import Foundation
005import AppKit
006import PDFKit
007import Cocoa
008
009let rectA4H: NSRect = NSRect(x: 0, y: 0, width: 841.89, height: 595.28)
010let sizeA4H: NSSize = NSSize(width:841.89, height:595.28)
011let insetsZero: NSEdgeInsets = NSEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
012
013
014let appFileManager: FileManager = FileManager.default
015let urlDesktop: URL = appFileManager.urls(for: .desktopDirectory, in: .userDomainMask).first!
016//読み込むPDF A4サイズの縦型PDF 2ページ
017let urlReadFile: URL = urlDesktop.appendingPathComponent("A4P.pdf")
018//保存先PDF
019let urlSaveFile: URL = urlDesktop.appendingPathComponent("Save.pdf")
020//PDF読み込み
021guard let pdfDocument: PDFDocument = PDFDocument(url: urlReadFile) else {
022print("PDFの読み込みに失敗しました")
023exit(0)}
024
025// PDFViewを設定
026let pdfView: PDFView = PDFView(frame: rectA4H)
027pdfView.document = pdfDocument
028
029if let setPdfPage: PDFPage = pdfDocument.page(at :0){
030pdfView.go(to: setPdfPage)
031}
032pdfView.displayMode = .twoUpContinuous
033pdfView.displayDirection = .vertical
034pdfView.displaysAsBook = false 
035pdfView.displaysRTL = true
036pdfView.autoScales = true
037pdfView.maxScaleFactor = 0.71
038pdfView.minScaleFactor = 0.70714
039pdfView.displayBox = .cropBox
040pdfView.displaysPageBreaks = false
041pdfView.pageBreakMargins = insetsZero
042pdfView.pageShadowsEnabled = false
043pdfView.autoresizesSubviews = false
044pdfView.autoresizingMask = [.width, .height, .minXMargin, .minYMargin]
045pdfView.translatesAutoresizingMaskIntoConstraints = true
046//レイヤー
047pdfView.wantsLayer = true
048if let caLayer: CALayer = pdfView.layer {
049  caLayer.shadowOpacity = 0 
050  caLayer.shadowOffset = CGSize(width: -5, height: -5)
051  caLayer.shadowRadius = 0 
052}
053//スクローラー
054if let scrollView: NSScrollView = pdfView.subviews.first(where: { $0 is NSScrollView }) as? NSScrollView {
055scrollView.hasHorizontalScroller = false
056scrollView.hasVerticalScroller = false
057scrollView.hasHorizontalRuler = false
058scrollView.hasVerticalRuler = false
059scrollView.rulersVisible = false
060scrollView.autohidesScrollers = true
061scrollView.borderType = .noBorder
062scrollView.drawsBackground = false
063scrollView.clipsToBounds = false
064scrollView.scrollerInsets = insetsZero
065scrollView.scrollerStyle = .overlay 
066scrollView.wantsLayer = true
067//スクローラーのレイヤー
068if let caScLayer: CALayer = pdfView.layer {
069  caScLayer.shadowOpacity = 0 
070  caScLayer.shadowOffset = CGSize(width: -5, height: -5)
071  caScLayer.shadowRadius = 0 
072}
073}
074//SUBVIEW
075for itemView: NSView in pdfView.subviews {
076  if let itemCaLayer: CALayer = itemView.layer {
077    itemCaLayer.shadowOpacity = 0
078    itemCaLayer.shadowOffset = CGSize.zero
079    itemCaLayer.shadowRadius = 0
080  }
081}
082
083
084//NSPrintInfo
085let printerInfoDictionary: NSMutableDictionary = NSMutableDictionary()
086printerInfoDictionary.setObject(true, forKey: NSPrintInfo.AttributeKey.allPages.rawValue as NSCopying)
087let printInfo: NSPrintInfo = NSPrintInfo(dictionary: printerInfoDictionary as! [NSPrintInfo.AttributeKey: Any])
088//let printInfo: NSPrintInfo = NSPrintInfo.shared
089printInfo.orientation = .portrait
090printInfo.horizontalPagination = .fit
091printInfo.verticalPagination = .fit
092printInfo.paperSize = sizeA4H
093printInfo.isHorizontallyCentered = true
094printInfo.isVerticallyCentered = true
095printInfo.leftMargin = 0.0
096printInfo.rightMargin = 0.0
097printInfo.topMargin = 0.0
098printInfo.bottomMargin = 0.0
099
100//NSPrintOperation
101let pdfOperation: NSPrintOperation = NSPrintOperation.pdfOperation(with: pdfView, inside: rectA4H, toPath: urlSaveFile.path, printInfo: printInfo)
102pdfOperation.showsPrintPanel = false
103pdfOperation.showsProgressPanel = false
104if pdfOperation.run() {
105    print("PDFが正常に保存されました")
106} else {
107    print("PDFの保存に失敗しました")
108}
109
110
AppleScriptで生成しました

|

[swift]DatePicker(日付選択画面)の呼び出し




ダウンロード - datepicker.zip



20240722030422_1100x790


AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#! /usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003# 日付ピッカーswift
004# 初回起動時に時間がかかる
005# swiftファイルが必要です
006(*
007こちらからダウンロードして試してください
008https://quicktimer.cocolog-nifty.com/icefloe/files/datepicker.zip
009*)
010# com.cocolog-nifty.quicktimer.icefloe
011----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
012use AppleScript version "2.8"
013use framework "Foundation"
014use framework "AppKit"
015use scripting additions
016
017#このファイルのパス
018set aliasPathToMe to (path to me) as alias
019tell application "Finder"
020  #コンテナ
021  set aliasContainerDirPath to (container of aliasPathToMe) as alias
022  #Swift格納先
023  set aliasBinDirPath to (folder "bin" of folder aliasContainerDirPath) as alias
024  #Swiftパス
025  set aliasSwiftPath to (file "launchDatePicker.swift" of folder aliasBinDirPath) as alias
026end tell
027#パス
028set strSwiftPath to (POSIX path of aliasSwiftPath) as text
029#コマンド整形 zsh指定
030set strCommandText to ("/bin/zsh -c '" & strSwiftPath & "'") as text
031log strCommandText
032try
033  #コマンド実行
034  set strResponse to (do shell script strCommandText) as text
035end try
036#戻り値がfalse=日付を選択しなかった場合
037#戻り値はbool値なんだけどAs textしているのでTextで比較
038if strResponse is "false" then
039#戻り値falseの場合は今日の日付を入れる
040  set strResponse to doGetDateNo("yyyyMMDD")
041end if
042
043
044##############################
045#####ダイアログ
046##############################
047tell current application
048  set strName to name as text
049end tell
050if strName is "osascript" then
051  tell application "Finder"
052    activate
053  end tell
054else
055  tell current application
056    activate
057  end tell
058end if
059set aliasIconPath to (POSIX file "/System/Applications/Clock.app/Contents/Resources/AppIcon.icns") as alias
060try
061  set recordResult to (display dialog strResponse with title "戻り値です" default answer strResponse buttons {"クリップボードにコピー", "終了", "再実行"} default button "再実行" cancel button "終了" giving up after 20 with icon aliasIconPath without hidden answer) as record
062on error
063  return "エラーしました"
064end try
065if (gave up of recordResult) is true then
066  return "時間切れです"
067end if
068##############################
069#####自分自身を再実行
070##############################
071if button returned of recordResult is "再実行" then
072  tell application "Finder"
073    set aliasPathToMe to (path to me) as alias
074  end tell
075  run script aliasPathToMe with parameters "再実行"
076end if
077##############################
078#####値のコピー
079##############################
080if button returned of recordResult is "クリップボードにコピー" then
081  try
082    set strText to text returned of recordResult as text
083    ####ペーストボード宣言
084    set appPasteboard to refMe's NSPasteboard's generalPasteboard()
085    set ocidText to (refMe's NSString's stringWithString:(strText))
086    appPasteboard's clearContents()
087    appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
088  on error
089    tell application "Finder"
090      set the clipboard to strText as text
091    end tell
092  end try
093end if
094
095
096return 0
097
098
099
100##############################
101### 今の日付日間 テキスト
102##############################
103to doGetDateNo(argDateFormat)
104  ####日付情報の取得
105  set ocidDate to current application's NSDate's |date|()
106  ###日付のフォーマットを定義
107  set ocidNSDateFormatter to current application's NSDateFormatter's alloc()'s init()
108  set ocidLocale to current application's NSLocale's localeWithLocaleIdentifier:("ja_JP_POSIX")
109  ocidNSDateFormatter's setLocale:(ocidLocale)
110  set ocidTimeZone to current application's NSTimeZone's alloc()'s initWithName:("Asia/Tokyo")
111  ocidNSDateFormatter's setTimeZone:(ocidTimeZone)
112  ocidNSDateFormatter's setDateFormat:(argDateFormat)
113  set ocidDateAndTime to ocidNSDateFormatter's stringFromDate:(ocidDate)
114  set strDateAndTime to ocidDateAndTime as text
115  return strDateAndTime
116end doGetDateNo
AppleScriptで生成しました

|

[swift]AppleScriptから透過指定のできるカラーピッカーを呼び出す(CMYK対応)

ダウンロード - openswiftcolorpicker.zip


AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#! /usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003# RGBの場合カラーはキャリブレートされた値になります
004# そのためPantone等指定された値とは異なりますが
005# デバイスのモニター設定の値が反映されています
006# com.cocolog-nifty.quicktimer.icefloe
007----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
008use AppleScript version "2.8"
009use framework "Foundation"
010use framework "AppKit"
011use scripting additions
012
013#このファイルのパス
014set aliasPathToMe to (path to me) as alias
015tell application "Finder"
016  #コンテナ
017  set aliasContainerDirPath to (container of aliasPathToMe) as alias
018  #Swift格納先
019  set aliasBinDirPath to (folder "bin" of folder aliasContainerDirPath) as alias
020  #Swiftパス
021  set aliasSwiftPath to (file "launchColorPicker.swift" of folder aliasBinDirPath) as alias
022end tell
023#パス
024set strSwiftPath to (POSIX path of aliasSwiftPath) as text
025#コマンド整形 zsh指定
026set strCommandText to ("/bin/zsh -c '" & strSwiftPath & "'") as text
027log strCommandText
028try
029  #コマンド実行
030  set strResponse to (do shell script strCommandText) as text
031end try
032#スペース区切りでリスト化
033set strDelim to AppleScript's text item delimiters
034set AppleScript's text item delimiters to " "
035set listResponse to every text item of strResponse
036set AppleScript's text item delimiters to strDelim
037#数えて
038set numCntList to (count of listResponse) as integer
039##単純にカラーの数で取得
040if (strResponse) contains "Gray" then
041  set numK to (item (numCntList - 1) of listResponse) as number
042  set numA to (item (numCntList) of listResponse) as number
043  set numKp to (numK * 100) as integer
044  set numAp to (numA * 100) as integer
045  set strMes to ("Gs: " & numK & "\t" & numA & "") as text
046  set strResponseText to ("0\t0\t0\t" & numKp & "\t") as text
047  
048else if (strResponse) contains "CMYK" then
049  set numC to (item (numCntList - 4) of listResponse) as number
050  set numM to (item (numCntList - 3) of listResponse) as number
051  set numY to (item (numCntList - 2) of listResponse) as number
052  set numK to (item (numCntList - 1) of listResponse) as number
053  set numA to (item (numCntList) of listResponse) as number
054  set numCp to (numC * 100) as integer
055  set numMp to (numM * 100) as integer
056  set numYp to (numY * 100) as integer
057  set numKp to (numK * 100) as integer
058  set numAp to (numA * 100) as integer
059  set strMes to ("CMYK値: " & numC & "\t" & numM & "\t" & numY & "\t" & numK & "\t" & numA & "") as text
060  set strResponseText to ("" & numCp & "\t" & numMp & "\t" & numYp & "\t" & numKp & "\t") as text
061  
062else
063  ##それ以外はまぁRGB系でしょう
064  set numR to (item (numCntList - 3) of listResponse) as number
065  set numG to (item (numCntList - 2) of listResponse) as number
066  set numB to (item (numCntList - 1) of listResponse) as number
067  set numA to (item (numCntList) of listResponse) as number
068  set numR8 to (numR * 255) as integer
069  set numG8 to (numG * 255) as integer
070  set numB8 to (numB * 255) as integer
071  set numA8 to (numA * 255) as integer
072  set strMes to ("RGB値: " & numR & "\t" & numG & "\t" & numB & "\t" & numA & "") as text
073  set strResponseText to ("" & numR8 & "\t" & numG8 & "\t" & numB8 & "\t") as text
074end if
075
076
077##############################
078#####ダイアログ
079##############################
080tell current application
081  set strName to name as text
082end tell
083if strName is "osascript" then
084  tell application "Finder"
085    activate
086  end tell
087else
088  tell current application
089    activate
090  end tell
091end if
092set aliasIconPath to (POSIX file "/System/Applications/Utilities/Digital Color Meter.app/Contents/Resources/AppIcon.icns") as alias
093try
094  set recordResult to (display dialog strMes with title "戻り値です" default answer strResponseText buttons {"クリップボードにコピー", "終了", "再実行"} default button "再実行" cancel button "終了" giving up after 20 with icon aliasIconPath without hidden answer) as record
095on error
096  return "エラーしました"
097end try
098if (gave up of recordResult) is true then
099  return "時間切れです"
100end if
101##############################
102#####自分自身を再実行
103##############################
104if button returned of recordResult is "再実行" then
105  tell application "Finder"
106    set aliasPathToMe to (path to me) as alias
107  end tell
108  run script aliasPathToMe with parameters "再実行"
109end if
110##############################
111#####値のコピー
112##############################
113if button returned of recordResult is "クリップボードにコピー" then
114  try
115    set strText to text returned of recordResult as text
116    ####ペーストボード宣言
117    set appPasteboard to refMe's NSPasteboard's generalPasteboard()
118    set ocidText to (refMe's NSString's stringWithString:(strText))
119    appPasteboard's clearContents()
120    appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
121  on error
122    tell application "Finder"
123      set the clipboard to strText as text
124    end tell
125  end try
126end if
127
128
129return 0
AppleScriptで生成しました

|

[swift]AppleScriptから透過指定のできるカラーピッカーを呼び出す(CMYK対応)




サンプルファイルが入っています
ダウンロードして試してみてください

ダウンロード - openswiftcolorpicker.zip




RGB値はキャリブレートされた値になるケースがありますので
ニアな値だと思った方が良い場合もあります

AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#! /usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004# com.cocolog-nifty.quicktimer.icefloe
005----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
006use AppleScript version "2.8"
007use scripting additions
008
009set aliasPathToMe to (path to me) as alias
010tell application "Finder"
011  set aliasContainerDirPath to (container of aliasPathToMe) as alias
012  set aliasBinDirPath to (folder "bin" of folder aliasContainerDirPath) as alias
013  set aliasSwiftPath to (file "launchColorPicker.swift" of folder aliasBinDirPath) as alias
014end tell
015set strSwiftPath to (POSIX path of aliasSwiftPath) as text
016set strCommandText to ("/bin/zsh -c '" & strSwiftPath & "'") as text
017try
018  set strResponse to (do shell script strCommandText) as text
019end try
020#スペース区切りでリスト化
021set strDelim to AppleScript's text item delimiters
022set AppleScript's text item delimiters to " "
023set listResponse to every text item of strResponse
024set AppleScript's text item delimiters to strDelim
025#数えて
026set numCntList to (count of listResponse) as integer
027##単純にカラーの数で取得
028if (strResponse) contains "RGB" then
029  set numR to (item (numCntList - 3) of listResponse) as number
030  set numG to (item (numCntList - 2) of listResponse) as number
031  set numB to (item (numCntList - 1) of listResponse) as number
032  set numA to (item (numCntList) of listResponse) as number
033  log numR
034  log numG
035  log numB
036  log numA
037else if (strResponse) contains "Adobe" then
038  #モニターカラープロファイルがわかっている場合はこうゆうのもあり
039  set numR to (item (numCntList - 3) of listResponse) as number
040  set numG to (item (numCntList - 2) of listResponse) as number
041  set numB to (item (numCntList - 1) of listResponse) as number
042  set numA to (item (numCntList) of listResponse) as number
043  log numR
044  log numG
045  log numB
046  log numA
047else if (strResponse) contains "P3" then
048  #モニターカラープロファイルがわかっている場合はこうゆうのもあり
049  set numR to (item (numCntList - 3) of listResponse) as number
050  set numG to (item (numCntList - 2) of listResponse) as number
051  set numB to (item (numCntList - 1) of listResponse) as number
052  set numA to (item (numCntList) of listResponse) as number
053  log numR
054  log numG
055  log numB
056  log numA
057else if (strResponse) contains "Gray" then
058  set numK to (item (numCntList - 1) of listResponse) as number
059  set numA to (item (numCntList) of listResponse) as number
060  log numK
061  log numA
062  
063else if (strResponse) contains "CMYK" then
064  set numC to (item (numCntList - 4) of listResponse) as number
065  set numM to (item (numCntList - 3) of listResponse) as number
066  set numY to (item (numCntList - 2) of listResponse) as number
067  set numK to (item (numCntList - 1) of listResponse) as number
068  set numA to (item (numCntList) of listResponse) as number
069  log numC
070  log numM
071  log numY
072  log numK
073  log numA
074else
075  ##それ以外はRGBにしておく
076  set numR to (item (numCntList - 3) of listResponse) as number
077  set numG to (item (numCntList - 2) of listResponse) as number
078  set numB to (item (numCntList - 1) of listResponse) as number
079  set numA to (item (numCntList) of listResponse) as number
080  log numR
081  log numG
082  log numB
083  log numA
084end if
AppleScriptで生成しました

|

その他のカテゴリー

Accessibility Acrobat Acrobat 2020 Acrobat AddOn Acrobat Annotation Acrobat ARMDC Acrobat AV2 Acrobat BookMark Acrobat Classic Acrobat DC Acrobat Dialog Acrobat Distiller Acrobat Form Acrobat JS Acrobat Manifest Acrobat Menu Acrobat Open Acrobat Plugin Acrobat Preferences Acrobat Preflight Acrobat python Acrobat Reader Acrobat SCA Acrobat SCA Updater Acrobat Sequ Acrobat Sign Acrobat Stamps Acrobat Watermark Acrobat Windows Acrobat Windows Reader Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Mobileconfig Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin Support Admin System Information Admin Tools Admin Users Admin Volumes Adobe Adobe FDKO Adobe RemoteUpdateManager AppKit Apple AppleScript AppleScript do shell script AppleScript List AppleScript ObjC AppleScript Osax AppleScript PDF AppleScript Pictures AppleScript record AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript System Events AppleScript System Events Plist AppleScript Video Applications AppStore Archive Attributes Automator BackUp Barcode Barcode QR Barcode QR Decode Bash Basic Basic Path Bluetooth BOX Browser Calendar CD/DVD Choose Chrome CIImage CityCode CloudStorage Color com.apple.LaunchServices.OpenWith Console Contacts CotEditor CURL current application Date&Time delimiters Desktop Device Diff Disk Dock DropBox Droplet eMail Encode % Encode Decode Encode UTF8 Error EXIFData ffmpeg File Finder Firefox Folder FolderAction Fonts GIF github Guide HTML HTML Entity Icon Illustrator Image Events Image2PDF ImageOptim iPhone iWork Javascript Jedit Json Label Leading Zero List locationd LRC lsappinfo LSSharedFileList m3u8 Mail MakePDF Map Math Media Media AVAsset Media AVconvert Media AVFoundation Media AVURLAsset Media Movie Media Music Memo Messages Microsoft Microsoft Edge Microsoft Excel Mouse Music NetWork Notes NSArray NSArray Sort NSBezierPath NSBitmapImageRep NSBundle NSCFBoolean NSCharacterSet NSColor NSColorList NSData NSDecimalNumber NSDictionary NSError NSEvent NSFileAttributes NSFileManager NSFileManager enumeratorAtURL NSFont NSFontManager NSGraphicsContext NSImage NSIndex NSKeyedArchiver NSKeyedUnarchiver NSLocale NSMutableArray NSMutableDictionary NSMutableString NSNotFound NSNumber NSOpenPanel NSPasteboard NSpoint NSPredicate NSPrintOperation NSRange NSRect NSRegularExpression NSRunningApplication NSScreen NSSize NSString NSString stringByApplyingTransform NSStringCompareOptions NSTask NSTimeZone NSURL NSURL File NSURLBookmark NSURLComponents NSURLResourceKey NSURLSession NSUserDefaults NSUUID NSView NSWorkspace Numbers OAuth OneDrive PDF PDFAnnotation PDFAnnotationWidget PDFContext PDFDisplayBox PDFDocumentPermissions PDFImageRep PDFKit PDFnUP PDFOutline perl Photoshop PlistBuddy pluginkit postalcode PostScript prefPane Preview Python QuickLook QuickTime ReadMe Regular Expression Reminders ReName Repeat RTF Safari SaveFile ScreenCapture ScreenSaver SF Symbols character id SF Symbols Entity sips Skype Slack Sound Spotlight sqlite SRT StandardAdditions Swift System Settings TCC TemporaryItems Terminal Text Text CSV Text MD Text TSV TextEdit Tools Translate Trash Twitter Typography UI Unit Conversion UTType valueForKeyPath Video VisionKit Visual Studio Code Wacom webarchive webp Wifi Windows XML XML EPUB XML OPML XML Plist XML RSS XML savedSearch XML SVG XML TTML XML webloc XML XMP YouTube zoom