Menu

Skip to content
AppleScriptの穴
  • Home
  • Products
  • Books
  • Docs
  • Events
  • Forum
  • About This Blog
  • License
  • 仕事依頼

AppleScriptの穴

Useful & Practical AppleScript archive. Click '★Click Here to Open This Script' Link to download each AppleScript

Numbersで選択範囲のセルのデータを取得して重複データを抽出

Posted on 6月 7, 2018 by Takaaki Naganoya

Numbersの表データの選択範囲のセルのデータを取得し、重複データがあれば重複データのみ表示するAppleScriptです。

# NumbersというApple社製の表計算アプリケーションを操作する話であって、宝くじの話ではありません。また、本BlogはScriptでMac上のアプリケーションやOS内のサービスを呼び出して処理する話を紹介しているものであって、単に画面上から削除する方法を紹介するものではありません。また、データのユニーク化処理ができないわけがありません。とっくの昔に書いています。

macOS標準装備のScript Menuに入れて便利に使っています。Numbers上の選択範囲内に重複データがあれば、ダイアログでデータを表示します。

AppleScript名:Numbersで選択範囲のセルのデータを取得して重複データを抽出
— Created 2018-01-13 by Takaaki Naganoya
— Modified 2018-06-06 by Takaaki Naganoya
— 2018 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

property NSCountedSet : a reference to current application’s NSCountedSet

script spd
  property uniqList : {}
end script

set (uniqList of spd) to {}

tell application "Numbers"
  tell front document
    tell active sheet
      try
        set theTable to first table whose class of selection range is range
      on error
        display notification "Numbers: There is no selection"
        
return
      end try
      
      
tell theTable
        set (uniqList of spd) to value of cells of selection range
      end tell
    end tell
  end tell
end tell

if (uniqList of spd) = {} then
  display notification "Numbers: There is no selection"
  
return
end if

set aRes to returnDuplicatesOnly(uniqList of spd) of me
if aRes is not equal to {} then
  choose from list aRes with prompt "Duplicated Data:"
else
  display notification "No Duplicated Data"
end if

–1D Listから重複項目のみを抽出して返す
on returnDuplicatesOnly(aList as list)
  set aSet to NSCountedSet’s alloc()’s initWithArray:aList
  
set bList to (aSet’s allObjects()) as list
  
  
set dupList to {}
  
repeat with i in bList
    set aRes to (aSet’s countForObject:i)
    
if aRes > 1 then
      set the end of dupList to (contents of i)
    end if
  end repeat
  
  
return dupList
end returnDuplicatesOnly

★Click Here to Open This Script 

Posted in list | Tagged 10.11savvy 10.12savvy 10.13savvy Numbers | Leave a comment

数値演算ライブラリ「calcLibAS」

Posted on 6月 7, 2018 by Takaaki Naganoya

数値演算の関数を35個提供するAppleScript Librariesです。

Cocoa Frameworkを呼び出して計算するよりも262倍、OSAXを呼び出して計算するよりも760倍遅いのですが、関数の数はたいへんに多いです。

スピードが遅い上に数百回連続で呼び出すとScript Editorがクラッシュする傾向があります(本当)。

run scriptコマンドでJavaScript(JXA)を呼び出して計算しているのですが、run script経由でJavaScript(JXA)を呼び出すのがこんなに危険だと思わなかったので、いっそJavaScript Coreを呼び出して実行してみてもよいのかもしれません(それでも高速にはならなさそうで)。

最初は「calcLib」というライブラリをJXAで試しに書いて、AppleScriptから呼び出せないかどうか実験してみたのですが、useコマンドでJXAのライブラリを指定したら「OSA言語が違うので呼び出せないよ」といったエラーになりました(AppleScript用語辞書を用意すれば複数のOSA言語間から利用できるのだと思います、まだやっていませんけれども)。

そのあとで作ったので「calcLibAS」という名前に。

AppleScript名:atan2をライブラリ呼び出しで計算する
— Created 2018-06-06 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use mLib : script "calcLibAS"

set aRes to calcAtan2(10, 20) of mLib

★Click Here to Open This Script 

本ライブラリは~/Library/Script Librariesフォルダなどに入れて呼び出してください。

AppleScript名:calcLibAS
— Created 2018-06-06 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.5"
use scripting additions
use framework "Foundation"

set a01Res to calcAbs(-10) of me –> 10
set a02Res to calcAcos(-1) of me –> 3.14159265359
set a03Res to calcAcosh(10) of me –> 2.993222846126
set a04Res to calcAsin(-1) of me –> -1.570796326795
set a05Res to calcAsinh(10) of me –> 2.998222950298
set a06Res to calcAtan(10) of me –> 1.471127674304
set a07Res to calcAtan2(10, 20) of me –> 0.463647609001
set a08Res to calcAtanh(0.5) of me –> 0.549306144334
set a09Res to calcCbrt(3) of me –> 1.442249570307
set a10Res to calcCeil(0.95) of me –> 1
set a11Res to calcClz32(1) of me –> 31
set a12Res to calcCos(1) of me –> 0.540302305868
set a13Res to calcCosh(1) of me –> 1.543080634815
set a14Res to calcExp(1) of me –> 2.718281828459
set a15Res to calcExpm1(-1) of me –> -0.632120558829
set a16Res to calcFloor(45.95) of me –> 45
set a17Res to calcFround(1.337) of me –> 1.337000012398
set a18Res to calcHypot({3, 4, 5}) of me –> 7.071067811865
set a19Res to calcImul(2, 5) of me –> 10
set a20Res to calcLog(10) of me –> 2.302585092994
set a21Res to calcLog10(2) of me –> 0.301029995664
set a22Res to calcLog1p(1) of me –> 0.69314718056
set a23Res to calcLog2(3) of me –> 1.584962500721
set a24Res to calcMax({1, 2, 3, 4, 6, 2, 10}) of me –> 10
set a25Res to calcMin({1, 2, 3, 4, 6, 2, 10, 0}) of me –> 0
set a26Res to calcPow(7, 2) of me
set a27Res to calcRandom() of me
set a28Res to calcRound(5.95) of me
set a29Res to calcSign(0) of me –> -1/0/1
set a30Res to calcSin(pi / 2) of me –> 1
set a31Res to calcSinh(1) of me –> 1.175201193644
set a32Res to calcSqrt(2) of me –> 1.414213562373
set a33Res to calcTan(30) of me –> -6.405331196646
set a34Res to calcTanh(10) of me –> 0.999999995878
set a35Res to calcTrunc(13.37) of me –> 13

–数値の絶対値を返す
on calcAbs(aNum as string)
  set aStr to "Math.abs(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcAbs

–アークコサインをラジアン単位で返す
on calcAcos(aNum as string)
  set aStr to "Math.acos(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcAcos

–ハイパーボリックアークコサインを返す
on calcAcosh(aNum as string)
  set aStr to "Math.acosh(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcAcosh

–アークサインをラジアン単位で返す
on calcAsin(aNum as string)
  set aStr to "Math.asin(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcAsin

–ハイパーボリックアークサインを返す
on calcAsinh(aNum as string)
  set aStr to "Math.asinh(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcAsinh

–アークタンジェントをラジアン単位で返す
on calcAtan(aNum as string)
  set aStr to "Math.atan(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcAtan

–アークタンジェントを返す
on calcAtan2(aNum as string, bNum as string)
  set aStr to "Math.atan2(" & aNum & ", " & bNum & ")"
  
return (run script aStr in "JavaScript")
end calcAtan2

–ハイパーボリックアークタンジェントを返す
on calcAtanh(aNum as string)
  set aStr to "Math.atanh(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcAtanh

–引数として与えた数の立方根を返す
on calcCbrt(aNum as string)
  set aStr to "Math.cbrt(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcCbrt

–引数として与えた数以上の最小の整数を返す
on calcCeil(aNum as string)
  set aStr to "Math.ceil(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcCeil

–引数として与えた数以上の最小の整数を返す
on calcClz32(aNum as string)
  set aStr to "Math.clz32(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcClz32

–引数として与えた数のコサインを返す
on calcCos(aNum as string)
  set aStr to "Math.cos(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcCos

–引数として与えた数のハイパーボリックコサインを返す
on calcCosh(aNum as string)
  set aStr to "Math.cosh(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcCosh

–Ex を返す。ここでの x は引数、E は、自然対数の底であるネイピア数(オイラー数)
on calcExp(aNum as string)
  set aStr to "Math.exp(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcExp

–ex – 1 を返す。x は引数で、e は自然対数の底
on calcExpm1(aNum as string)
  set aStr to "Math.expm1(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcExpm1

–引数として与えた数以下の最大の整数を返す
on calcFloor(aNum as string)
  set aStr to "Math.floor(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcFloor

–引数として与えた数の最も近い単精度 floatを返す
on calcFround(aNum as string)
  set aStr to "Math.fround(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcFround

–引数の二乗和の平方根を返す
on calcHypot(aList as list)
  set bStr to retArrowText(aList, ", ") of me
  
set aStr to "Math.hypot(" & bStr & ")"
  
return (run script aStr in "JavaScript")
end calcHypot

— 2 つの引数をとり、C 言語の様な 32 ビット乗算の結果を返す
on calcImul(aNum as string, bNum as string)
  set aStr to "Math.imul(" & aNum & ", " & bNum & ")"
  
return (run script aStr in "JavaScript")
end calcImul

— 引数として与えた数の自然対数 (底は e) を返す
on calcLog(aNum as string)
  set aStr to "Math.log(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcLog

— 引数として与えた数に対して、10を底とする対数を返す
on calcLog10(aNum as string)
  set aStr to "Math.log10(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcLog10

— 引数として与えた数と 1 の合計の自然対数(底 e)を返す
on calcLog1p(aNum as string)
  set aStr to "Math.log1p(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcLog1p

— 引数として与えた数の2を底とする対数を返す
on calcLog2(aNum as string)
  set aStr to "Math.log2(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcLog2

–引数として与えた複数の数の中で最大の数を返す
on calcMax(aList as list)
  set bStr to retArrowText(aList, ", ") of me
  
set aStr to "Math.max(" & bStr & ")"
  
return (run script aStr in "JavaScript")
end calcMax

–引数として与えた複数の数の中で最小の数を返す
on calcMin(aList as list)
  set bStr to retArrowText(aList, ", ") of me
  
set aStr to "Math.min(" & bStr & ")"
  
return (run script aStr in "JavaScript")
end calcMin

–引数として与えた複数の数の中で最小の数を返す
on calcPow(aNum as string, bNum as string)
  set aStr to "Math.pow(" & aNum & ", " & bNum & ")"
  
return (run script aStr in "JavaScript")
end calcPow

–(0以上、1未満)の範囲で浮動小数点の擬似乱数を返す
on calcRandom()
  set aStr to "Math.random()"
  
return (run script aStr in "JavaScript")
end calcRandom

–引数として与えた数を四捨五入して、もっとも近似の整数を返す
on calcRound(aNum as string)
  set aStr to "Math.round(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcRound

–引数として与えた数が正、負、0 のどれであるか示す符号を返す
on calcSign(aNum as string)
  set aStr to "Math.sign(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcSign

–引数として与えた数のサイン(正弦)を返す
on calcSin(aNum as string)
  set aStr to "Math.sin(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcSin

–引数として与えた数のハイパーボリックサインを返す
on calcSinh(aNum as string)
  set aStr to "Math.sinh(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcSinh

–引数として与えた数の平方根を返す
on calcSqrt(aNum as string)
  set aStr to "Math.sqrt(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcSqrt

–引数として与えた数のタンジェントを返す
on calcTan(aNum as string)
  set aStr to "Math.tan(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcTan

–引数として与えた数のハイパーボリックタンジェントを返す
on calcTanh(aNum as string)
  set aStr to "Math.tanh(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcTanh

–引数として与えた数の小数部の桁を取り除いて整数部を返す
on calcTrunc(aNum as string)
  set aStr to "Math.trunc(" & aNum & ")"
  
return (run script aStr in "JavaScript")
end calcTrunc

–Sub Routines

–リストを指定デリミタをはさんでテキスト化
on retArrowText(aList, aDelim) –自分のASでよく使うハンドラ名称なので、同じものを用意
  set anArray to current application’s NSArray’s arrayWithArray:aList
  
set aRes to anArray’s componentsJoinedByString:aDelim
  
return aRes as text
end retArrowText

(*
–run scriptコマンドに問題が出た場合にはJavaScriptCoreなどで実行してもよさそう
on run script aStr in osaLangName
  display dialog aStr
end run script
*)

★Click Here to Open This Script 

Posted in JXA Number | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

Tag CloudっぽいRTFの作成

Posted on 6月 6, 2018 by Takaaki Naganoya

指定のrecord in listからTag CloudっぽいRTFファイルをデスクトップに生成するAppleScriptです。

以前からTag Cloudを出力するフレームワークやObjective-Cのプログラムを探していたのですが、なかなか具合のいいものがありませんでした。

動作原理を考えたら割と簡単そうだったので、仕方なく自分で作ることに。

作ってみて「そんなに難しくない」ことはわかりましたが、まだまだ自分が望むようなものにはなっていません。とりあえず「まあそんなもんだよね」という程度のものです。

set tagList to {{tagname:”AirServer”, tagcount:2}, {tagname:”App Store”, tagcount:1}, {tagname:”Calendar”, tagcount:3}, {tagname:”Contacts”, tagcount:1}, {tagname:”CotEditor”, tagcount:27}, {tagname:”Dictionary”, tagcount:9}, {tagname:”Dock”, tagcount:7}, {tagname:”Evernote”, tagcount:2}, {tagname:”Finder”, tagcount:20}, {tagname:”HelpViewer”, tagcount:2}, {tagname:”HoudahSpot”, tagcount:1}, {tagname:”iBooks”, tagcount:1}, {tagname:”Image Events”, tagcount:1}, {tagname:”iTunes”, tagcount:12}, {tagname:”JeditΩ”, tagcount:3}, {tagname:”Keynote”, tagcount:14}, {tagname:”Mac Blu-ray Player”, tagcount:1}, {tagname:”MacDown”, tagcount:3}, {tagname:”Mail”, tagcount:6}, {tagname:”Maps”, tagcount:3}, {tagname:”mi”, tagcount:2}, {tagname:”Numbers”, tagcount:8}, {tagname:”Pages”, tagcount:2}, {tagname:”Preview.app”, tagcount:2}, {tagname:”QuickTime Player”, tagcount:8}, {tagname:”Reminders”, tagcount:1}, {tagname:”Safari”, tagcount:13}, {tagname:”Script Debugger”, tagcount:1}, {tagname:”Script Editor”, tagcount:7}, {tagname:”Sorting”, tagcount:5}, {tagname:”Spell check”, tagcount:3}, {tagname:”System Events”, tagcount:6}, {tagname:”Terminal”, tagcount:4}, {tagname:”TextEdit”, tagcount:12}, {tagname:”Twitter”, tagcount:1}, {tagname:”Xcode”, tagcount:2}}

という入力から、

というタグクラウドのRTFをデスクトップに書き出します。処理時間は開発環境(MacBook Pro Retina 2012 Core i7 2.66GHz)で0.08秒ぐらいです。

本当は、こんな1次元で連続した内容ではなく、2次元で各タグを分離したオブジェクトとして平面上に配置し、かつ、大きな文字の内容を中心部に配置するとか、間を詰めるために縦方向に回転させたタグも入れるとか、そういう感じの処理を(自動で)行いたいところなので、このレベルだと「ただタグとして並んでいるだけ」で満足できません。

最終的には、日本語のテキストを形態素解析して固有名詞のみ抽出し、出現頻度の高いものをタグクラウドで並べることで内容を把握しやすくする、といった処理を行いたいところです。

AppleScript名:Tag CloudっぽいRTFの作成
— Created 2018-06-06 by Takaaki Naganoya
— 2018 Piyomaru Software
use AppleScript version "2.5"
use scripting additions
use framework "Foundation"
use framework "AppKit"

property NSFont : a reference to current application’s NSFont
property NSUUID : a reference to current application’s NSUUID
property NSColor : a reference to current application’s NSColor
property NSString : a reference to current application’s NSString
property Board2D : a reference to current application’s Board2D
property Pathfinder : a reference to current application’s Pathfinder
property NSDictionary : a reference to current application’s NSDictionary
property NSLiteralSearch : a reference to current application’s NSLiteralSearch
property NSMutableArray : a reference to current application’s NSMutableArray
property NSFontAttributeName : a reference to current application’s NSFontAttributeName
property NSMutableAttributedString : a reference to current application’s NSMutableAttributedString
property NSForegroundColorAttributeName : a reference to current application’s NSForegroundColorAttributeName
property NSDocumentTypeDocumentAttribute : a reference to current application’s NSDocumentTypeDocumentAttribute

set tagList to {{tagname:"AirServer", tagcount:2}, {tagname:"App Store", tagcount:1}, {tagname:"Calendar", tagcount:3}, {tagname:"Contacts", tagcount:1}, {tagname:"CotEditor", tagcount:27}, {tagname:"Dictionary", tagcount:9}, {tagname:"Dock", tagcount:7}, {tagname:"Evernote", tagcount:2}, {tagname:"Finder", tagcount:20}, {tagname:"HelpViewer", tagcount:2}, {tagname:"HoudahSpot", tagcount:1}, {tagname:"iBooks", tagcount:1}, {tagname:"Image Events", tagcount:1}, {tagname:"iTunes", tagcount:12}, {tagname:"JeditΩ", tagcount:3}, {tagname:"Keynote", tagcount:14}, {tagname:"Mac Blu-ray Player", tagcount:1}, {tagname:"MacDown", tagcount:3}, {tagname:"Mail", tagcount:6}, {tagname:"Maps", tagcount:3}, {tagname:"mi", tagcount:2}, {tagname:"Numbers", tagcount:8}, {tagname:"Pages", tagcount:2}, {tagname:"Preview.app", tagcount:2}, {tagname:"QuickTime Player", tagcount:8}, {tagname:"Reminders", tagcount:1}, {tagname:"Safari", tagcount:13}, {tagname:"Script Debugger", tagcount:1}, {tagname:"Script Editor", tagcount:7}, {tagname:"Sorting", tagcount:5}, {tagname:"Spell check", tagcount:3}, {tagname:"System Events", tagcount:6}, {tagname:"Terminal", tagcount:4}, {tagname:"TextEdit", tagcount:12}, {tagname:"Twitter", tagcount:1}, {tagname:"Xcode", tagcount:2}}

set targFontName to "Courier-Bold" –PostScript Name

set tagArray to current application’s NSMutableArray’s arrayWithArray:tagList
set aMax to (tagArray’s valueForKeyPath:"@max.tagcount") as list of string or string –as anything
set aMin to (tagArray’s valueForKeyPath:"@min.tagcount") as list of string or string –as anything

set strList to tagArray’s valueForKey:"tagname"
set strAll to retArrowText(strList, " ") of me
set strAll to " " & strAll & " "

set anAttr to current application’s NSMutableAttributedString’s alloc()’s initWithString:strAll

repeat with i in tagList
  set aName to (tagname of i) as string
  
set aNum to (tagcount of i) as number
  
if aNum > (aMax * 0.8) then
    set aFontSize to 48
    
set aColor to current application’s NSColor’s redColor()
  else if aNum > (aMax * 0.6) then
    set aFontSize to 36
    
set aColor to current application’s NSColor’s orangeColor()
  else if aNum > (aMax * 0.4) then
    set aFontSize to 22
    
set aColor to current application’s NSColor’s greenColor()
  else
    set aFontSize to 16
    
set aColor to current application’s NSColor’s blackColor()
  end if
  
  
set aFont to (current application’s NSFont’s fontWithName:targFontName |size|:aFontSize)
  
  
–Caution: Call by Reference
  
markCharOfAttributedString(anAttr, strAll, " " & aName & " ", aColor, aFont) of me
  
end repeat

–結果のRTFをデスクトップ上に書き出す。ファイル名はUUID.rtf
set targFol to current application’s NSHomeDirectory()’s stringByAppendingPathComponent:"Desktop"
set aRes to my saveStyledTextAsRTF(targFol, anAttr)

–指定のAttributed String内で指定文字列が含まれる箇所に指定の色をつける(結果はメイン側に参照渡し)
on markCharOfAttributedString(anAttr, origStr, aTargStr, aColor, aFont)
  set rList to searchWordWithRange(origStr, aTargStr) of me
  
repeat with ii in rList
    (anAttr’s addAttribute:(NSForegroundColorAttributeName) value:aColor range:ii)
    (
anAttr’s addAttribute:(NSFontAttributeName) value:aFont range:ii)
  end repeat
end markCharOfAttributedString

–指定の文字列をAttributed Stringに変換して任意のフォントを一括指定
on changeAttrStrsFontAttribute(aStr, aFontPSName, aFontSize)
  set tmpAttr to NSMutableAttributedString’s alloc()’s initWithString:aStr
  
set aRange to current application’s NSMakeRange(0, tmpAttr’s |length|())
  
set aVal1 to NSFont’s fontWithName:aFontPSName |size|:aFontSize
  
tmpAttr’s beginEditing()
  
tmpAttr’s addAttribute:(NSFontAttributeName) value:aVal1 range:aRange
  
tmpAttr’s endEditing()
  
return tmpAttr
end changeAttrStrsFontAttribute

–スタイル付きテキストを指定フォルダ(POSIX path)にRTFで書き出し
on saveStyledTextAsRTF(targFol, aStyledString)
  set bstyledLength to aStyledString’s |string|()’s |length|()
  
set bDict to NSDictionary’s dictionaryWithObject:"NSRTFTextDocumentType" forKey:(NSDocumentTypeDocumentAttribute)
  
set bRTF to aStyledString’s RTFFromRange:(current application’s NSMakeRange(0, bstyledLength)) documentAttributes:bDict
  
  
set theName to (NSUUID’s UUID()’s UUIDString())
  
set thePath to NSString’s stringWithString:targFol
  
set thePath to (thePath’s stringByAppendingPathComponent:theName)’s stringByAppendingPathExtension:"rtf"
  
return (bRTF’s writeToFile:thePath atomically:true) as boolean
end saveStyledTextAsRTF

–指定テキストデータ(atargText)内に、指定文字列(aSearchStr)が含まれる範囲情報(NSRange)をすべて取得する
on searchWordWithRange(aTargText, aSearchStr)
  set aStr to NSString’s stringWithString:aTargText
  
set bStr to NSString’s stringWithString:aSearchStr
  
set hitArray to NSMutableArray’s alloc()’s init()
  
set cNum to (aStr’s |length|()) as integer
  
  
set aRange to current application’s NSMakeRange(0, cNum)
  
  
repeat
    set detectedRange to aStr’s rangeOfString:bStr options:NSLiteralSearch range:aRange
    
set aLoc to (detectedRange’s location)
    
–CAUTION !!!! Sometimes aLoc returns not NSNotFound (-1) but a Very large number
    
if (aLoc > 9.999999999E+9) or (aLoc = (current application’s NSNotFound)) then exit repeat
    
    
hitArray’s addObject:detectedRange
    
    
set aNum to aLoc as integer
    
set bNum to (detectedRange’s |length|) as integer
    
    
set aRange to current application’s NSMakeRange(aNum + bNum, cNum – (aNum + bNum))
  end repeat
  
  
return hitArray
end searchWordWithRange

–リストを指定デリミタをはさんでテキスト化
on retStrFromArrayWithDelimiter(aList, aDelim)
  set anArray to current application’s NSArray’s arrayWithArray:aList
  
set aRes to anArray’s componentsJoinedByString:aDelim
  
return aRes as list of string or string
end retStrFromArrayWithDelimiter

on retArrowText(aList, aDelim) –自分のASでよく使うハンドラ名称なので、同じものを用意
  return my retStrFromArrayWithDelimiter(aList, aDelim)
end retArrowText

–テキストを指定デリミタでリスト化
on parseByDelim(aData, aDelim)
  set aText to current application’s NSString’s stringWithString:aData
  
set aList to aText’s componentsSeparatedByString:aDelim
  
return aList as list
end parseByDelim

★Click Here to Open This Script 

Posted in list Record RTF Text | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

Finderで選択中のPDFを反時計方向に90°回転させる

Posted on 6月 4, 2018 by Takaaki Naganoya

Finder上で選択中のPDFを反時計方向に90°回転(=時計方向に270°回転)させるAppleScriptです。

Finder上で選択中の項目の中にPDF以外のものがあった場合には処理をスキップし、選択中のアイテムがない場合には処理を行いません。

実際には、macOS標準装備のScript Menuに、それぞれの角度(90°、180°、270°)への回転Scriptを個別に入れて使っています。1本のScriptで角度入力を行って回転させるよりも、あらかじめ固定の角度に回転させるものを複数用意しておいたほうが使い勝手がよいためです。

ドキュメントスキャナで紙の資料をPDFにスキャンするような時に、紙がヨレていて1枚ずつでないとスキャンできないような場合で、さらに穴が空いていたりヨレていて通常方向に紙を入れられなかった場合に、他の方向に入れてスキャンしておき、本Scriptのようなプログラムであとでまとめて回転させるなどの処理をよく行っています。

AppleScript名:Finderで選択中のPDFを反時計方向に90°回転させる
— Created 2018-05-26 by Takaaki Naganoya
— Modified 2018-06-02 by Takaaki Naganoya
— 2018 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "Quartz"

property |NSURL| : a reference to current application’s |NSURL|
property NSUUID : a reference to current application’s NSUUID
property NSArray : a reference to current application’s NSArray
property NSString : a reference to current application’s NSString
property NSPredicate : a reference to current application’s NSPredicate
property PDFDocument : a reference to current application’s PDFDocument
property NSFileManager : a reference to current application’s NSFileManager
property NSURLPathKey : a reference to current application’s NSURLPathKey
property NSMutableArray : a reference to current application’s NSMutableArray
property NSSortDescriptor : a reference to current application’s NSSortDescriptor
property NSURLIsPackageKey : a reference to current application’s NSURLIsPackageKey
property NSURLIsDirectoryKey : a reference to current application’s NSURLIsDirectoryKey
property NSURLTypeIdentifierKey : a reference to current application’s NSURLTypeIdentifierKey
property NSURLContentModificationDateKey : a reference to current application’s NSURLContentModificationDateKey
property NSDirectoryEnumerationSkipsHiddenFiles : a reference to current application’s NSDirectoryEnumerationSkipsHiddenFiles

set targDegree to 270 — targDegree have to be in {0, 90, 180, 270, 360} in clockwise

–set inFiles to (choose file of type {"pdf"} with prompt "Choose your PDF files:" with multiple selections allowed)
tell application "Finder"
  set inFiles to selection as alias list
end tell
if inFiles = {} then return

–指定のAlias listのうちPDFのみ抽出
set filRes1 to filterAliasListByUTI(inFiles, "com.adobe.pdf") of me
if filRes1 = {} then return

–選択中のファイルのうちの1つから親フォルダを求め、出力先ファイルパスを組み立てる
set outPathTarg to POSIX path of (first item of filRes1)
set pathString to NSString’s stringWithString:outPathTarg
set newPath to (pathString’s stringByDeletingLastPathComponent()) as string

repeat with i in filRes1
  set destPosixPath to newPath & "/" & ((NSUUID’s UUID()’s UUIDString()) as string) & ".pdf"
  
rotatePDFandSaveAt(i, destPosixPath, targDegree) of me
end repeat

–与えられたPOSIX pathのPDFを指定の角度に回転させて新規指定パスに書き出す
on rotatePDFandSaveAt(oldPath as string, newPath as string, aDegree as integer)
  
  
–Error Check
  
if aDegree is not in {0, 90, 180, 270, 360} then error "Wrong Degree"
  
  
set aURL to current application’s |NSURL|’s fileURLWithPath:oldPath
  
set aPDFdoc to PDFDocument’s alloc()’s initWithURL:aURL
  
  
set pCount to aPDFdoc’s pageCount() –count pages
  
  
–Make Blank PDF
  
set newPDFdoc to PDFDocument’s alloc()’s init()
  
  
–Rotate Each Page
  
repeat with i from 0 to (pCount – 1)
    set aPage to (aPDFdoc’s pageAtIndex:i)
    
    
–Set Degree
    
set curDegree to aPage’s |rotation|() –Get Current Degree
    (
aPage’s setRotation:(aDegree + curDegree)) –Set New Degree
    
    (
newPDFdoc’s insertPage:aPage atIndex:i)
  end repeat
  
  
set aRes to newPDFdoc’s writeToFile:newPath
  
return aRes as boolean
  
end rotatePDFandSaveAt

–Alias listから指定UTIに含まれるものをPOSIX pathのリストで返す
on filterAliasListByUTI(aList, targUTI)
  set newList to {}
  
repeat with i in aList
    set j to POSIX path of i
    
set tmpUTI to my retUTIfromPath(j)
    
set utiRes to my filterUTIList({tmpUTI}, targUTI)
    
if utiRes is not equal to {} then
      set the end of newList to j
    end if
  end repeat
  
return newList
end filterAliasListByUTI

–指定のPOSIX pathのファイルのUTIを求める
on retUTIfromPath(aPOSIXPath)
  set aURL to |NSURL|’s fileURLWithPath:aPOSIXPath
  
set {theResult, theValue} to aURL’s getResourceValue:(reference) forKey:NSURLTypeIdentifierKey |error|:(missing value)
  
  
if theResult = true then
    return theValue as string
  else
    return theResult
  end if
end retUTIfromPath

–UTIリストが指定UTIに含まれているかどうか演算を行う
on filterUTIList(aUTIList, aUTIstr)
  set anArray to NSArray’s arrayWithArray:aUTIList
  
set aPred to NSPredicate’s predicateWithFormat_("SELF UTI-CONFORMS-TO %@", aUTIstr)
  
set bRes to (anArray’s filteredArrayUsingPredicate:aPred) as list
  
return bRes
end filterUTIList

★Click Here to Open This Script 

Posted in file PDF | Tagged 10.11savvy 10.12savvy 10.13savvy Finder | Leave a comment

Finder上で選択中の画像をアンチエイリアスなしで200%にリサイズ

Posted on 6月 3, 2018 by Takaaki Naganoya

Finder上で選択中の画像をアンチエイリアスなしで200%にリサイズするAppleScriptです。

よく使う拡大/縮小倍率のScriptを用意してmacOS標準装備のScript Menuに入れておき、Menuから呼び出して使っています。

AppleScript名:Finder上で選択中の画像をアンチエイリアスなしで200%にリサイズ
— Created 2014-02-21 Shane Stanley
— Modified 2018-06-01 Takaaki Naganoya
use AppleScript version "2.5"
use scripting additions
use framework "Foundation"
use framework "AppKit"

property |NSURL| : a reference to current application’s |NSURL|
property NSArray : a reference to current application’s NSArray
property NSPredicate : a reference to current application’s NSPredicate
property NSURLTypeIdentifierKey : a reference to current application’s NSURLTypeIdentifierKey

set zoomPercent to 2.0

tell application "Finder"
  set inFiles to selection as alias list
end tell

–指定のAlias listのうち画像のみ抽出
set filRes1 to filterAliasListByUTI(inFiles, "public.image") of me
if filRes1 = {} then return

–選択中のファイルのうちの1つから親フォルダを求め、出力先ファイルパスを組み立てる
set outPathTarg to POSIX path of (first item of filRes1)
set pathString to current application’s NSString’s stringWithString:outPathTarg
set newPath to (pathString’s stringByDeletingLastPathComponent()) as string

repeat with i in filRes1
  
  
set outPOSIXpath to newPath & "/" & (current application’s NSUUID’s UUID()’s UUIDString()) as string
  
  
set aNSImage to (current application’s NSImage’s alloc()’s initWithContentsOfFile:(i))
  
set theImage to (my resizeNSImageWithoutAntlialias:aNSImage toScale:zoomPercent)
  
  
–ファイルパスの拡張子を取得する
  
set pathString to (current application’s NSString’s stringWithString:i)
  
set fileExt to (pathString’s pathExtension()) as string
  
  
set newPath to outPOSIXpath & "." & fileExt
  
  
–元画像のファイルファイルフォーマットに合わせて同じフォーマットに
  
if fileExt is in {"png", "PNG"} then
    my saveNSImageAtPathAsPNG(theImage, newPath)
  else if fileExt is in {"jpg", "jpeg"} then
    my saveNSImageAtPathAsJPG(theImage, newPath, 1.0 as real)
  else if fileExt is in {"tif", "tiff"} then
    my saveNSImageAtPathAsTIFF(theImage, newPath)
  else if fileExt is in {"bmp"} then
    my saveNSImageAtPathAsBMP(theImage, newPath)
  end if
  
end repeat

–NSImageを指定倍率で拡大(アンチエイリアス解除状態で)
on resizeNSImageWithoutAntlialias:aSourceImg toScale:imgScale
  set aSize to aSourceImg’s |size|()
  
set aWidth to (aSize’s width) * imgScale
  
set aHeight to (aSize’s height) * imgScale
  
  
set aRep to current application’s NSBitmapImageRep’s alloc()’s initWithBitmapDataPlanes:(missing value) pixelsWide:aWidth pixelsHigh:aHeight bitsPerSample:8 samplesPerPixel:4 hasAlpha:true isPlanar:false colorSpaceName:(current application’s NSCalibratedRGBColorSpace) bytesPerRow:0 bitsPerPixel:0
  
  
set newSize to {width:aWidth, height:aHeight}
  
aRep’s setSize:newSize
  
  
current application’s NSGraphicsContext’s saveGraphicsState()
  
  
set theContext to current application’s NSGraphicsContext’s graphicsContextWithBitmapImageRep:aRep
  
current application’s NSGraphicsContext’s setCurrentContext:theContext
  
theContext’s setShouldAntialias:false
  
theContext’s setImageInterpolation:(current application’s NSImageInterpolationNone)
  
  
aSourceImg’s drawInRect:(current application’s NSMakeRect(0, 0, aWidth, aHeight)) fromRect:(current application’s NSZeroRect) operation:(current application’s NSCompositeCopy) fraction:(1.0)
  
  
current application’s NSGraphicsContext’s restoreGraphicsState()
  
  
set newImg to current application’s NSImage’s alloc()’s initWithSize:newSize
  
newImg’s addRepresentation:aRep
  
  
return newImg
end resizeNSImageWithoutAntlialias:toScale:

–Alias listから指定UTIに含まれるものをPOSIX pathのリストで返す
on filterAliasListByUTI(aList, targUTI)
  set newList to {}
  
repeat with i in aList
    set j to POSIX path of i
    
set tmpUTI to my retUTIfromPath(j)
    
set utiRes to my filterUTIList({tmpUTI}, targUTI)
    
if utiRes is not equal to {} then
      set the end of newList to j
    end if
  end repeat
  
return newList
end filterAliasListByUTI

–指定のPOSIX pathのファイルのUTIを求める
on retUTIfromPath(aPOSIXPath)
  set aURL to |NSURL|’s fileURLWithPath:aPOSIXPath
  
set {theResult, theValue} to aURL’s getResourceValue:(reference) forKey:NSURLTypeIdentifierKey |error|:(missing value)
  
  
if theResult = true then
    return theValue as string
  else
    return theResult
  end if
end retUTIfromPath

–UTIリストが指定UTIに含まれているかどうか演算を行う
on filterUTIList(aUTIList, aUTIstr)
  set anArray to NSArray’s arrayWithArray:aUTIList
  
set aPred to NSPredicate’s predicateWithFormat_("SELF UTI-CONFORMS-TO %@", aUTIstr)
  
set bRes to (anArray’s filteredArrayUsingPredicate:aPred) as list
  
return bRes
end filterUTIList

–NSImageを指定パスにJPEG形式で保存、qulityNumは0.0〜1.0。1.0は無圧縮
on saveNSImageAtPathAsJPG(anImage, outPath, qulityNum as real)
  set imageRep to anImage’s TIFFRepresentation()
  
set aRawimg to current application’s NSBitmapImageRep’s imageRepWithData:imageRep
  
set pathString to current application’s NSString’s stringWithString:outPath
  
set newPath to pathString’s stringByExpandingTildeInPath()
  
set myNewImageData to (aRawimg’s representationUsingType:(current application’s NSJPEGFileType) |properties|:{NSImageCompressionFactor:qulityNum})
  
set aRes to (myNewImageData’s writeToFile:newPath atomically:true) as boolean
  
return aRes –true/false
end saveNSImageAtPathAsJPG

–NSImageを指定パスにTIFF形式で保存
on saveNSImageAtPathAsTIFF(anImage, outPath)
  set imageRep to anImage’s TIFFRepresentation()
  
set aRawimg to current application’s NSBitmapImageRep’s imageRepWithData:imageRep
  
set pathString to current application’s NSString’s stringWithString:outPath
  
set newPath to pathString’s stringByExpandingTildeInPath()
  
set myNewImageData to (aRawimg’s representationUsingType:(current application’s NSTIFFFileType) |properties|:(missing value))
  
set aRes to (myNewImageData’s writeToFile:newPath atomically:true) as boolean
  
return aRes –true/false
end saveNSImageAtPathAsTIFF

–NSImageを指定パスにPNG形式で保存
on saveNSImageAtPathAsPNG(anImage, outPath)
  set imageRep to anImage’s TIFFRepresentation()
  
set aRawimg to current application’s NSBitmapImageRep’s imageRepWithData:imageRep
  
set pathString to current application’s NSString’s stringWithString:outPath
  
set newPath to pathString’s stringByExpandingTildeInPath()
  
set myNewImageData to (aRawimg’s representationUsingType:(current application’s NSPNGFileType) |properties|:(missing value))
  
set aRes to (myNewImageData’s writeToFile:newPath atomically:true) as boolean
  
return aRes –true/false
end saveNSImageAtPathAsPNG

–NSImageを指定パスにBMP形式で保存
on saveNSImageAtPathAsBMP(anImage, outPath)
  set imageRep to anImage’s TIFFRepresentation()
  
set aRawimg to current application’s NSBitmapImageRep’s imageRepWithData:imageRep
  
set pathString to current application’s NSString’s stringWithString:outPath
  
set newPath to pathString’s stringByExpandingTildeInPath()
  
set myNewImageData to (aRawimg’s representationUsingType:(current application’s NSBMPFileType) |properties|:(missing value))
  
set aRes to (myNewImageData’s writeToFile:newPath atomically:true) as boolean
  
return aRes –true/false
end saveNSImageAtPathAsBMP

★Click Here to Open This Script 

Posted in file Image | Tagged 10.11savvy 10.12savvy 10.13savvy Finder | Leave a comment

Finder上で選択中の画像をアンチエイリアスありで50%にリサイズ

Posted on 6月 3, 2018 by Takaaki Naganoya

Finder上で選択中の画像をアンチエイリアスありで50%にリサイズするAppleScriptです。

よく使う拡大/縮小倍率のScriptを用意してmacOS標準装備のScript Menuに入れておき、Menuから呼び出して使っています。

AppleScript名:Finder上で選択中の画像をアンチエイリアスありで50%にリサイズ
— Created 2014-02-21 Shane Stanley
— Modified 2018-06-01 Takaaki Naganoya
use AppleScript version "2.5"
use scripting additions
use framework "Foundation"
use framework "AppKit"

property |NSURL| : a reference to current application’s |NSURL|
property NSArray : a reference to current application’s NSArray
property NSPredicate : a reference to current application’s NSPredicate
property NSURLTypeIdentifierKey : a reference to current application’s NSURLTypeIdentifierKey

set zoomPercent to 0.5

tell application "Finder"
  set inFiles to selection as alias list
end tell

–指定のAlias listのうち画像のみ抽出
set filRes1 to filterAliasListByUTI(inFiles, "public.image") of me
if filRes1 = {} then return

–選択中のファイルのうちの1つから親フォルダを求め、出力先ファイルパスを組み立てる
set outPathTarg to POSIX path of (first item of filRes1)
set pathString to current application’s NSString’s stringWithString:outPathTarg
set newPath to (pathString’s stringByDeletingLastPathComponent()) as string

repeat with i in filRes1
  set outPOSIXpath to newPath & "/" & (current application’s NSUUID’s UUID()’s UUIDString()) as string
  
set fRes1 to resizeImage(i, outPOSIXpath, zoomPercent) of me
end repeat

on resizeImage(imagePath, newPath, aZoom as real)
  –ファイルパスの拡張子を取得する
  
set pathString to current application’s NSString’s stringWithString:imagePath
  
set fileExt to (pathString’s pathExtension()) as string
  
  
–画像ファイルをNSImageに読み込み
  
set theImage to current application’s NSImage’s alloc()’s initWithContentsOfFile:imagePath — load the file as an NSImage
  
  
— calculate required sizes
  
set theSize to (theImage’s |size|()) as record
  
  
set oldWidth to width of theSize
  
set oldHeight to height of theSize
  
  
set theWidth to oldWidth * aZoom
  
set theHeight to oldHeight * aZoom
  
  
set newImage to current application’s NSImage’s alloc()’s initWithSize:(current application’s NSMakeSize(theWidth, theHeight))
  
  
newImage’s lockFocus()
  
theImage’s drawInRect:{origin:{x:0, y:0}, |size|:{width:theWidth, height:theHeight}} fromRect:(current application’s NSZeroRect) operation:(current application’s NSCompositeSourceOver) fraction:1.0
  
newImage’s unlockFocus()
  
  
set theData to newImage’s TIFFRepresentation()
  
set newRep to current application’s NSBitmapImageRep’s imageRepWithData:theData
  
  
–元画像のファイルファイルフォーマットに合わせて同じフォーマットに
  
if fileExt is in {"png", "PNG"} then
    set theData to (newRep’s representationUsingType:(current application’s NSPNGFileType) |properties|:{NSImageGamma:1.0})
  else if fileExt is in {"jpg", "jpeg"} then
    set theData to (newRep’s representationUsingType:(current application’s NSJPEGFileType) |properties|:{NSImageCompressionFactor:1.0})
  else if fileExt is in {"tif", "tiff"} then
    set theData to (newRep’s representationUsingType:(current application’s NSTIFFFileType) |properties|:(missing value))
  else if fileExt is in {"bmp"} then
    set theData to (newRep’s representationUsingType:(current application’s NSBMPFileType) |properties|:(missing value))
  end if
  
  
set newPath to newPath & "." & fileExt
  
return (theData’s writeToFile:newPath atomically:true)
  
end resizeImage

–Alias listから指定UTIに含まれるものをPOSIX pathのリストで返す
on filterAliasListByUTI(aList, targUTI)
  set newList to {}
  
repeat with i in aList
    set j to POSIX path of i
    
set tmpUTI to my retUTIfromPath(j)
    
set utiRes to my filterUTIList({tmpUTI}, targUTI)
    
if utiRes is not equal to {} then
      set the end of newList to j
    end if
  end repeat
  
return newList
end filterAliasListByUTI

–指定のPOSIX pathのファイルのUTIを求める
on retUTIfromPath(aPOSIXPath)
  set aURL to |NSURL|’s fileURLWithPath:aPOSIXPath
  
set {theResult, theValue} to aURL’s getResourceValue:(reference) forKey:NSURLTypeIdentifierKey |error|:(missing value)
  
  
if theResult = true then
    return theValue as string
  else
    return theResult
  end if
end retUTIfromPath

–UTIリストが指定UTIに含まれているかどうか演算を行う
on filterUTIList(aUTIList, aUTIstr)
  set anArray to NSArray’s arrayWithArray:aUTIList
  
set aPred to NSPredicate’s predicateWithFormat_("SELF UTI-CONFORMS-TO %@", aUTIstr)
  
set bRes to (anArray’s filteredArrayUsingPredicate:aPred) as list
  
return bRes
end filterUTIList

★Click Here to Open This Script 

Posted in file Image | Tagged 10.11savvy 10.12savvy 10.13savvy Finder | Leave a comment

各デスクトップのデスクトップピクチャをPreviewでオープン

Posted on 6月 1, 2018 by Takaaki Naganoya

各デスクトップに設定してあるデスクトップピクチャのパスをもとめ、Preview.appでオープンするAppleScriptです。

こんな感じに複数のディスプレイにデスクトップピクチャが設定してある状態で実行すると、

すべてのディスプレイのデスクトップピクチャの画像をPreview.appでオープンします。

Keynoteで資料を作っているときに、デスクトップのキャプチャを行なったような場合に、デスクトップピクチャを含めて合成できたほうが便利なケースがあって、そのようなときに書いた「作り捨て」レベルのScriptです。

AppleScript名:各デスクトップのデスクトップピクチャをPreviewでオープン
tell application "System Events"
  set aList to picture of every desktop
end tell

repeat with i in aList
  try
    set targFile to (POSIX file i) as alias
    
tell application "Preview"
      open targFile
    end tell
  end try
end repeat

★Click Here to Open This Script 

Posted in System | Tagged 10.11savvy 10.12savvy 10.13savvy Preview System Events | Leave a comment

HoudahSpotのコントロールを行う

Posted on 6月 1, 2018 by Takaaki Naganoya

HoudahSpotの各種コントロールを行うAppleScriptです。

HoudahSpotは、Spotlightの検索を行うアプリケーションで、AppleScript対応しています。

検索自体は非同期で実行され、検索が終了したかどうかは最前面のドキュメント(front document)のプロパティ「search completed」がtrueになるかどうかをループで確認することになります。このさい、delayコマンドで時間待ちしないと負荷が高くなって全体のパフォーマンスが低下するので、0.1秒ぐらいの時間待ちを行うのが非同期アプリケーションのコントロール時の「お約束」です(Xcodeとか)。

HoudahSpotの検索条件についてはAppleScriptから一切コントロールできないので、HoudahSpot書類に保存しておいてオープンして再検索を行うという利用スタイルを考えているのでしょう。

みどころは、Finderの最前面のウィンドウのパス以下を対象にSpotlight検索するfinder searchコマンド。ちょっと目の付け所がいいと思います。あと、HoudahSpot HelperをオンにするとStatus Bar上にmacOS純正のSpotlightアイコンと同様のアイコンが出てきて検索できます。これもいいと思います。

ただ、わざわざGUIアプリケーションで実行しなくても、AppleScriptから直接Spotlightの機能を呼び出せるので、HoudahSpotを利用する必然性があまり感じられません。

AppleScript名:アプリケーションのプロパティを取得する
tell application "HoudahSpot"
  properties
  
–> {frontmost:false, class:application, name:"HoudahSpot", version:"4.3.7"}
end tell

★Click Here to Open This Script 

AppleScript名:ドキュメントのプロパティを取得する
tell application "HoudahSpot"
  tell document 1
    properties
    
–> {modified:false, name:"Untitled", details pane visible:false, search completed:false, selection:{}, search active:false, file:missing value, results view:list view, search pane visible:true, class:document}
  end tell
end tell

★Click Here to Open This Script 

AppleScript名:ドキュメントをかぞえる
tell application "HoudahSpot"
  set dCount to count every document
  
–> 1
end tell

★Click Here to Open This Script 

AppleScript名:Windowのプロパティを取得する
tell application "HoudahSpot"
  tell window 1
    properties
    
–> {zoomable:true, closeable:true, current tab:tab 1 of window id 89717 of application "HoudahSpot", zoomed:false, class:window, index:1, visible:true, sidebar visible:false, name:"Untitled", toolbar visible:true, miniaturizable:true, id:89717, miniaturized:false, resizable:true, bounds:{0, 22, 1407, 797}, document:document "Untitled" of application "HoudahSpot"}
    
  end tell
end tell

★Click Here to Open This Script 

AppleScript名:WindowのTabをかぞえる
tell application "HoudahSpot"
  tell window 1
    set tCount to count every tab
    
–> 1
  end tell
end tell

★Click Here to Open This Script 

AppleScript名:検索を実行
tell application "HoudahSpot"
  search "Piyowolf"
  
–> document "Untitled 3" of application "HoudahSpot"
end tell

★Click Here to Open This Script 

AppleScript名:検索結果のプロパティをすべて取得する
tell application "HoudahSpot"
  set resList to every result of front document
  
  
set rList to {}
  
repeat with i in resList
    set aRes to properties of i
    
log aRes
    
(*class:result, path:/Users/maro/Library/Mail/V4/DA40FA88-F9E4-45A0-A3C9-4DCD4DCE3C38/Sent Messages.mbox/8DD46D63-E6F7-4A3C-81DF-4D4FDBFBE19B/Data/7/9/0/2/Messages/2097257.emlx, id:/Users/maro/Library/Mail/V4/DA40FA88-F9E4-45A0-A3C9-4DCD4DCE3C38/Sent Messages.mbox/8DD46D63-E6F7-4A3C-81DF-4D4FDBFBE19B/Data/7/9/0/2/Messages/2097257.emlx, name: Yasu for Mac*)
  end repeat
end tell

★Click Here to Open This Script 

AppleScript名:検索結果をカウントする
tell application "HoudahSpot"
  set resCount to count every result of front document
end tell

★Click Here to Open This Script 

AppleScript名:キーワード検索して結果を取得する
tell application "HoudahSpot"
  set resDoc to search "AppleScriptObjC"
  
  
repeat
    tell resDoc
      set resC to search completed
    end tell
    
if resC is equal to true then exit repeat
    
delay 0.1
  end repeat
  
  
set resList to count every result of front document
end tell

★Click Here to Open This Script 

AppleScript名:検索結果からフィルタ参照でしぼりこみ
tell application "HoudahSpot"
  set resList to every result of front document whose path ends with ".md"
end tell

★Click Here to Open This Script 

AppleScript名:検索結果を指定パスに保存する
set aSavePath to choose file name

tell application "HoudahSpot"
  save front document in aSavePath
end tell

★Click Here to Open This Script 

AppleScript名:保存しておいた検索結果をオープンする
set aFile to choose file

tell application "HoudahSpot"
  open aFile
end tell

★Click Here to Open This Script 

AppleScript名:キーワードをFinderの最前面のウィンドウのパスを対象に検索
tell application "HoudahSpot"
  set resDoc to finder search "EXIF"
  
  
repeat
    tell resDoc
      set resC to search completed
    end tell
    
if resC is equal to true then exit repeat
    
delay 0.1
  end repeat
  
  
set resList to count every result of front document
  
end tell

★Click Here to Open This Script 

Posted in Spotlight | Tagged 10.11savvy 10.12savvy 10.13savvy HoudahSpot | Leave a comment

ちょっと古めのAppleScript関連ドキュメントのアーカイブ「AppleScript Reference Library」

Posted on 5月 31, 2018 by Takaaki Naganoya

Philによるちょっと古めのAppleScript関連ドキュメントPDFのアーカイブサイト「AppleScript Reference Library」の更新情報がAppleScript Users ML上で紹介されていました。

Appleが開発者向けに1990年代に刊行していた「Develop」掲載記事や「Inside Machintosh」掲載のAppleScript関連記事などがあらたに追加されたようです。

2000〜2009年ぐらいのドキュメントも割とレガシー入りしており見つけにくくなっているものが多く、そうした意味でもまとめてダウンロードできる同サイトはありがたいところです。

Posted in 未分類 | Leave a comment

指定の画像からEXIFの撮影日付(DateTimeOriginal)を取得 v2

Posted on 5月 31, 2018 by Takaaki Naganoya

指定の画像からEXIF情報を取得し、撮影日付(DateTimeOriginal)を取得するAppleScriptです。

Image Eventsで取得するよりも、BridgePlusで取得するほうが高速だったので差し替えてみました。

AppleScript名:指定の画像からEXIFの撮影日付(DateTimeOriginal)を取得 v2
— Created 2014-12-14 by Takaaki Naganoya
— 2014 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use BPlus : script "BridgePlus" –https://www.macosxautomation.com/applescript/apps/BridgePlus.html

property NSString : a reference to current application’s NSString
property NSLocale : a reference to current application’s NSLocale
property SMSForder : a reference to current application’s SMSForder
property NSDateFormatter : a reference to current application’s NSDateFormatter

set aTargFile to choose file of type {"public.image"}
set exifRes to readExifDateTimeOriginal(aTargFile) of me

–指定ファイルからのExifデータを取得し撮影日付を取得する
on readExifDateTimeOriginal(aTargFileAlias)
  set theMetadata to readMetadataFrom(aTargFileAlias) of me
  
set keysList to theMetadata’s allKeys()
  
  
if "{Exif}" is not in (keysList as list) then return false
  
  
set exifDate to theMetadata’s valueForKeyPath:"{Exif}.DateTimeOriginal"
  
if exifDate = missing value then return false
  
  
set fullDate to dateFromStringWithDateFormat(exifDate, "yyyy:MM:dd HH:mm:ss") of me
  
  
return fullDate
end readExifDateTimeOriginal

–指定ファイルからのメタデータ読み込み
on readMetadataFrom(imageFile)
  load framework
  
set {theRecord, theError} to SMSForder’s metadataFromImage:imageFile |error|:(reference)
  
if theRecord = missing value then — there was a problem, so extract the error description
    error (theError’s localizedDescription() as text) — number (theError’s code())
  else
    return theRecord
  end if
end readMetadataFrom

–日付文字列を形式指定しつつdate objectに変換
on dateFromStringWithDateFormat(dateString, dateFormat)
  set dStr to NSString’s stringWithString:dateString
  
set dateFormatStr to NSString’s stringWithString:dateFormat
  
  
set aDateFormatter to NSDateFormatter’s alloc()’s init()
  
aDateFormatter’s setDateFormat:dateFormatStr
  
aDateFormatter’s setLocale:(NSLocale’s alloc()’s initWithLocaleIdentifier:"en_US_POSIX")
  
  
set aDestDate to (aDateFormatter’s dateFromString:dStr)
  
  
return aDestDate as list of string or string
end dateFromStringWithDateFormat

★Click Here to Open This Script 

Posted in Calendar exif file Image | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

指定フォルダ内のJPEGファイルのEXIFから撮影日付を取得してファイルの作成日付に反映させる v2

Posted on 5月 31, 2018 by Takaaki Naganoya

指定フォルダ内のすべてのJPEGファイルのEXIF情報から撮影日付を取得し、画像ファイルの作成日付に反映させるAppleScriptです。

写真.app(Photos.app)内で管理している大量の写真ファイルをいったんファイルに書き出して、DVD-Rにコピーして人に渡すときに、写真の作成日付が撮影日になっておらず、Finderなどのファイラー上で整理するのが大変でした。

ファイル書き出しなので仕方のないことですが、この仕様はいただけません。

かようにファイル作成日付が正しくない写真でも、EXIFに正しい撮影日付が保存されているケースが多い(ただし、完全にすべてではない)ため、EXIFの日付をAppleScriptで読み取ってファイル作成日付に反映させてみました。

写真.appなどのアプリケーションにインポートしてしまえばEXIF日付でソートされるので、あまり意味があるとも思えませんが、Finder上での写真整理のために実行してとりあえず走らせてみました。

AppleScript名:EXIFから撮影日付を取得してファイルの作成日付に反映させる v2
— Created 2018-05-30 by Takaaki Naganoya
— 2018 Piyomaru Software
use AppleScript version "2.5"
use scripting additions
use framework "Foundation"
use framework "AppKit"

script spd
  property fList : {}
end script

set renCount to 0

set (fList of spd) to {}

set aFolder to (choose folder)

set aDate to current date

set (fList of spd) to getFilePathList(aFolder, "JPG") of me

repeat with i in (fList of spd)
  set j to contents of i
  
chkCreationDateAsExif(j) of me
  
set renCount to renCount + 1
end repeat

set bDate to current date

return {bDate – aDate, renCount}

on chkCreationDateAsExif(aFile)
  tell application "Image Events"
    launch
    
set this_image to open (aFile as alias)
    
    
try
      tell this_image
        set aVal to (value of metadata tag "creation")
      end tell
    on error
      return
    end try
    
    
close this_image
  end tell
  
  
set a to current application’s NSString’s stringWithString:aVal
  
set {aDateStr, aTimeStr} to (a’s componentsSeparatedByString:" ") as list
  
set bDateStr to repChar(aDateStr, ":", "/") of me
  
set fullDate to date (bDateStr & " " & aTimeStr)
  
  
set aDic to current application’s NSMutableDictionary’s dictionaryWithObject:fullDate forKey:(current application’s NSFileModificationDate)
  
set aFM to current application’s NSFileManager’s defaultManager()’s setAttributes:aDic ofItemAtPath:(POSIX path of aFile) |error|:(missing value)
end chkCreationDateAsExif

–文字置換
on repChar(origText as string, targChar as string, repChar as string)
  set curDelim to AppleScript’s text item delimiters
  
set AppleScript’s text item delimiters to targChar
  
set tmpList to text items of origText
  
set AppleScript’s text item delimiters to repChar
  
set retText to tmpList as string
  
set AppleScript’s text item delimiters to curDelim
  
return retText
end repChar

on getFilePathList(aFol, aExt)
  set aFol to current application’s |NSURL|’s fileURLWithPath:(POSIX path of aFol)
  
  
set aFM to current application’s NSFileManager’s defaultManager()
  
set urlArray to aFM’s contentsOfDirectoryAtURL:aFol includingPropertiesForKeys:{} options:(current application’s NSDirectoryEnumerationSkipsHiddenFiles) |error|:(missing value)
  
set thePred to current application’s NSPredicate’s predicateWithFormat:"pathExtension == [c]%@" argumentArray:{aExt}
  
set anArray to urlArray’s filteredArrayUsingPredicate:thePred
  
return anArray as list — URLs pre-10.11, files under 10.11
end getFilePathList

★Click Here to Open This Script 

Posted in exif file Image | Tagged 10.11savvy 10.12savvy 10.13savvy Image Events | Leave a comment

Finderファイルタグの設定や取得

Posted on 5月 29, 2018 by Takaaki Naganoya

指定ファイルのFinderタグを取得/設定/追加を行うAppleScriptです。

もともとはShane Stanleyが数年前に書いたScriptですが、Cocoaっぽいハンドラ記述だと慣れていないScripterには敷居が高いので、OLD Style AppleScript風のハンドラに書き換えたものです。

AppleScript名:Finderファイルタグの設定や取得
–Created By Shane Stanley
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

property |NSURL| : a reference to current application’s |NSURL|
property NSOrderedSet : a reference to current application’s NSOrderedSet
property NSURLTagNamesKey : a reference to current application’s NSURLTagNamesKey

set anAlias to (choose file)
set aRes to getTagsForPath(anAlias) of me

— get the tags
on getTagsForPath(anAlias)
  set aURL to |NSURL|’s fileURLWithPath:(POSIX path of anAlias)
  
set {theResult, theTags} to aURL’s getResourceValue:(reference) forKey:(NSURLTagNamesKey) |error|:(missing value)
  
if theTags = missing value then return {} — because when there are none, it returns missing value
  
return theTags as list
end getTagsForPath

— set the tags, replacing any existing
on setTagsForPath(tagList, anAlias)
  set aURL to |NSURL|’s fileURLWithPath:(POSIX path of anAlias)
  
aURL’s setResourceValue:tagList forKey:(NSURLTagNamesKey) |error|:(missing value)
end setTagsForPath

— add to existing tags
on addTagsForPath(tagList, anAlias)
  set aURL to |NSURL|’s fileURLWithPath:(POSIX path of anAlias)
  
— get existing tags
  
set {theResult, theTags} to aURL’s getResourceValue:(reference) forKey:(NSURLTagNamesKey) |error|:(missing value)
  
if theTags ≠ missing value then — add new tags
    set tagList to (theTags as list) & tagList
    
set tagList to (NSOrderedSet’s orderedSetWithArray:tagList)’s allObjects() — delete any duplicates
  end if
  
aURL’s setResourceValue:tagList forKey:(NSURLTagNamesKey) |error|:(missing value)
end addTagsForPath

★Click Here to Open This Script 

Posted in file Tag | Tagged 10.11savvy 10.12savvy 10.13savvy Finder | Leave a comment

各TTSの名前とバージョン情報を取得

Posted on 5月 28, 2018 by Takaaki Naganoya

OSにインストールされている各TTS(Text To Speech)の名称一覧とバージョン情報を取得するAppleScriptです。

AppleScriptのsayコマンドには音声を指定する機能が用意されていますが、その一方でOSにインストールされているTTS音声の一覧を取得する機能がないため、このようにしてTTS音声名称を取得したり、対応言語(英語とか日本語とか)でしぼりこみを行なって指定言語のテキスト読み上げに必要なTTS音声が存在しているかといった判定を行います。

各TTS Voiceには、

{​​​​​​​VoiceName:”Vicki”, ​​​​​​​VoiceLocaleIdentifier:”en_US”, ​​​​​​​VoiceIndividuallySpokenCharacters:{{….}}, VoiceDemoText:”Isn’t it nice to have a computer that will talk to you?”, ​​​​​​​VoiceSupportedCharacters:{​​​​​​​​​{…}}, VoiceShowInFullListOnly:1, ​​​​​​​VoiceGender:”VoiceGenderFemale”, ​​​​​​​VoiceVersion:”3.6″, ​​​​​​​VoiceAge:35, ​​​​​​​VoiceIdentifier:”com.apple.speech.synthesis.voice.Vicki”, ​​​​​​​VoiceRelativeDesirability:5100, ​​​​​​​VoiceLanguage:”en-US”​​​​​}

のような属性情報があり、このVoiceNameとVoiceVersionを求めています。

Japanese TTS VoiceのOtoya v6.3.1とKyoko v6.3.1でも、あいかわらず「捥げる」「もげる」を正しく読み上げられない(「げる」、「もげ」になる)バグは治っていません(これを確認するのが本Scriptの目的です)。

AppleScript名:各TTSの名前とバージョン情報を取得
— Created 2015-08-25 by Takaaki Naganoya
— Modified 2015-08-26 by Shane Stanley, Takaaki Naganoya
— 2015 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"

set v1Res to getVoiceNamesAndVers()
–>  {{"Agnes", "3.6"}, {"Albert", "3.6"}, {"Alex", "2.0.36"}, {"Alice", "6.1.1"}, {"Allison", "6.3.1"}, {"Alva", "6.1.1"}, {"Amelie", "6.1.1"}, {"Anna", "6.3.1"}, {"Audrey", "6.3.1"}, {"Ava", "6.3.1"}, {"Bad News", "3.6"}, {"Bahh", "3.6"}, {"Bells", "3.6"}, {"Boing", "3.6"}, {"Bruce", "3.6"}, {"Bubbles", "3.6"}, {"Carmit", "6.1.1"}, {"Cellos", "3.6"}, {"Damayanti", "6.1.1"}, {"Daniel", "6.3.1"}, {"Deranged", "3.6"}, {"Diego", "6.1.1"}, {"Ellen", "6.1.1"}, {"Emily", "2.0.3"}, {"Fiona", "6.1.1"}, {"Fred", "3.6"}, {"Good News", "3.6"}, {"Hysterical", "3.6"}, {"Ioana", "6.1.1"}, {"Jill", "2.0.3"}, {"Joana", "6.1.1"}, {"Jorge", "6.1.1"}, {"Juan", "6.1.1"}, {"Junior", "3.6"}, {"Kanya", "6.1.1"}, {"Karen", "6.3.1"}, {"Kate", "6.3.1"}, {"Kathy", "3.6"}, {"Kyoko", "6.3.1"}, {"Laura", "6.1.1"}, {"Lee", "6.3.1"}, {"Lekha", "6.1.1"}, {"Luca", "6.1.1"}, {"Luciana", "6.1.1"}, {"Maged", "6.1.1"}, {"Mariska", "6.1.1"}, {"Mei-Jia", "6.1.1"}, {"Melina", "6.1.1"}, {"Milena", "6.1.1"}, {"Moira", "6.1.1"}, {"Monica", "6.1.1"}, {"Nora", "6.1.1"}, {"Otoya", "6.3.1"}, {"Paulina", "6.1.1"}, {"Pipe Organ", "3.6"}, {"Princess", "3.6"}, {"Ralph", "3.6"}, {"Samantha", "6.3.1"}, {"Sara", "6.1.1"}, {"Satu", "6.1.1"}, {"Serena", "6.3.1"}, {"Sin-ji", "6.1.1"}, {"Tessa", "6.1.1"}, {"Thomas", "6.1.1"}, {"Ting-Ting", "6.3.1"}, {"Tom", "6.3.1"}, {"Trinoids", "3.6"}, {"Veena", "6.1.1"}, {"Vicki", "3.6"}, {"Victoria", "3.6"}, {"Whisper", "3.6"}, {"Xander", "6.1.1"}, {"Yelda", "6.1.1"}, {"Yuna", "6.3.1"}, {"Yuri", "6.1.1"}, {"Zarvox", "3.6"}, {"Zosia", "6.1.1"}, {"Zuzana", "6.1.1"}}

–Get TTS Voice names and versions
on getVoiceNamesAndVers()
  set aList to {}
  
  
set nameList to (current application’s NSSpeechSynthesizer’s availableVoices()) as list
  
repeat with i in nameList
    set j to contents of i
    
set aDic to ((current application’s NSSpeechSynthesizer’s attributesForVoice:j))
    
set aName to (aDic’s VoiceName) as string
    
set aVer to (aDic’s VoiceVersion) as string
    
set the end of aList to {aName, aVer}
  end repeat
  
  
return aList as list
end getVoiceNamesAndVers

★Click Here to Open This Script 

Posted in list System | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

noteのオンラインマガジン「猛者」に新規Noteを寄稿(3)

Posted on 5月 28, 2018 by Takaaki Naganoya

オンラインマガジンApp Engineer Journal “猛者”(モサ)に「Appleに関するウワサ話を実際に検証(上)」「Appleに関するウワサ話を実際に検証(下)」を寄稿しました。

Posted in 未分類 | Leave a comment

現在のスライド上のshapeオブジェクトのうち一番上のものに他のものの幅をそろえる

Posted on 5月 27, 2018 by Takaaki Naganoya

Keynoteの現在のスライド上のshapeオブジェクトのうち、一番上のものに他のものの幅をそろえるAppleScriptです。

いっそ、Shapeオブジェクトのboundsをすべて取得して、横長か縦長かを計算し、自動で基準オブジェクトを上にするか左のものにするかを判定してもよいのですが、少しやりすぎな感じもするので、現状のままにしてあります。

AppleScript名:現在のスライド上のshapeオブジェクトのうち一番上のものに他のものの幅をそろえる
— Created 2018-05-25 by Takaaki Naganoya
— 2018 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use bPlus : script "BridgePlus" –https://www.macosxautomation.com/applescript/apps/BridgePlus.html

tell application "Keynote"
  tell front document
    tell (current slide)
      — すべてのshapeオブジェクトの座標{x,y}を返す
      
set pList to position of every shape
      
      
— shapeオブジェクトの全座標を昇順ソートして最もX座標値が小さいものを返す
      
set mostLeftPos to first item of sort2DList(pList) of me
      
      
— 一番X座標値が小さい(=左にある)オブジェクトを特定
      
set mostLeftObj to first item of (every shape whose position is equal to mostLeftPos)
      
set mostLeftProp to properties of mostLeftObj
      
–> (*class:shape, opacity:100, parent:slide 5 of document id 253165F1-0596-4E72-B9E3-2AB6D6084125, reflection showing:false, background fill type:color fill, position:32, 160, object text:, width:56, rotation:0, reflection value:0, height:467, locked:false*)
      
      
set mostLeftHeight to height of mostLeftProp
      
set mostLeftWidth to width of mostLeftProp
      
      
— 「一番左」以外のshapeオブジェクトへの参照を取得して一気にオブジェクトのwidthをそろえる
      
set otherShape to a reference to (every shape whose position is not equal to mostLeftPos)
      
set width of otherShape to mostLeftWidth
    end tell
  end tell
end tell

on sort2DList(aList)
  load framework
  
set sortIndexes to {1} –Key Item id: begin from 0
  
set sortOrders to {true} –ascending = true
  
set sortTypes to {"compare:"}
  
set resList to (current application’s SMSForder’s subarraysIn:(aList) sortedByIndexes:sortIndexes ascending:sortOrders sortTypes:sortTypes |error|:(missing value)) as list
  
return resList
end sort2DList

★Click Here to Open This Script 

Posted in Sort | Tagged 10.11savvy 10.12savvy 10.13savvy Keynote | Leave a comment

Finderで選択中のPDFを古い順に連結する v2

Posted on 5月 27, 2018 by Takaaki Naganoya

Finder上で選択中のファイルのうちPDFだけを作成日付で古い順に連結するAppleScriptです。

間違ってPDF以外のファイルを選択してしまった場合でも、それについては無視します。

こんな風にmacOS標準装備のScript Menuに入れて利用しています。

AppleScript名:Finderで選択中のPDFを古い順に連結する v2
— Created 2018-05-26 by Takaaki Naganoya
— 2018 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "Quartz"

property |NSURL| : a reference to current application’s |NSURL|
property NSArray : a reference to current application’s NSArray
property NSPredicate : a reference to current application’s NSPredicate
property NSFileManager : a reference to current application’s NSFileManager
property NSURLPathKey : a reference to current application’s NSURLPathKey
property NSMutableArray : a reference to current application’s NSMutableArray
property NSSortDescriptor : a reference to current application’s NSSortDescriptor
property NSURLIsPackageKey : a reference to current application’s NSURLIsPackageKey
property NSURLIsDirectoryKey : a reference to current application’s NSURLIsDirectoryKey
property NSURLTypeIdentifierKey : a reference to current application’s NSURLTypeIdentifierKey
property NSURLContentModificationDateKey : a reference to current application’s NSURLContentModificationDateKey
property NSDirectoryEnumerationSkipsHiddenFiles : a reference to current application’s NSDirectoryEnumerationSkipsHiddenFiles

–set inFiles to (choose file of type {"pdf"} with prompt "Choose your PDF files:" with multiple selections allowed)
tell application "Finder"
  set inFiles to selection as alias list
end tell

if inFiles = {} then return

–指定のAlias listのうちPDFのみ抽出
set filRes1 to filterAliasListByUTI(inFiles, "com.adobe.pdf") of me

–選択中のファイルのうちの1つから親フォルダを求め、出力先ファイルパスを組み立てる
set outPathTarg to POSIX path of (first item of filRes1)
set pathString to current application’s NSString’s stringWithString:outPathTarg
set newPath to (pathString’s stringByDeletingLastPathComponent()) as string
set destPosixPath to newPath & "/" & ((current application’s NSUUID’s UUID()’s UUIDString()) as string) & ".pdf"

combinePDFsAndSaveIt(filRes1, destPosixPath) of me

on combinePDFsAndSaveIt(inFiles, destPosixPath)
  set inFilesSorted to my filesInListSortFromOldToNew(inFiles)
  
  
— make URL of the first PDF
  
set inNSURL to current application’s |NSURL|’s fileURLWithPath:(POSIX path of item 1 of inFilesSorted)
  
set theDoc to current application’s PDFDocument’s alloc()’s initWithURL:inNSURL
  
  
— loop through the rest
  
set oldDocCount to theDoc’s pageCount()
  
set inFilesSorted to rest of inFilesSorted
  
  
repeat with aFile in inFilesSorted
    set inNSURL to (current application’s |NSURL|’s fileURLWithPath:(POSIX path of aFile))
    
set newDoc to (current application’s PDFDocument’s alloc()’s initWithURL:inNSURL)
    
    
set newDocCount to newDoc’s pageCount()
    
repeat with i from 1 to newDocCount
      set thePDFPage to (newDoc’s pageAtIndex:(i – 1)) — zero-based indexes
      (
theDoc’s insertPage:thePDFPage atIndex:oldDocCount)
      
set oldDocCount to oldDocCount + 1
    end repeat
    
  end repeat
  
  
set outNSURL to current application’s |NSURL|’s fileURLWithPath:destPosixPath
  (
theDoc’s writeToURL:outNSURL)
end combinePDFsAndSaveIt

on filesInListSortFromOldToNew(aliasList)
  set keysToRequest to {NSURLPathKey, NSURLIsPackageKey, NSURLIsDirectoryKey, NSURLContentModificationDateKey}
  
  
set valuesNSArray to NSMutableArray’s array()
  
repeat with i in aliasList
    set oneNSURL to (|NSURL|’s fileURLWithPath:(POSIX path of i))
    (
valuesNSArray’s addObject:(oneNSURL’s resourceValuesForKeys:keysToRequest |error|:(missing value)))
  end repeat
  
  
set theNSPredicate to NSPredicate’s predicateWithFormat_("%K == NO OR %K == YES", NSURLIsDirectoryKey, NSURLIsPackageKey)
  
set valuesNSArray to valuesNSArray’s filteredArrayUsingPredicate:theNSPredicate
  
  
set theDescriptor to NSSortDescriptor’s sortDescriptorWithKey:(NSURLContentModificationDateKey) ascending:true
  
set theSortedNSArray to valuesNSArray’s sortedArrayUsingDescriptors:{theDescriptor}
  
  
— extract just the paths and convert to an AppleScript list
  
return (theSortedNSArray’s valueForKey:(NSURLPathKey)) as list
end filesInListSortFromOldToNew

–Alias listから指定UTIに含まれるものをPOSIX pathのリストで返す
on filterAliasListByUTI(aList, targUTI)
  set newList to {}
  
repeat with i in aList
    set j to POSIX path of i
    
set tmpUTI to my retUTIfromPath(j)
    
set utiRes to my filterUTIList({tmpUTI}, targUTI)
    
if utiRes is not equal to {} then
      set the end of newList to j
    end if
  end repeat
  
return newList
end filterAliasListByUTI

–指定のPOSIX pathのファイルのUTIを求める
on retUTIfromPath(aPOSIXPath)
  set aURL to |NSURL|’s fileURLWithPath:aPOSIXPath
  
set {theResult, theValue} to aURL’s getResourceValue:(reference) forKey:NSURLTypeIdentifierKey |error|:(missing value)
  
  
if theResult = true then
    return theValue as string
  else
    return theResult
  end if
end retUTIfromPath

–UTIリストが指定UTIに含まれているかどうか演算を行う
on filterUTIList(aUTIList, aUTIstr)
  set anArray to NSArray’s arrayWithArray:aUTIList
  
set aPred to NSPredicate’s predicateWithFormat_("SELF UTI-CONFORMS-TO %@", aUTIstr)
  
set bRes to (anArray’s filteredArrayUsingPredicate:aPred) as list
  
return bRes
end filterUTIList

★Click Here to Open This Script 

Posted in file PDF Sort UTI | Tagged 10.11savvy 10.12savvy 10.13savvy Finder | Leave a comment

Finderで選択中のファイルのうち、指定UTIに含まれるものを返す

Posted on 5月 26, 2018 by Takaaki Naganoya

Finder上で選択中のファイルのうち、指定UTIに含まれるもの(下位階層のUTIも含む)を返すAppleScriptです。

Finderでfileのkindを指定してフィルタ参照でしぼりこむ方法もありますが、ファイル数が増えると処理速度が大幅に低下するのと、UTIで指定できたほうが便利なので作っておきました。

AppleScript名:Finderで選択中のファイルのうち、指定UTIに含まれるものを返す
— Created 2018-05-26 by Takaaki Naganoya
— 2018 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

property NSURLTypeIdentifierKey : a reference to current application’s NSURLTypeIdentifierKey
property |NSURL| : a reference to current application’s |NSURL|
property NSPredicate : a reference to current application’s NSPredicate
property NSArray : a reference to current application’s NSArray

tell application "Finder"
  set aSel to selection as alias list
end tell
if aSel = {} then its return

set filRes1 to filterAliasListByUTI(aSel, "com.adobe.pdf") of me
–>  {​​​​​"/Users/me/Pictures/annotation_origin.pdf"​​​}

set filRes2 to filterAliasListByUTI(aSel, "public.image") of me
–>  {"/Users/me/Pictures/スクリーンショット 2017-11-06 20.05.30.png", "/Users/me/Pictures/スクリーンショット 2017-09-27 19.35.08.png", "/Users/me/Pictures/スクリーンショット 2017-09-27 19.33.53.png", "/Users/me/Pictures/スクリーンショット 2017-09-26 16.46.29.png"}

set filRes3 to filterAliasListByUTI(aSel, "public.item") of me
–>  {"/Users/me/Pictures/スクリーンショット 2017-11-06 20.05.30.png", "/Users/me/Pictures/annotation_origin.pdf", "/Users/me/Pictures/スクリーンショット 2017-09-27 19.35.08.png", "/Users/me/Pictures/スクリーンショット 2017-09-27 19.33.53.png", "/Users/me/Pictures/スクリーンショット 2017-09-26 16.46.29.png"}

–Alias listから指定UTIに含まれるものをPOSIX pathのリストで返す
on filterAliasListByUTI(aList, targUTI)
  set newList to {}
  
repeat with i in aList
    set j to POSIX path of i
    
set tmpUTI to my retUTIfromPath(j)
    
set utiRes to my filterUTIList({tmpUTI}, targUTI)
    
if utiRes is not equal to {} then
      set the end of newList to j
    end if
  end repeat
  
return newList
end filterAliasListByUTI

–指定のPOSIX pathのファイルのUTIを求める
on retUTIfromPath(aPOSIXPath)
  set aURL to |NSURL|’s fileURLWithPath:aPOSIXPath
  
set {theResult, theValue} to aURL’s getResourceValue:(reference) forKey:NSURLTypeIdentifierKey |error|:(missing value)
  
  
if theResult = true then
    return theValue as string
  else
    return theResult
  end if
end retUTIfromPath

–UTIリストが指定UTIに含まれているかどうか演算を行う
on filterUTIList(aUTIList, aUTIstr)
  set anArray to NSArray’s arrayWithArray:aUTIList
  
set aPred to NSPredicate’s predicateWithFormat_("SELF UTI-CONFORMS-TO %@", aUTIstr)
  
set bRes to (anArray’s filteredArrayUsingPredicate:aPred) as list
  
return bRes
end filterUTIList

★Click Here to Open This Script 

Posted in file UTI | Tagged 10.11savvy 10.12savvy 10.13savvy Finder | Leave a comment

現在のスライド上のshapeオブジェクトのうち一番左のものに他のものの高さをそろえる

Posted on 5月 25, 2018 by Takaaki Naganoya

Keynoteの現在のスライド上のshapeオブジェクトのうち、一番左のものに他のものの高さをそろえるAppleScriptです。

AppleScript名:現在のスライド上のshapeオブジェクトのうち一番左のものに他のものの高さをそろえる
— Created 2018-05-25 by Takaaki Naganoya
— 2018 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use bPlus : script "BridgePlus" –https://www.macosxautomation.com/applescript/apps/BridgePlus.html

tell application "Keynote"
  tell front document
    tell (current slide)
      — すべてのshapeオブジェクトの座標{x,y}を返す
      
set pList to position of every shape
      
      
— shapeオブジェクトの全座標を昇順ソートして最もX座標値が小さいものを返す
      
set mostLeftPos to first item of sort2DList(pList) of me
      
      
— 一番X座標値が小さい(=左にある)オブジェクトを特定
      
set mostLeftObj to first item of (every shape whose position is equal to mostLeftPos)
      
set mostLeftProp to properties of mostLeftObj
      
–> (*class:shape, opacity:100, parent:slide 5 of document id 253165F1-0596-4E72-B9E3-2AB6D6084125, reflection showing:false, background fill type:color fill, position:32, 160, object text:, width:56, rotation:0, reflection value:0, height:467, locked:false*)
      
      
set mostLeftHeight to height of mostLeftProp
      
set mostLeftWidth to width of mostLeftProp
      
      
— 「一番左」以外のshapeオブジェクトへの参照を取得して一気にオブジェクトのHeightをそろえる
      
set otherShape to a reference to (every shape whose position is not equal to mostLeftPos)
      
set height of otherShape to mostLeftHeight
    end tell
  end tell
end tell

on sort2DList(aList)
  load framework
  
set sortIndexes to {0} –Key Item id: begin from 0
  
set sortOrders to {true} –ascending = true
  
set sortTypes to {"compare:"}
  
set resList to (current application’s SMSForder’s subarraysIn:(aList) sortedByIndexes:sortIndexes ascending:sortOrders sortTypes:sortTypes |error|:(missing value)) as list
  
return resList
end sort2DList

★Click Here to Open This Script 

Posted in Sort | Tagged 10.11savvy 10.12savvy 10.13savvy Keynote | Leave a comment

ディスプレイを回転させる

Posted on 5月 25, 2018 by Takaaki Naganoya

指定のディスプレイを回転(表示方向を変更)させるAppleScriptです。

–> Watch Demo Movie

ディスプレイの表示方向の変更には、fb-rotateというコマンドラインツールを用いています。

fb-rotateをバンドル内に内蔵して呼び出すことが多く、AppleScript Librariesとして呼び出してもよいでしょう。

–> AppleScript Bundle file with fb-rotate


▲0°(MacBook Air 11)


▲90°(MacBook Air 11)


▲180°(MacBook Air 11)


▲270°(MacBook Air 11)

AppleScript名:ディスプレイを回転させる
— Created 2016-03-11 by Takaaki Naganoya
— 2018 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

–fb-rotate
–http://modbookish.lefora.com/topic/3513246/A-Unix-Utility-to-Change-the-Primary-Display-on-OSX/#.VuIe82OFlro

–ディスプレイの情報を取得(基本情報)
getDisplayList() of me
–> {{dispID:"0x4248387", dispWidth:1920, dispHeight:1200, mainD:true}, {dispID:"0x424b104", dispWidth:1920, dispHeight:1200, mainD:false}, {dispID:"0x1b557a25", dispWidth:1920, dispHeight:1080, mainD:false}}

–メインディスプレイを回転させる
rotateMainDisplayToDegree(0) of me –いったんこれを実行すると、構成によってはメインディスプレイが他のIDのものに変わる可能性がある

–ディスプレイの詳細情報を取得
getDisplayInformation() of me
–>  {​​​​​{​​​​​​​dispID:"0x4248387", ​​​​​​​dispWidth:1920, ​​​​​​​dispHeight:1200, ​​​​​​​dispX1:0, ​​​​​​​dispY1:0, ​​​​​​​dispX2:1920, ​​​​​​​dispY2:1200, ​​​​​​​mainD:true, ​​​​​​​rotationDegree:0, ​​​​​​​cousorExists:false​​​​​}, ​​​​​{​​​​​​​dispID:"0x424b104", ​​​​​​​dispWidth:1920, ​​​​​​​dispHeight:1200, ​​​​​​​dispX1:-1920, ​​​​​​​dispY1:0, ​​​​​​​dispX2:0, ​​​​​​​dispY2:1200, ​​​​​​​mainD:false, ​​​​​​​rotationDegree:0, ​​​​​​​cousorExists:true​​​​​}, ​​​​​{​​​​​​​dispID:"0x1b557a25", ​​​​​​​dispWidth:1080, ​​​​​​​dispHeight:1920, ​​​​​​​dispX1:1920, ​​​​​​​dispY1:-362, ​​​​​​​dispX2:3000, ​​​​​​​dispY2:1558, ​​​​​​​mainD:false, ​​​​​​​rotationDegree:270, ​​​​​​​cousorExists:false​​​​​}​​​}

on getDisplayInformation()
  set aPath to POSIX path of (path to me) & "Contents/Resources/fb-rotate"
  
try
    set aRes to (do shell script (quoted form of aPath) & " -i")
  on error
    return false
  end try
  
  
set aList to paragraphs of aRes
  
set aaList to contents of (items 2 thru -2 of aList)
  
  
set a to contents of last item of aList
  
set {b, c} to separateStrByAChar(a, ":") of me
  
set {b1, c1} to separateStrByAChar(c, ",") of me
  
set mouseX to returnNumberCharsOnly(b1) as number
  
set mouseY to returnNumberCharsOnly(c1) as number
  
  
set recList to {}
  
  
repeat with i in aaList
    set j to contents of i
    
    
–Parse Result by space character
    
set aStr to (current application’s NSString’s stringWithString:j)
    
set aLine to (aStr’s componentsSeparatedByString:" ")
    (
aLine’s removeObject:"")
    
set bList to aLine as list
    
–>  {​​​​​"3", ​​​​​"0x4248387", ​​​​​"1920×1200", ​​​​​"0", ​​​​​"0", ​​​​​"-1920", ​​​​​"-1200", ​​​​​"0", ​​​​​"[main]"​​​}
    
    
–Display ID
    
set anID to contents of item 2 of bList
    
    
–Resolution
    
set aResol to contents of item 3 of bList
    
set dParseRes to separateStrByACharAndReturnNumList(aResol, "x") of me
    
if dParseRes = "" then exit repeat –Error
    
copy dParseRes to {aWidth, aHeight}
    
    
–Display_Bounds
    
set dX1 to (contents of item 4 of bList) as number
    
set dY1 to (contents of item 5 of bList) as number
    
set dX2 to (contents of item 6 of bList) as number
    
set dY2 to (contents of item 7 of bList) as number
    
    
–Rotation
    
set aDeg to (contents of item 8 of bList) as number
    
    
–Mouse Cursor Detection
    
set mouseF to (dX1 ≤ mouseX) and (mouseX ≤ dX2) and (dY1 ≤ mouseY) and (mouseY ≤ dY2)
    
    
–Main Display (Menu)
    
set aMain to contents of last item of bList
    
if (contents of last item of bList) contains "main" then
      set aMainF to true
    else
      set aMainF to false
    end if
    
    
set the end of recList to {dispID:anID, dispWidth:aWidth, dispHeight:aHeight, dispX1:dX1, dispY1:dY1, dispX2:dX2, dispY2:dY2, mainD:aMainF, rotationDegree:aDeg, cousorExists:mouseF}
  end repeat
  
  
return recList
  
end getDisplayInformation

–指定IDのディスプレイを指定角度(0, 90, 180, 270のいずれか)に回転させる
on rotateADisplayToDegree(aDispID as string, aDegree as integer)
  if aDegree is not in {0, 90, 180, 270} then return false
  
set aPath to POSIX path of (path to me) & "Contents/Resources/fb-rotate"
  
try
    set aRes to (do shell script (quoted form of aPath) & " -d " & aDispID & " -r " & (aDegree as string))
  on error
    return false
  end try
end rotateADisplayToDegree

–メインディスプレイを指定角度(0, 90, 180, 270のいずれか)に回転させる
on rotateMainDisplayToDegree(aDegree as integer)
  if aDegree is not in {0, 90, 180, 270} then return false
  
set mainID to getMainDispID() of me
  
set aPath to POSIX path of (path to me) & "Contents/Resources/fb-rotate"
  
try
    set aRes to (do shell script (quoted form of aPath) & " -d " & mainID & " -r " & (aDegree as string))
  on error
    return false
  end try
end rotateMainDisplayToDegree

–メインディスプレイのIDを取得する
on getMainDispID()
  set dList to getDisplayList() of me
  
set dDict to current application’s NSArray’s arrayWithArray:dList
  
set aRes to filterRecListByLabel1(dDict, "mainD == true") of me
  
set aMainD to contents of first item of aRes
  
set mainID to dispID of aMainD
  
return mainID
end getMainDispID

–実行中のMacに接続されているディスプレイの一覧を取得する
on getDisplayList()
  set aPath to POSIX path of (path to me) & "Contents/Resources/fb-rotate"
  
try
    set aRes to (do shell script (quoted form of aPath) & " -l")
  on error
    return false
  end try
  
set aList to paragraphs of aRes
  
set aaList to contents of (items 2 thru -1 of aList)
  
  
set recList to {}
  
  
repeat with i in aaList
    set j to contents of i
    
set bList to words of j
    
set anID to contents of item 1 of bList
    
set aResol to contents of item 2 of bList
    
set dParseRes to separateStrByACharAndReturnNumList(aResol, "x") of me
    
if dParseRes = "" then exit repeat –Error
    
copy dParseRes to {aWidth, aHeight}
    
    
set aMain to contents of last item of bList
    
if j ends with "]" then
      set aMainF to true
    else
      set aMainF to false
    end if
    
set the end of recList to {dispID:anID, dispWidth:aWidth, dispHeight:aHeight, mainD:aMainF}
  end repeat
  
  
recList
end getDisplayList

–"1920×1200" といった文字列を"x"でparseしてパラメータを分ける。結果は文字列のリストで返す
on separateStrByAChar(aStr as string, aChar as string)
  if aStr does not contain aChar then return ""
  
if length of aChar is not equal to 1 then return ""
  
if aStr = "" or (length of aStr < 3) then return ""
  
set aPos to offset of aChar in aStr
  
set partA to text 1 thru (aPos – 1) of aStr
  
set partB to text (aPos + 1) thru -1 of aStr
  
return {partA, partB}
end separateStrByAChar

–"1920×1200" といった文字列を"x"でparseしてパラメータを分ける。結果は整数のリストで返す
on separateStrByACharAndReturnNumList(aStr as string, aChar as string)
  if aStr does not contain aChar then return ""
  
if length of aChar is not equal to 1 then return ""
  
if aStr = "" or (length of aStr < 3) then return ""
  
set aPos to offset of aChar in aStr
  
set partA to (text 1 thru (aPos – 1) of aStr) as number
  
set partB to (text (aPos + 1) thru -1 of aStr) as number
  
return {partA, partB}
end separateStrByACharAndReturnNumList

–リストに入れたレコードを、指定の属性ラベルの値で抽出
on filterRecListByLabel1(aRecList as list, aPredicate as string)
  set aArray to current application’s NSArray’s arrayWithArray:aRecList
  
set aPredicate to current application’s NSPredicate’s predicateWithFormat:aPredicate
  
set filteredArray to aArray’s filteredArrayUsingPredicate:aPredicate
  
set bList to filteredArray as list
  
return bList
end filterRecListByLabel1

–数字とプラスマイナスの符号のみ返す
on returnNumberCharsOnly(aStr)
  set anNSString to current application’s NSString’s stringWithString:aStr
  
set anNSString to anNSString’s stringByReplacingOccurrencesOfString:"[^0-9-+]" withString:"" options:(current application’s NSRegularExpressionSearch) range:{0, anNSString’s |length|()}
  
return anNSString as text
end returnNumberCharsOnly

★Click Here to Open This Script 

Posted in System | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

OS X 10.11.5+Safari 9.1.1以降で、新たなAS制限機能が増える

Posted on 5月 24, 2018 by Takaaki Naganoya

macOS 10.11.5+Safari 9.1.1以降で、新たなAppleScriptの制限機能が増えました。Safariに対してdo javascriptコマンドによるコマンド実行が可能でしたが、これがデフォルト設定では禁止状態になったということです。

macOS 10.12.x系では、macOS 10.12.6+Safari 11.1にて、macOS 10.13.x系ではmacOS 10.13.5+Safari 11.1.1上にて確認しています。

■デフォルトでdo javascriptコマンドによる制御がオフに

これ以前のmacOSではデフォルトでオンになっていたので、一回オンにする作業が必要になりました(管理者パスワード必要)。

・STEP1 「開発」メニューをオンに
Safariの「環境設定」>「詳細」で、「メニューバーに”開発”メニューを表示」をオンにします。これで、Safariのメニューバーに「開発」メニューが表示されます。

・STEP2 「開発」メニューから「AppleEventからのJavaScriptを許可」「スマート検索フィールドからのJavaScriptを許可」の2つの項目をオンに(管理者パスワード必要)

AppleScript名:最前面のウィンドウのタイトルを取得する
tell application "Safari"
  set aRes to do JavaScript "document.title;" in front document
  
display dialog aRes
end tell

★Click Here to Open This Script 


▲デフォルト状態


▲「開発」メニューからJavaScriptの実行を許可した状態

Posted in JavaScript Security | Tagged 10.11savvy 10.12savvy 10.13savvy Safari | Leave a comment

Post navigation

  • Older posts
  • Newer posts

電子書籍(PDF)をオンラインストアで販売中!

Google Search

Popular posts

  • 開発機としてM2 Mac miniが来たのでガチレビュー
  • macOS 15, Sequoia
  • 指定のWordファイルをPDFに書き出す
  • Pages本執筆中に、2つの書類モード切り替えに気がついた
  • Numbersで選択範囲のセルの前後の空白を削除
  • メキシカンハットの描画
  • Pixelmator Pro v3.6.4でAppleScriptからの操作時の挙動に違和感が
  • AdobeがInDesign v19.4からPOSIX pathを採用
  • AppleScriptによる並列処理
  • Safariで「プロファイル」機能を使うとAppleScriptの処理に影響
  • macOS 14.xでScript Menuの実行速度が大幅に下がるバグ
  • AppleScript入門③AppleScriptを使った「自動化」とは?
  • macOS 15でも変化したText to Speech環境
  • Keynote/Pagesで選択中の表カラムの幅を均等割
  • デフォルトインストールされたフォント名を取得するAppleScript
  • macOS 15 リモートApple Eventsにバグ?
  • AppleScript入門① AppleScriptってなんだろう?
  • macOS 14で変更になったOSバージョン取得APIの返り値
  • Script Debuggerの開発と販売が2025年に終了
  • 【続報】macOS 15.5で特定ファイル名パターンのfileをaliasにcastすると100%クラッシュするバグ

Tags

10.11savvy (1101) 10.12savvy (1242) 10.13savvy (1391) 10.14savvy (587) 10.15savvy (438) 11.0savvy (283) 12.0savvy (212) 13.0savvy (194) 14.0savvy (147) 15.0savvy (132) CotEditor (66) Finder (51) iTunes (19) Keynote (117) NSAlert (61) NSArray (51) NSBitmapImageRep (20) NSBundle (20) NSButton (34) NSColor (53) NSDictionary (28) NSFileManager (23) NSFont (21) NSImage (41) NSJSONSerialization (21) NSMutableArray (63) NSMutableDictionary (22) NSPredicate (36) NSRunningApplication (56) NSScreen (30) NSScrollView (22) NSString (119) NSURL (98) NSURLRequest (23) NSUTF8StringEncoding (30) NSView (33) NSWorkspace (20) Numbers (76) Pages (55) Safari (44) Script Editor (27) WKUserContentController (21) WKUserScript (20) WKWebView (23) WKWebViewConfiguration (22)

カテゴリー

  • 2D Bin Packing
  • 3D
  • AirDrop
  • AirPlay
  • Animation
  • AppleScript Application on Xcode
  • Beginner
  • Benchmark
  • beta
  • Bluetooth
  • Books
  • boolean
  • bounds
  • Bug
  • Calendar
  • call by reference
  • check sum
  • Clipboard
  • Cocoa-AppleScript Applet
  • Code Sign
  • Color
  • Custom Class
  • date
  • dialog
  • diff
  • drive
  • Droplet
  • exif
  • file
  • File path
  • filter
  • folder
  • Font
  • Font
  • GAME
  • geolocation
  • GUI
  • GUI Scripting
  • Hex
  • History
  • How To
  • iCloud
  • Icon
  • Image
  • Input Method
  • Internet
  • iOS App
  • JavaScript
  • JSON
  • JXA
  • Keychain
  • Keychain
  • Language
  • Library
  • list
  • Locale
  • Localize
  • Machine Learning
  • Map
  • Markdown
  • Menu
  • Metadata
  • MIDI
  • MIME
  • Natural Language Processing
  • Network
  • news
  • Noification
  • Notarization
  • Number
  • Object control
  • OCR
  • OSA
  • parallel processing
  • PDF
  • Peripheral
  • PRODUCTS
  • QR Code
  • Raw AppleEvent Code
  • Record
  • rectangle
  • recursive call
  • regexp
  • Release
  • Remote Control
  • Require Control-Command-R to run
  • REST API
  • Review
  • RTF
  • Sandbox
  • Screen Saver
  • Script Libraries
  • sdef
  • search
  • Security
  • selection
  • shell script
  • Shortcuts Workflow
  • Sort
  • Sound
  • Spellchecker
  • Spotlight
  • SVG
  • System
  • Tag
  • Telephony
  • Text
  • Text to Speech
  • timezone
  • Tools
  • Update
  • URL
  • UTI
  • Web Contents Control
  • WiFi
  • XML
  • XML-RPC
  • イベント(Event)
  • 未分類

アーカイブ

  • 2025年5月
  • 2025年4月
  • 2025年3月
  • 2025年2月
  • 2025年1月
  • 2024年12月
  • 2024年11月
  • 2024年10月
  • 2024年9月
  • 2024年8月
  • 2024年7月
  • 2024年6月
  • 2024年5月
  • 2024年4月
  • 2024年3月
  • 2024年2月
  • 2024年1月
  • 2023年12月
  • 2023年11月
  • 2023年10月
  • 2023年9月
  • 2023年8月
  • 2023年7月
  • 2023年6月
  • 2023年5月
  • 2023年4月
  • 2023年3月
  • 2023年2月
  • 2023年1月
  • 2022年12月
  • 2022年11月
  • 2022年10月
  • 2022年9月
  • 2022年8月
  • 2022年7月
  • 2022年6月
  • 2022年5月
  • 2022年4月
  • 2022年3月
  • 2022年2月
  • 2022年1月
  • 2021年12月
  • 2021年11月
  • 2021年10月
  • 2021年9月
  • 2021年8月
  • 2021年7月
  • 2021年6月
  • 2021年5月
  • 2021年4月
  • 2021年3月
  • 2021年2月
  • 2021年1月
  • 2020年12月
  • 2020年11月
  • 2020年10月
  • 2020年9月
  • 2020年8月
  • 2020年7月
  • 2020年6月
  • 2020年5月
  • 2020年4月
  • 2020年3月
  • 2020年2月
  • 2020年1月
  • 2019年12月
  • 2019年11月
  • 2019年10月
  • 2019年9月
  • 2019年8月
  • 2019年7月
  • 2019年6月
  • 2019年5月
  • 2019年4月
  • 2019年3月
  • 2019年2月
  • 2019年1月
  • 2018年12月
  • 2018年11月
  • 2018年10月
  • 2018年9月
  • 2018年8月
  • 2018年7月
  • 2018年6月
  • 2018年5月
  • 2018年4月
  • 2018年3月
  • 2018年2月

https://piyomarusoft.booth.pm/items/301502

メタ情報

  • ログイン
  • 投稿フィード
  • コメントフィード
  • WordPress.org

Forum Posts

  • 人気のトピック
  • 返信がないトピック

メタ情報

  • ログイン
  • 投稿フィード
  • コメントフィード
  • WordPress.org
Proudly powered by WordPress
Theme: Flint by Star Verte LLC