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

カテゴリー: list

NSIndexSetを作成し、各index要素を取り出す

Posted on 3月 30 by Takaaki Naganoya

NSIndexSetを作成し、そこから各インデックス(数値)を取り出すAppleScriptです。

{3, 4, 5, 6, 7}

から構成されるNSIndexSetを作成して処理すると、

{3, 4, 5, 6, 7}

が返ってきます。

NSTableViewで複数行選択時の行インデックスを取得する際に、NSIndexSetで結果が返ってきたので、ChatGPTに書かせてみました。

本Script内でNSIndexSet内の各インデックス数値に対してオフセット加算ができるようにしているのは、このNSTableViewで1行目が0と返ってくる仕様のためで、AppleScriptと合わせるために+1のオフセット加算を行う必要があったためこのようになっています。

NSTableViewで複数行を選択すると、結果がNSIndexSetで返ってくる

初回から動くコードは返してこなかったものの、何回かやりとりしている間に、書き直せばなんとかなりそうだったので、引き継いで手で書いてみました。CocoaのAPI呼び出しはプログラミングではなくパズルみたいなものなので、ChatGPTに向いているといえば向いているのですが、AppleScriptObjCがBlocks構文を呼べないとかいった前提条件が認識されていないようなので、「手で描き直した方が速い」ということに。

NSNotFoundについては、Apple側も真面目に実装している風ではない(これを返すことが徹底されているわけではない、と)ので、あてにできないと感じています。

AppleScript名:NSIndexSetを作成し、各index要素を取り出す.scptd
—
–  Created by: Takaaki Naganoya
–  Created on: 2025/03/30
—
–  Copyright © 2025 Piyomaru Software, All Rights Reserved
—

use AppleScript version "2.4" — Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

— サンプルのNSIndexSetを作成(3, 4, 5, 6, 7 を含む)
set indexSet to current application’s NSIndexSet’s indexSetWithIndexesInRange:(current application’s NSMakeRange(3, 5))
set aList to getEachIndexFromIndexSet(indexSet, 0) of me
–> {3, 4, 5, 6, 7}

— インデックスを取得する処理
on getEachIndexFromIndexSet(indexSet, offsetNum)
  set indexList to {}
  
set currentIndex to indexSet’s firstIndex() — 最初のインデックスを取得
  
  
repeat while currentIndex ≠ (current application’s NSNotFound)
    — 取得したインデックスをAppleScriptのリストに追加
    
if currentIndex > 9.99999999E+8 then exit repeat
    
    
set end of indexList to ((currentIndex as number) + offsetNum)
    
    
— 次のインデックスを取得
    
set currentIndex to indexSet’s indexGreaterThanIndex:currentIndex
  end repeat
  
  
return indexList
end getEachIndexFromIndexSet

★Click Here to Open This Script 

AppleScript名:NSIndexSetを作成し、各index要素を取り出す(書き換え後).scptd
—
–  Created by: Takaaki Naganoya
–  Created on: 2025/03/30
—
–  Copyright © 2025 Piyomaru Software, All Rights Reserved
—

use AppleScript version "2.4" — Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

— サンプルのNSIndexSetを作成(3, 4, 5, 6, 7 を含む)
set indexSet to current application’s NSIndexSet’s indexSetWithIndexesInRange:(current application’s NSMakeRange(3, 5))
set aList to getEachIndexFromIndexSet(indexSet, 0) of me
–> {3, 4, 5, 6, 7}

— インデックスを取得する処理
on getEachIndexFromIndexSet(indexSet, offsetNum)
  set indexList to {}
  
set currentIndex to indexSet’s firstIndex() — 最初のインデックスを取得
  
  
— 取得したインデックスをAppleScriptのリストに追加  
  
repeat while currentIndex ≤ 9.99999999E+8
    set end of indexList to ((currentIndex as number) + offsetNum)
    
    
— 次のインデックスを取得
    
set currentIndex to indexSet’s indexGreaterThanIndex:currentIndex
  end repeat
  
  
return indexList
end getEachIndexFromIndexSet

★Click Here to Open This Script 

Posted in list | Tagged 13.0savvy 14.0savvy 15.0savvy NSIndexSet | Leave a comment

Keynoteの現在のスライド上で選択中のテキストをもとに、後続の記事トビラページのタイトルに内容を設定 v2a

Posted on 3月 23 by Takaaki Naganoya

Keynote書類の現在表示中のスライド上で選択中のテキストアイテム(ボックス)の内容をもとに、後続の記事トビラページのタイトルを設定するAppleScriptです。Keynote 14.3+macOS 15.4betaで動作確認していますが、とくにバージョン依存した書き方などは行なっていません。

また、本来はiWork汎用オブジェクトの座標によるソート機能をライブラリとして独立させ、バンドル形式のScript書類に入れてあったのですが、Blog掲載のためにフラットなScriptに書き換えています。

本来、Keynoteのようにスライドのインデント(レベル変更)を行って階層構造を形成できるアプリでは、それぞれのスライド(ページ)のレベルを取得したり変更できることが望ましいのですが、Keynoteの機能セットの範囲内ではAppleScriptからそのような操作は行えません。そこで、各スライドのベースレイアウトに何を用いているかによって擬似的にレベルを判定しています。

KeynoteのAppleScript対応機能はiWork Apps中では屈指の対応度を誇っていますが、レイアウトした画像の内容データにアクセスできないのと、各スライドのレベルの取得/変更が行えない点がものすごく残念です。

電子書籍「Cocoa Scripting Course」の作成用に、以前にも作ったことがあるかもしれませんが、ふたたび作ってしまいました。ちょっと大きめの書き捨てScriptです。


▲Keynote書類の章トビラ上で章の記事内容を示すテキストボックスを選択した状態で本AppleScriptを実行。複数のボックスを選択してあっても、座標値でソートして順番を決定


▲各記事のトビラページに、章トビラから取得したテキストを設定。以下、繰り返し


▲章トビラ上のテキストをすべて記事トビラのタイトルに設定

AppleScript名:現在のスライド上で選択中のテキストをもとに、後続の記事トビラページのタイトルに内容を設定 v2a.scptd
—
–  Created by: Takaaki Naganoya
–  Created on: 2025/03/23
—
–  Copyright © 2025 Piyomaru Software, All Rights Reserved
—

use AppleScript version "2.4" — Yosemite (10.10) or later
use framework "Foundation"
use scripting additions
–use iwoSortLib : script "iWorkObjSortLib"

tell application "Keynote"
  tell front document
    –章扉の上にあるテキストアイテム(各記事タイトルが入っているものと想定、複数可能)を取得
    
set aSelList to selection
    
set bSelList to {}
    
set sCount to count every slide
    
    
    
–画面上で選択しておいたオブジェクトのうち、text itemのみを抽出(念のため)
    
repeat with i in aSelList
      set j to contents of i
      
set aClass to class of j
      
if aClass is text item then
        set the end of bSelList to j
      end if
    end repeat
    
    
set cSelList to sortIWorkObjectsByPositionAndRetObjRef(bSelList, {"positionX", "positionY"}, {true, true}) of iWorkObjSort
    
    
    
–章トビラ上のテキストアイテム(複数可)をループしつつ、中のテキストを行ごとに分解してリスト化
    
–(連結前にあらかじめX座標をもとにソートしておいたほうがいい??)
    
set textList to {}
    
repeat with i in cSelList
      set tmpCon to object text of i
      
set tmpList to paragraphs of tmpCon
      
set textList to textList & tmpList
    end repeat
    
–return textList
    
    
–章トビラのページの情報を取得
    
tell current slide
      set curSlideNum to slide number
      
set curSlideLayout to name of base layout
    end tell
    
    
–章トビラの次のページの情報を取得(ここが必ず記事トビラであるという前提のもとに処理)
    
tell slide (curSlideNum + 1)
      set nextSlideLayout to name of base layout
    end tell
    
    
set targSlideList to {}
    
repeat with i from (curSlideNum + 1) to sCount
      tell slide i
        set tSTheme to name of base layout
        
if tSTheme = curSlideLayout then
          –章トビラを検出したら処理終了
          
exit repeat
        else if tSTheme = nextSlideLayout then
          –扉+1ページのスライド(記事カバー)を検出したら記録
          
set the end of targSlideList to i
        end if
      end tell
    end repeat
    
–return targSlideList
    
    
set iCount to 1
    
repeat with i in targSlideList
      try
        set tmpT to contents of item iCount of textList
        
tell slide i
          set object text of default title item of it to tmpT
        end tell
        
set iCount to iCount + 1
      on error
        return
      end try
    end repeat
  end tell
end tell

–ライブラリとしてバンドル形式のAppleScript書類に組み込んでいたものをBlog掲載用に展開した
script iWorkObjSort
  property parent : AppleScript
  
use AppleScript
  
use framework "Foundation"
  
use framework "AppKit"
  
use scripting additions
  
  
script spd
    property aaSel : {}
  end script
  
  
–Keynote上のiWork ObjをXY座標でソートして結果を返す(App Obj情報はitem noだけ)
  
on sortIWorkObjectsByPosition(aaSel, sortLabelLIst, sortDirectionList)
    tell application "Keynote"
      set aVer to version
      
if aVer < "12.0" then return
      
      
tell front document
        set posList to {}
        
set aCount to 1
        
        
repeat with ii in aaSel
          set jj to contents of ii
          
set bClass to class of jj
          
          
tell jj
            set {posX, posY} to position
            
            
try
              set tmpStr to object text as string
            on error
              set tmpStr to ""
            end try
          end tell
          
          
set the end of posList to {positionX:posX, positionY:posY, objID:aCount, myStr:tmpStr}
          
          
set aCount to aCount + 1
        end repeat
        
        
–座標データをもとにソート
        
set sortedList to sortRecListByLabel(posList, sortLabelLIst, sortDirectionList) of me
        
      end tell
    end tell
    
    
return sortedList
  end sortIWorkObjectsByPosition
  
  
  
–Keynote上のiWork ObjをXY座標でソートして結果を返す(App Objだけ返す)
  
on sortIWorkObjectsByPositionIncludingObjRef(aaSel, sortLabelLIst, sortDirectionList)
    tell application "Keynote"
      set aVer to version
      
if aVer < "12.0" then return
      
      
tell front document
        set posList to {}
        
set aCount to 1
        
        
repeat with ii in aaSel
          set jj to contents of ii
          
set bClass to class of jj
          
          
tell jj
            set {posX, posY} to position
            
            
try
              set tmpStr to object text as string
            on error
              set tmpStr to ""
            end try
          end tell
          
          
set the end of posList to {positionX:posX, positionY:posY, objID:aCount, myStr:tmpStr}
          
          
set aCount to aCount + 1
        end repeat
        
        
–座標データをもとにソート
        
set sortedList to sortRecListByLabel(posList, sortLabelLIst, sortDirectionList) of me
        
        
–データを返す配列にiWork Object への参照を含める
        
set sCount to 1
        
repeat with i from 1 to (length of aaSel)
          set tmpID to objID of contents of item i of sortedList
          
set tmpObj to contents of item tmpID of aaSel
          
set (item tmpID of sortedList) to (item tmpID of sortedList) & {objRef:tmpObj}
        end repeat
      end tell
    end tell
    
    
return sortedList
  end sortIWorkObjectsByPositionIncludingObjRef
  
  
  
–Keynote上のiWork ObjをXY座標でソートして結果を返す(App Obj入りのリストを返す)
  
on sortIWorkObjectsByPositionAndRetObjRef(aaSel, sortLabelLIst, sortDirectionList)
    tell application "Keynote"
      set aVer to version
      
if aVer < "12.0" then return
      
      
tell front document
        set posList to {}
        
set aCount to 1
        
        
repeat with ii in aaSel
          set jj to contents of ii
          
set bClass to class of jj
          
          
tell jj
            set {posX, posY} to position
            
            
try
              set tmpStr to object text as string
            on error
              set tmpStr to ""
            end try
          end tell
          
          
set the end of posList to {positionX:posX, positionY:posY, objID:aCount, myStr:tmpStr}
          
          
set aCount to aCount + 1
        end repeat
        
        
–座標データをもとにソート
        
set sortedList to sortRecListByLabel(posList, sortLabelLIst, sortDirectionList) of me
        
        
–データを返す配列にiWork Object への参照を含める
        
set sCount to 1
        
set retList to {}
        
repeat with i from 1 to (length of aaSel)
          set tmpID to objID of contents of item i of sortedList
          
set tmpObj to contents of item tmpID of aaSel
          
set the end of retList to tmpObj
        end repeat
      end tell
    end tell
    
    
return retList
  end sortIWorkObjectsByPositionAndRetObjRef
  
  
  
–リストに入れたレコードを、指定の属性ラベルの値でソート
  
on sortRecListByLabel(aRecList as list, aLabelStr as list, ascendF as list)
    set aArray to current application’s NSArray’s arrayWithArray:aRecList
    
    
set aCount to length of aLabelStr
    
set sortDescArray to current application’s NSMutableArray’s new()
    
repeat with i from 1 to aCount
      set aLabel to (item i of aLabelStr)
      
set aKey to (item i of ascendF)
      
set sortDesc to (current application’s NSSortDescriptor’s alloc()’s initWithKey:aLabel ascending:aKey)
      (
sortDescArray’s addObject:sortDesc)
    end repeat
    
    
return (aArray’s sortedArrayUsingDescriptors:sortDescArray) as list
  end sortRecListByLabel
  
end script

★Click Here to Open This Script 

Posted in list Sort | Tagged 13.0savvy 14.0savvy 15.0savvy Keynote | Leave a comment

Numbersで選択範囲のdateの年を+1する

Posted on 3月 10 by Takaaki Naganoya

Numbersの書類上で選択中のセル内の日付形式データがあったら、yearを+1(インクリメント)するAppleScriptです。macOS 15.4beta+Numbers 14.3で動作確認していますが、OSバージョンおよびNumbersのバージョンに依存する部分はありません。

実行前

実行後

ものすごくつまらなくて、ものすごく用途が狭いScriptですが、実際に書いてみたら意外と手間取る感じでした。

当然、+1するだけではなくー1する機能も作ってあり、呼び出し部分を差し替えればー1するようになります。macOS標準搭載のスクリプトメニューに入れて実行することを想定しています。

AppleScript名:選択範囲のdateの年を+1する.scptd
—
–  Created by: Takaaki Naganoya
–  Created on: 2025/03/10
—
–  Copyright © 2025 Piyomaru Software, All Rights Reserved
—

use AppleScript version "2.4"
use framework "Foundation"
use scripting additions

tell application "Numbers"
  tell front document
    tell active sheet
      try
        set theTable to first table whose class of selection range is range
        
set cellList to cell of selection range of theTable
        
set valList to value of cell of selection range of theTable
        
set aLen to length of cellList
      on error
        display notification "Numbers: There is no selection"
        
return
      end try
      
      
set bValList to {}
      
repeat with i in valList
        set j to contents of i
        
set aClass to class of j
        
        
if aClass = date then
          set j to incremenetYearOf(j) of me
        end if
        
        
set the end of bValList to j
      end repeat
      
      
      
repeat with i from 1 to aLen
        set aVal to contents of item i of bValList
        
set aCell to contents of item i of cellList
        
        
ignoring application responses
          set value of aCell to aVal
        end ignoring
      end repeat
      
    end tell
  end tell
end tell

on incremenetYearOf(aDate)
  set {bYear, bMonth, bDate} to {year of aDate, month of aDate, day of aDate}
  
set bYear to bYear + 1
  
set {year of aDate, month of aDate, day of aDate} to {bYear, bMonth, bDate}
  
return aDate
end incremenetYearOf

on decremenetYearOf(aDate)
  set {bYear, bMonth, bDate} to {year of aDate, month of aDate, day of aDate}
  
set bYear to bYear – 1
  
set {year of aDate, month of aDate, day of aDate} to {bYear, bMonth, bDate}
  
return aDate
end decremenetYearOf

★Click Here to Open This Script 

Posted in Calendar list | Tagged 13.0savvy 14.0savvy 15.0savvy Numbers | Leave a comment

複数の重複検出ルーチンを順次速度計測

Posted on 2月 6 by Takaaki Naganoya

1D List(1次元配列)の重複項目検出を、複数の方式で速度計測するAppleScriptです。

List(Array)中の重複項目の抽出は、かなりよく出てくる処理です。自分が使っていたルーチンよりも他の人が使っているルーチンのほうが速かったので、ひととおり調べておくべきだと考え、10万項目の乱数データに対して処理してみることに。

テストScriptを書いて実行してみたら、本件では高速化ずみのVanilla ASのハンドラが一番速いという結果が出ました。意外です。

AppleScript名:複数の重複検出ルーチンを順次速度計測.scptd
—
–  Created by: Takaaki Naganoya
–  Created on: 2025/02/05
—
–  Copyright © 2025 Piyomaru Software, All Rights Reserved
—

use AppleScript version "2.4" — Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

script spd
  property aList : {}
  
property bList : {}
end script

–Mesurement data gen.
set (aList of spd) to {}
repeat with i from 1 to 100000
  set the end of (aList of spd) to (random number from 1 to 10000)
end repeat

–Benchmark Code
set hList to {"returnDuplicatesOnly1:", "returnDuplicatesOnly2:", "returnDuplicatesOnly3:"}
set resList to {}

repeat with i in hList
  set nameOfTargetHandler to contents of i
  
  
–Check Handler existence
  
set existsHandler to (me’s respondsToSelector:nameOfTargetHandler) as boolean
  
if existsHandler = true then
    –Call handler
    
set a1Dat to current application’s NSDate’s timeIntervalSinceReferenceDate()
    
    
set aRes to (my performSelector:nameOfTargetHandler withObject:(aList of spd))
    
    
set b1Dat to current application’s NSDate’s timeIntervalSinceReferenceDate()
    
set c1Dat to b1Dat – a1Dat
  else
    error "Handler does not exists"
  end if
  
  
set the end of resList to {nameOfTargetHandler, c1Dat}
end repeat

return resList
–> {{"returnDuplicatesOnly1:", 0.065470099449}, {"returnDuplicatesOnly2:", 2.39611697197}, {"returnDuplicatesOnly3:", 0.038006067276}}

–Cocoa Scripting最速?
on returnDuplicatesOnly1:aList
  set arrayOne to current application’s NSArray’s arrayWithArray:aList
  
set setOne to current application’s NSCountedSet’s alloc()’s initWithArray:(arrayOne)
  
set arrayTwo to (arrayOne’s valueForKeyPath:"@distinctUnionOfObjects.self")
  
set setTwo to current application’s NSCountedSet’s alloc()’s initWithArray:(arrayTwo)
  
setOne’s minusSet:setTwo
  
return setOne’s allObjects() as list –>{3, 6, 4}
end returnDuplicatesOnly1:

–1より遅い
on returnDuplicatesOnly2:(aList as list)
  set aSet to current application’s 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 returnDuplicatesOnly2:

–リスト中から重複項目をリストアップする(Vanilla AS高速化版)
on returnDuplicatesOnly3:(aList)
  script spd
    property aList : {}
    
property dList : {}
  end script
  
  
copy aList to (aList of spd)
  
set aCount to length of (aList of spd)
  
  
set (dList of spd) to {}
  
  
repeat aCount times
    set anItem to contents of (first item of (aList of spd))
    
set (aList of spd) to rest of (aList of spd)
    
    
if {anItem} is in (aList of spd) then
      if {anItem} is not in (dList of spd) then –ここを追加した (v3)
        set the end of (dList of spd) to anItem
      end if
    end if
    
  end repeat
  
  
return (dList of spd)
end returnDuplicatesOnly3:

★Click Here to Open This Script 

Posted in list | Tagged 12.0savvy 13.0savvy 14.0savvy 15.0savvy | Leave a comment

BridgePlusを使わずに1D–>2D list変換 v2

Posted on 2月 5 by Takaaki Naganoya

BridgePlus AppleScript Libraryを使わずに、1D Listを2D Listに変換するAppleScriptの改修版です。

指定アイテム数で1D Listを2D化する処理において、対象listが指定アイテム数の倍数になっていなかった場合にギャップ項目を追加する処理を追加しました。10万項目の1D Listを2D化するのに0.5秒程度で処理できました(M2 MacBook Air)。実用レベルにはあると思われます。

動作OSバージョンには、とくに制限はありません。

AppleScript名:BridgePlusを使わずに1D–>2D list_v2.scptd
—
–  Created by: Takaaki Naganoya
–  Created on: 2025/02/03
—
–  Copyright © 2025 Piyomaru Software, All Rights Reserved
—

use AppleScript version "2.4" — Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

set dList to {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}

set aRes to my subarraysFrom:(dList) groupedBy:6 gapFilledBy:0
–> {{1, 2, 3, 4, 5, 6}, {7, 8, 9, 10, 11, 12}, {13, 14, 15, 16, 0, 0}}

set bRes to my subarraysFrom:(dList) groupedBy:4 gapFilledBy:0
–> {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}}

set cRes to my subarraysFrom:(dList) groupedBy:3 gapFilledBy:0
–> {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}, {13, 14, 15}, {16, 0, 0}}

–1D Listの2D LIst化
on subarraysFrom:aList groupedBy:colCount gapFilledBy:gapItem
  script spd
    property aList : {}
    
property bList : {}
    
property cList : {}
  end script
  
  
copy aList to (aList of spd) –deep copy (Important !!!)
  
  
set (bList of spd) to {}
  
set (cList of spd) to {}
  
  
set aLen to length of (aList of spd)
  
set aMod to aLen mod colCount
  
  
–あらかじめ指定数(groupedBy)の倍数になっていない場合にはgap itemを末尾に足しておく
  
if aMod is not equal to 0 then
    repeat (colCount – aMod) times
      set the end of (aList of spd) to gapItem
    end repeat
    
set aLen to length of (aList of spd)
  end if
  
  
–通常処理
  
repeat with i from 1 to aLen by colCount
    set (bList of spd) to items i thru (i + colCount – 1) of (aList of spd)
    
set the end of (cList of spd) to (bList of spd)
  end repeat
  
  
return (cList of spd)
end subarraysFrom:groupedBy:gapFilledBy:

★Click Here to Open This Script 

Posted in list | Tagged 12.0savvy 13.0savvy 14.0savvy 15.0savvy | Leave a comment

BridgePlusを使わずに1D–>2D list変換

Posted on 2月 4 by Takaaki Naganoya

BridgePlus AppleScript Libraryを使わずに、1D Listを2D Listに変換するAppleScriptです。

Script Debuggerの開発が終了したため、Frameworkを内蔵したBridgePlusの運用についても、今後は「Script Debuggerをダウンロードして動かしてほしい」といったお願いができなくなるかもしれません。

BridgePlus AppleScriptライブラリは有用ですが、Frameworkを含んでいるため実行できる環境が限られるかもしれません(ASObjC Explorerが復活しないかなー)。そのための「準備」です。

AppleScript名:BridgePlusを使わずに1D–>2D list.scptd
—
–  Created by: Takaaki Naganoya
–  Created on: 2025/02/03
—
–  Copyright © 2025 Piyomaru Software, All Rights Reserved
—

use AppleScript version "2.4" — Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

set dList to {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
set aRes to my subarraysFrom:dList groupedBy:3
–> {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}, {13, 14, 15}}

set aRes to my subarraysFrom:dList groupedBy:5
–> {{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}

–1D Listの2D LIst化
on subarraysFrom:aList groupedBy:colCount
  script spd
    property aList : {}
    
property bList : {}
    
property cList : {}
  end script
  
  
set (aList of spd) to aList
  
set (bList of spd) to {}
  
set (cList of spd) to {}
  
  
set aLen to length of (aList of spd)
  
  
set aMod to aLen mod colCount
  
if aMod is not equal to 0 then error "Item number does not match paramaters"
  
  
repeat with i from 1 to aLen by colCount
    set (bList of spd) to items i thru (i + colCount – 1) of (aList of spd)
    
set the end of (cList of spd) to (bList of spd)
  end repeat
  
  
return (cList of spd)
end subarraysFrom:groupedBy:

★Click Here to Open This Script 

Posted in list | Tagged 12.0savvy 13.0savvy 14.0savvy 15.0savvy | Leave a comment

Numbersで選択範囲のデータを切り捨て

Posted on 1月 20 by Takaaki Naganoya

Numbersの表の選択範囲のデータを指定の数(10,000とか、100万とか)で切り捨てるAppleScriptです。Numbers v14.3で検証してありますが、凝った機能は何も使っていないので、古いバージョンのNumbersでも問題なく動作することでしょう。

もともとは、Keynoteで作った資料でデータが細かくて見にくかったので、指定桁で切り捨て(100万円で切り捨て、など)するために作ったものです。

本来はiWorkアプリ上でこうした操作を行うには、「データフォーマット」で「カスタムフォーマット」を定義するのがiWorkの流儀です。

ただ、このカスタムフォーマットが割と遠回りでわかりにくかったので(+AppleScriptから操作できないので)、即物的にデータを編集するプログラムを作ってしまった次第です。割と、使い捨てレベルの素朴なScriptでもあります。

AppleScript名:選択範囲のデータを100万円で切り捨て.scpt
—
–  Created by: Takaaki Naganoya
–  Created on: 2025/01/19
—
–  Copyright © 2025 Piyomaru Software, All Rights Reserved
—

set calcNum to 10000

tell application "Numbers"
  tell front document
    tell active sheet
      tell table 1
        set aSel to cell of selection range
        
        
set newList to {}
        
repeat with i in aSel
          set j to contents of i
          
if j is not equal to missing value then
            set tmpV1 to (value of j)
            
if tmpV1 is not equal to missing value then
              set tmpV2 to tmpV1 div calcNum
              
ignoring application responses
                set value of j to tmpV2
              end ignoring
            end if
          end if
        end repeat
      end tell
    end tell
  end tell
end tell

★Click Here to Open This Script 

Posted in list | Tagged 13.0savvy 14.0savvy 15.0savvy Numbers | Leave a comment

Pagesで選択中のテキストボックスの一番近くにある白い文字のボックスのテキストを取得

Posted on 1月 16 by Takaaki Naganoya

Pagesで作成した書類で、プログラムリストの上に配置したタイトルのテキストを取得するAppleScriptです。

割といきあたりばったりで作ってしまったツールです。

Pagesで電子書籍を作成し、レイアウトしたAppleScriptのプログラムリストのファイル名を求めるために、プログラムリストの上に配置した白い文字で記述したテキストフレーム(Pages上ではShapeオブジェクト)を特定します。

フィルタ参照で相対座標値を表現できるといいのですが、そういうのはできないので、地道に距離計算しています。

「上」「下」という相対的な位置関係を表現するのに、結局数値比較しかできないので、どうしたものかと考えていたのですが、結局この「上」という表現は用いずじまいでした。「一番距離が近いテキストフレーム、文字色は白っぽい」だけで割と正確に特定できたので、いいだろうかというところです。相対位置関係を表記するライブラリなども作っておくといいかもしれません。

予想外の要素が、白いとだけ思っていた文字色が、RGB値では若干ゆらいでいたので、そのあたりの辻褄合わせを地味にやっています。カラードメイン(色名をラフに計算する)系のライブラリを使えば「white」などと雑な表現で指定できたかもしれません。

実際に使っているものは、本Scriptにくわえて選択中のテキストフレームの内容をAppleScriptとしてメモリ上で構文確認とコンパイルを行なって、ここで取得したファイル名でAppleScriptとして保存する処理を行なっています。

AppleScript名:Pagesで選択中のテキストボックスの一番近くにある白い文字のボックスの名前を取得.scpt
—
–  Created by: Takaaki Naganoya
–  Created on: 2025/01/16
—
–  Copyright © 2025 Piyomaru Software, All Rights Reserved
—

use AppleScript
use scripting additions
use framework "Foundation"
use framework "OSAKit"

property |NSURL| : a reference to current application’s |NSURL|
property OSANull : a reference to current application’s OSANull
property NSString : a reference to current application’s NSString
property OSAScript : a reference to current application’s OSAScript
property OSALanguage : a reference to current application’s OSALanguage
property NSFontAttributeName : a reference to current application’s NSFontAttributeName
property OSALanguageInstance : a reference to current application’s OSALanguageInstance
property NSURLTypeIdentifierKey : a reference to current application’s NSURLTypeIdentifierKey

tell application "Pages"
  tell front document
    set aSel to selection
    
if aSel = {} then return
    
set aaSel to first item of aSel
    
    
set targPos to position of aaSel
    
set targCon to object text of aaSel –選択中のtext frame(Pages上ではShape)の本文
    
    
tell current page
      –文字が入っているiWork objectのみが対象
      
set tList to every shape whose object text is not equal to targCon and object text of it is not equal to "" –オブジェクト
      
set pList to position of every shape whose object text is not equal to targCon and object text of it is not equal to "" –座標
      
set cList to color of object text of every shape whose object text is not equal to targCon and object text of it is not equal to "" –文字色
    end tell
    
    
–クレヨンピッカーから指定しても、白色に若干の「ゆらぎ」があるようなので、数値比較で抽出
    
set aRes to findItemNums({65500, 65500, 65500}, cList) of me
    
set aLen to length of aRes
    
if aLen = 0 then
      display dialog "No Hit(error)"
      
    else if aLen = 1 then
      set tmpTarg to first item of aRes
      
set tmpTargTextFrame to item tmpTarg of tList
      
set oRes to object text of tmpTargTextFrame
      
    else
      set p2List to {}
      
repeat with i in aRes
        set j to contents of i
        
set the end of p2List to contents of item j of pList
      end repeat
      
      
set L2ItemNums to retNearestItemByPosition({targPos}, p2List) of me
      
set oRes to object text of (item (first item of L2ItemNums) of tList)
      
    end if
  end tell
end tell

return oRes

–RGBの値がaNumにlistで入ってくる{r, g, b}
–リスト中に入っている指定要素をサーチして、各チャネルの値よりも大きい場合に合致したとみなし、出現アイテム番号を返す(複数対応)
on findItemNums(aNum, aList)
  if aList = {missing value} then return {}
  
if aNum = {missing value} then return {}
  
  
set iCount to 1
  
set hitF to false
  
set hitList to {}
  
copy aNum to {aNum1, aNum2, aNum3}
  
  
repeat with i in aList
    set j to contents of i
    
if j is not equal to missing value then
      copy j to {tmpR, tmpG, tmpB}
      
      
if (tmpR > aNum1) and (tmpG > aNum2) and (tmpB > aNum3) then
        set the end of hitList to iCount
      end if
    end if
    
set iCount to iCount + 1
  end repeat
  
  
return hitList
end findItemNums

on retNearestItemByPosition(L1Pos, L2Pos)
  
  
set resItemNum to {}
  
  
repeat with i in L1Pos
    set j to contents of i
    
set iCount to 1
    
set tDList to {}
    
    
repeat with ii in L2Pos
      set jj to contents of ii
      
      
copy jj to {tmpX1, tmpY1}
      
copy j to {tmpX2, tmpY2}
      
      
if tmpX1 ≥ tmpX2 then
        set xDist to tmpX1 – tmpX2
      else
        set xDist to tmpX2 – tmpX1
      end if
      
      
if tmpY1 ≥ tmpY2 then
        set yDist to tmpY1 – tmpY2
      else
        set yDist to tmpY2 – tmpY1
      end if
      
      
set tArea to xDist * yDist
      
set t2Area to absNum(tArea) of me
      
set the end of tDList to {area:t2Area, itemNum:iCount}
      
set iCount to iCount + 1
    end repeat
    
    
set resList to sortRecListByLabel(tDList, "area", true) of me
    
–> {{itemNum:2, area:100}, {itemNum:3, area:1739}, {itemNum:4, area:3780}, {itemNum:1, area:4554}}
    
    
set tItem to itemNum of first item of resList
    
set the end of resItemNum to tItem
    
  end repeat
  
  
return resItemNum
end retNearestItemByPosition

on arrangeTargItemByItemNumList(L2Pos, L2ItemNums)
  set L3Pos to {}
  
repeat with i in L2ItemNums
    set j to contents of i
    
set the end of L3Pos to item j of L2Pos
  end repeat
  
  
return L3Pos
end arrangeTargItemByItemNumList

on absNum(q)
  if q is less than 0 then set q to –q
  
return q
end absNum

–リストに入れたレコードを、指定の属性ラベルの値でソート
on sortRecListByLabel(aRecList as list, aLabelStr as string, ascendF as boolean)
  set aArray to current application’s NSArray’s arrayWithArray:aRecList
  
set sortDesc to current application’s NSSortDescriptor’s alloc()’s initWithKey:aLabelStr ascending:ascendF
  
set sortedArray to aArray’s sortedArrayUsingDescriptors:{sortDesc}
  
set bList to (sortedArray) as anything
  
return bList
end sortRecListByLabel

★Click Here to Open This Script 

Posted in list Text | Tagged 13.0savvy 14.0savvy 15.0savvy Pages | Leave a comment

Numbersで選択中の範囲を横方向に逆順に並べて、選択範囲に再設定

Posted on 1月 14 by Takaaki Naganoya

Numbersで縦方向に行単位で任意の並べ替え(Ascending、Descending)を行うのは問題ないのですが、横方向に並べ替えをする機能がなかったので、作ってみました。


▲初期状態。左側のデータが新しく、右端が一番古いデータ。並べ替えを行う範囲を選択


▲実行後。横方向に逆順に並べ替えを行った。左端が一番古く、右端が一番新しいデータ

標準機能で欲しいところです。

データ取得は速いものの、スプレッドシートへのデータの書き込みに時間のかかるNumbers。本ScriptもApple Silicon Macで実行すればそこそこの速度で実行してくれますが、おそらくExcelに対して同様の処理を実行したら1,000倍ぐらい高速です。

それほど大量のデータを処理すると、非同期処理が途中でおかしくなるので、数千セルぐらいを上限としておいたほうがよいでしょう。

AppleScript名:Numbersで選択中の範囲を横方向に逆順に並べて、選択範囲に再設定.scptd
—
–  Created by: Takaaki Naganoya
–  Created on: 2025/01/14
—
–  Copyright © 2025 Piyomaru Software, All Rights Reserved
—

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

script spd
  property aList : {}
  
property bList : {}
  
property cList : {}
end script

set (aList of spd) to get2DListFromNumbersSelection() of me
if (aList of spd) = "" then return "No Selection"

set (bList of spd) to {}

repeat with i in (aList of spd)
  set tmpList to contents of i
  
set tmpList to reverse of tmpList
  
set the end of (bList of spd) to tmpList
end repeat

set (bList of spd) to FlattenList((bList of spd)) of me

tell application "Numbers"
  tell front document
    tell active sheet
      tell table 1
        set (cList of spd) to cell of selection range
        
        
set iCount to 1
        
repeat with i in (cList of spd)
          set newVal to contents of item iCount of (bList of spd)
          
if (newVal as string) is equal to "missing value" then set newVal to ""
          
          
ignoring application responses
            set value of i to newVal
          end ignoring
          
          
set iCount to iCount + 1
        end repeat
      end tell
    end tell
  end tell
end tell

on get2DListFromNumbersSelection()
  –Numbersで選択範囲を縦に区切ったリストを返す
  
tell application "Numbers"
    tell front document
      tell active sheet
        try
          set theTable to first table whose class of selection range is range
        on error
          return "" –何も選択されてなかった場合
        end try
        
        
tell theTable
          set selList to value of every cell of selection range –選択範囲のデータを取得
          
          
set selName to name of selection range –選択範囲のrange情報を取得
          
set {s1, s2} to parseByDelim(selName, ":") of me
          
          
–始点の情報を取得する
          
set s1Row to (address of row of range s1) as integer
          
set s1Column to (address of column of range s1) as integer
          
          
–終点の情報を取得する
          
set s2Row to (address of row of range s2) as integer
          
set s2Column to (address of column of range s2) as integer
          
          
–選択範囲の情報を取得する
          
set selHeight to s2Row – s1Row + 1 –高さ(Height of selection range)
          
set selWidth to s2Column – s1Column + 1 –幅(Width of selection range)
          
        end tell
      end tell
    end tell
  end tell
  
  
set aLen to length of selList
  
set aaLen to selHeight
  
  
set bList to {}
  
repeat with i from 1 to aaLen
    set aHoriList to {}
    
    
repeat with ii from 1 to selWidth
      set j1 to ii + (i – 1) * selWidth
      
set tmpCon to contents of item j1 of selList
      
      
set aClass to class of tmpCon
      
if aClass = number or aClass = integer or aClass = real then
        set tmpCon to tmpCon as integer
      end if
      
      
set the end of aHoriList to tmpCon
    end repeat
    
    
set the end of bList to aHoriList
  end repeat
  
  
return bList
end get2DListFromNumbersSelection

–テキストを指定デリミタでリスト化
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

–By Paul Berkowitz
–2009年1月27日 2:24:08:JST
–Re: Flattening Nested Lists
on FlattenList(aList)
  set oldDelims to AppleScript’s text item delimiters
  
set AppleScript’s text item delimiters to {"????"}
  
set aString to aList as text
  
set aList to text items of aString
  
set AppleScript’s text item delimiters to oldDelims
  
return aList
end FlattenList

★Click Here to Open This Script 

Posted in list | Tagged 13.0savvy 14.0savvy 15.0savvy Numbers | Leave a comment

選択範囲のセルの数値がAscendingになっているかをチェック

Posted on 12月 26, 2024 by Takaaki Naganoya

Numbersで選択中のセルが1→2→3と、値が増加する形式(Ascending)になっているかをチェックするAppleScriptです。

書籍のページ(ノンブル)は、かならず1–>2–>3とページ数がかならず増加するようになっています。これが、途中で減るような値になっているとまずいので、そのチェックを行うようにしてみたものです。

本ScriptはNumbers v14.3でテストしていますが、もっと古いバージョンでも問題ないことでしょう。

AppleScript名:選択範囲のセルの数値がAscendingになっているかをチェック
—
–  Created by: Takaaki Naganoya
–  Created on: 2024/12/25
—
–  Copyright © 2024 Piyomaru Software, All Rights Reserved
—
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

property NSString : a reference to current application’s NSString
property NSCharacterSet : a reference to current application’s NSCharacterSet

set curTable to getCurTable() of me
if curTable = "" then return

tell application "Numbers"
  tell curTable
    set cList to value of every cell of selection range
  end tell
end tell

copy cList to dList

set dList to shellSortAscending(dList) of me

if cList = dList then
  return true
else
  return false
end if

on getCurTable()
  tell application "Numbers"
    tell front document
      tell active sheet
        try
          set theTable to first table whose class of selection range is range
        on error
          return "" –何も選択されてなかった場合
        end try
        
        
return theTable
      end tell
    end tell
  end tell
end getCurTable

–入れ子ではないリストの昇順ソート
on shellSortAscending(aSortList)
  script oBj
    property list : aSortList
  end script
  
set len to count oBj’s list’s items
  
set gap to 1
  
repeat while (gap ≤ len)
    set gap to ((gap * 3) + 1)
  end repeat
  
repeat while (gap > 0)
    set gap to (gap div 3)
    
if (gap < len) then
      repeat with i from gap to (len – 1)
        set temp to oBj’s list’s item (i + 1)
        
set j to i
        
repeat while ((j ≥ gap) and (oBj’s list’s item (j – gap + 1) > temp))
          set oBj’s list’s item (j + 1) to oBj’s list’s item (j – gap + 1)
          
set j to j – gap
        end repeat
        
set oBj’s list’s item (j + 1) to temp
      end repeat
    end if
  end repeat
  
return oBj’s list
end shellSortAscending

★Click Here to Open This Script 

Posted in list | Tagged 14.0savvy 15.0savvy Numbers | Leave a comment

Excelで指定セルに指定画像を貼り込む

Posted on 12月 5, 2024 by Takaaki Naganoya

Microsoft Excelで、指定画像を指定セルに貼り込むAppleScriptです。指定セルの座標を求めて、そこを左上の位置として画像を貼り込みます。

本Scriptで、セルアドレスの指定時に「B4」などとアルファベット大文字で指定してください。英小文字で指定するとエラーになります(以後のバージョンでは、ignoring caseで判断部分を囲って対処しています)。

AppleScript名:指定セルに指定画像を貼り込む.scpt
—
–  Created by: Takaaki Naganoya
–  Created on: 2024/12/05
—
–  Copyright © 2024 Piyomaru Software, All Rights Reserved
—
use AppleScript version "2.4" — Yosemite (10.10) or later
use framework "Foundation"
use framework "AppKit"
use scripting additions

property |NSURL| : a reference to current application’s |NSURL|
property NSImage : a reference to current application’s NSImage

–Excel Cell Address (A1)–+ Column No, & Row No.
set targCellAddr to "A2"
set {targCellCol, targCellRow} to cellToNumber(targCellAddr) of AddressEncoder
log {targCellCol, targCellRow}

–Column No, & Row No. –> x position & y position
set {targCellX, targCellY} to retExcelCellPositiont(targCellCol, targCellRow) of me
log {targCellX, targCellY}

–Select Image file and get width and height
set anImagePath to choose file
set anImagePOSIX to POSIX path of anImagePath
set aURL to |NSURL|’s fileURLWithPath:anImagePOSIX
set aImage to NSImage’s alloc()’s initWithContentsOfURL:aURL
set overlaySize to aImage’s |size|()

–Place image on worksheet and resize and relocate it
tell application "Microsoft Excel"
  activate
  
  
tell active workbook
    tell active sheet
      
      
set aPicShape to make new shape at the beginning
      
set width of aPicShape to (overlaySize’s |width|)
      
set height of aPicShape to (overlaySize’s |height|)
      
set top of aPicShape to targCellY
      
set left position of aPicShape to targCellX
      
      
user picture of aPicShape picture file anImagePOSIX
      
    end tell
  end tell
end tell

–指定Row, ColumnのCellのpositionを返す
on retExcelCellPositiont(x as integer, y as integer)
  tell application "Microsoft Excel"
    tell active workbook
      tell active sheet
        tell row y
          tell cell x
            set xMin0 to left position
            
set yMin0 to top
            
set xWidth0 to width
            
set yHeight0 to height
          end tell
        end tell
      end tell
    end tell
  end tell
  
  
return {xMin0, yMin0}
end retExcelCellPositiont

script AddressEncoder
  property parent : AppleScript
  
use scripting additions
  
  
— 数値からセルアドレス(A1形式)への変換
  
on numberToCell(columnNumber)
    set columnAddress to ""
    
set tempNumber to columnNumber
    
    
— 列番号をA-Z形式に変換
    
repeat while tempNumber > 0
      set remainder to (tempNumber – 1) mod 26
      
set columnAddress to (character (remainder + 1) of "ABCDEFGHIJKLMNOPQRSTUVWXYZ") & columnAddress
      
set tempNumber to (tempNumber – 1) div 26
    end repeat
    
    
— A1形式のアドレスを返す
    
return columnAddress
  end numberToCell
  
  
  
— セルアドレス(A1形式)から数値への変換
  
on cellToNumber(cellAddress)
    set columnPart to ""
    
set rowPart to ""
    
    
— 列部分と行部分を分離
    
repeat with char in cellAddress
      if char is in "0123456789" then
        set rowPart to rowPart & char
      else
        set columnPart to columnPart & char
      end if
    end repeat
    
    
— 列部分を数値に変換
    
set columnNumber to 0
    
repeat with i from 1 to length of columnPart
      set char to character i of columnPart
      
using terms from scripting additions
        set columnNumber to columnNumber * 26 + (offset of char in "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
      end using terms from
    end repeat
    
    
— 数値を返す
    
return {columnNumber, (rowPart as integer)}
  end cellToNumber
  
end script

★Click Here to Open This Script 

Posted in Image list | Tagged 13.0savvy 14.0savvy 15.0savvy Excel | Leave a comment

Chat GPTに書かせたQuickSort(昇順・降順ソート)2D

Posted on 12月 4, 2024 by Takaaki Naganoya

2D List(2次元配列)のソートルーチンをChatGPTに書かせてみました。1,000項目のソートで0.6秒(MacBook Air M2)、10,000項目のソートで329秒(MacBook Air M2)。

そのままでは使い物にならないので、listの持ち方を変えて高速化対応を行い、10,000項目のソートで0.32秒まで速くなりました。

Cocoaの機能を利用して10,000項目の2D Listソートすると、0.08秒ほど(MacBook Air M2)でしたが、Cocoaでソートする場合にはList中にアプリケーションのオブジェクト情報を入れられないので、Vanilla Scriptのソートルーチンもそれなりに高速なものをそろえておく必要があります。

ChatGPTにソートルーチンを書かせてみたら、AppleScriptのListは遅いとか言い訳をしだしたので、「こうしたら速くなるよ、100倍ぐらい」と言い返したら、少しマシな内容を返してきました。人間だと思って相手をすると腹が立ちますが、人間だと思わず、あらかじめ正解を知っていればそちらに誘導するぐらいはできそうです。

AppleScript名:Chat GPTに書かせたQuickSort(昇順・降順ソート_高速化改造版)2D.scpt
use AppleScript
use scripting additions
use framework "Foundation"

script spd
  property aList : {}
end script

set (aList of spd) to {}

repeat 10000 times
  set end of (aList of spd) to {(random number 1000 from 1 to 9999), (random number 1000 from 1 to 9999)}
end repeat

–昇順ソート
set a1Dat to current application’s NSDate’s timeIntervalSinceReferenceDate()
set sortedList to quickSort2DArray((aList of spd), 2, true) –ソート
set b1Dat to current application’s NSDate’s timeIntervalSinceReferenceDate()
set c1Dat to b1Dat – a1Dat

–降順ソート
set a2Dat to current application’s NSDate’s timeIntervalSinceReferenceDate()
set sortedList to quickSort2DArray((aList of spd), 2, false) –ソート
set b2Dat to current application’s NSDate’s timeIntervalSinceReferenceDate()
set c2Dat to b2Dat – a2Dat

display dialog (c1Dat as number as text) & return & (c2Dat as number as text)
–> 0.01 sec @MacBook Air M2 (1,000 items)
–> 0.32 sec @MacBook Air M2 (10,000 items)

return {c1Dat, c2Dat}

— クイックソートの関数(高速化対応版)
on quickSort2DArray(array2D, columnIndex, ascendingOrder)
  script oBj
    property list : array2D
    
property lessList : {}
    
property greaterList : {}
  end script
  
  
if (length of (oBj’s list)) ≤ 1 then
    return (oBj’s list) — 要素が1つ以下の場合はそのまま返す
  else
    — ピボットを選択(最初の要素を基準)
    
set pivot to item 1 of (oBj’s list)
    
set pivotValue to item columnIndex of pivot
    
    
— ピボットより小さい要素のリスト
    
set (oBj’s lessList) to {}
    
— ピボット以上の要素のリスト
    
set (oBj’s greaterList) to {}
    
    
repeat with i from 2 to length of (oBj’s list) — ピボットを除いたリストを処理
      set currentItem to item i of (oBj’s list)
      
set currentValue to item columnIndex of currentItem
      
      
— 昇順または降順で分岐
      
if (ascendingOrder and currentValue ≤ pivotValue) or ((not ascendingOrder) and currentValue ≥ pivotValue) then
        set end of (oBj’s lessList) to currentItem
      else
        set end of (oBj’s greaterList) to currentItem
      end if
    end repeat
    
    
— 再帰的にソートして結合
    
return (quickSort2DArray((oBj’s lessList), columnIndex, ascendingOrder) & {pivot} & quickSort2DArray((oBj’s greaterList), columnIndex, ascendingOrder))
  end if
end quickSort2DArray

★Click Here to Open This Script 

Posted in list | Tagged 13.0savvy 14.0savvy 15.0savvy Sorting | Leave a comment

Numbersで選択中の表を書籍掲載用にセル内容の整理(重複セルをまとめる)v2

Posted on 12月 3, 2024 by Takaaki Naganoya

Numbersの表を、書籍掲載用に体裁をととのえるAppleScriptのアップデート版です。書籍掲載時には、同じ値が横方向に連続している箇所は1つにまとめたいところなので、その作業を自動で行います。

新型のNumbers/Excelセルアドレス変換ルーチンを実際に使用してみました。モジュールを入れ替えただけです。


▲対象の表のいずれかのセルを選択してAppleScriptを実行


▲処理後の表

AppleScript名:Numbersで選択中の表を書籍掲載用にセル内容の整理(重複セルをまとめる)v2.scpt
—
–  Created by: Takaaki Naganoya
–  Created on: 2024/12/03
—
–  Copyright © 2024 Piyomaru Software, All Rights Reserved
—

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

tell application "Numbers"
  tell front document
    tell active sheet
      try
        set theTable to first table whose class of selection range is range
      on error
        return "" –何も選択されてなかった場合
      end try
      
      
      
–セルを選択中の表を処理する
      
tell theTable
        set headR to header row count
        
set headC to header column count
        
set rowC to count every row
        
set colC to count every column
        
        
repeat with y from (headR + 1) to (rowC)
          –1行分(ヘッダーカラムをのぞく)のデータを1D Listで取得
          
set tmpRangeStr to numberToCell(headC + 1) of AddressEncoder & (y as string) & ":" & numberToCell(colC) of AddressEncoder & (y as string)
          
set tValList to value of cells of range tmpRangeStr
          
          
–1D Listから値が連続している区間を求める
          
set sameBlock to detectSameValueRepeatationBlockIn1DArray(tValList) of detectRepeatation
          
          
–連続区間でループ
          
repeat with i in sameBlock
            copy i to {startX, endX} –データ内の項目Indexであることに留意
            
            
–重複値のセルをクリアする(初出セルの値は残す)
            
repeat with ii from (startX + 1) to endX
              set value of cell (ii + headC) of row y to ""
            end repeat
            
            
–重複していたセルをマージする
            
set mRangeStr to numberToCell(headC + startX) of AddressEncoder & (y as string) & ":" & numberToCell(headC + endX) of AddressEncoder & (y as string)
            
set mRange to range mRangeStr
            
merge mRange
          end repeat
        end repeat
      end tell
    end tell
  end tell
end tell

script detectRepeatation
  property parent : AppleScript
  
use scripting additions
  
use framework "Foundation"
  
  
–巨大なデータの処理に向いていないかも?
  
on detectSameValueRepeatationBlockIn1DArray(aList)
    set dList to returnDuplicatesOnly(aList) of me
    
–>  {​​​​​"年間仕様", ​​​​​"YP仕様", ​​​​​"月間仕様"​​​}
    
    
set anArray to current application’s NSMutableArray’s arrayWithArray:aList
    
anArray’s addObject:""
    
    
set resList to {}
    
repeat with i in dList
      set j to contents of i
      
set anIndex to (anArray’s indexOfObject:j)
      
repeat with ii from (anIndex + 1) to ((length of aList))
        set jj to (anArray’s objectAtIndex:ii) as string
        
if jj is not equal to j then
          set the end of resList to {anIndex + 1, ii}
          
exit repeat
        end if
      end repeat
    end repeat
    
    
resList
    
–>  {​​​​​{​​​​​​​4, ​​​​​​​6​​​​​}, ​​​​​{​​​​​​​7, ​​​​​​​9​​​​​}, ​​​​​{​​​​​​​10, ​​​​​​​17​​​​​}​​​}
  end detectSameValueRepeatationBlockIn1DArray
  
  
on returnDuplicatesOnly(aList)
    set countedSet to current application’s NSCountedSet’s alloc()’s initWithArray:aList
    
set simpleSet to current application’s NSSet’s setWithArray:aList
    
countedSet’s minusSet:simpleSet
    
return countedSet’s allObjects() as list
  end returnDuplicatesOnly
end script

script AddressEncoder
  property parent : AppleScript
  
use scripting additions
  
  
— 数値からセルアドレス(A1形式)への変換
  
on numberToCell(columnNumber)
    set columnAddress to ""
    
set tempNumber to columnNumber
    
    
— 列番号をA-Z形式に変換
    
repeat while tempNumber > 0
      set remainder to (tempNumber – 1) mod 26
      
set columnAddress to (character (remainder + 1) of "ABCDEFGHIJKLMNOPQRSTUVWXYZ") & columnAddress
      
set tempNumber to (tempNumber – 1) div 26
    end repeat
    
    
— A1形式のアドレスを返す
    
return columnAddress
  end numberToCell
  
  
  
— セルアドレス(A1形式)から数値への変換
  
on cellToNumber(cellAddress)
    set columnPart to ""
    
set rowPart to ""
    
    
— 列部分と行部分を分離
    
repeat with char in cellAddress
      if char is in "0123456789" then
        set rowPart to rowPart & char
      else
        set columnPart to columnPart & char
      end if
    end repeat
    
    
— 列部分を数値に変換
    
set columnNumber to 0
    
repeat with i from 1 to length of columnPart
      set char to character i of columnPart
      
using terms from scripting additions
        set columnNumber to columnNumber * 26 + (offset of char in "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
      end using terms from
    end repeat
    
    
— 数値を返す
    
return {columnNumber, (rowPart as integer)}
  end cellToNumber
  
end script

★Click Here to Open This Script 

Posted in list Object control | Tagged 13.0savvy 14.0savvy 15.0savvy Numbers | Leave a comment

Pagesで選択中の表を書籍掲載用にセル内容の整理(重複セルをまとめる)

Posted on 12月 2, 2024 by Takaaki Naganoya

Pages書類上の表を、書籍掲載用に体裁をととのえるAppleScriptです。書籍掲載時には、同じ値が横方向に連続している箇所は1つにまとめたいところなので、その作業を自動で行います。


▲Pages書類上の表のいずれかのセルを選択しておいて、本Scriptを実行します


▲実行後

AppleScript名:Pagesで選択中の表を書籍掲載用にセル内容の整理(重複セルをまとめる).scpt
—
–  Created by: Takaaki Naganoya
–  Created on: 2024/12/02
—
–  Copyright © 2024 Piyomaru Software, All Rights Reserved
—

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

tell application "Pages"
  tell front document
    try
      set theTable to first table whose class of selection range is range
    on error
      return "" –何も選択されてなかった場合
    end try
    
    
–セルを選択中の表を処理する
    
tell theTable
      set headR to header row count
      
set headC to header column count
      
set rowC to count every row
      
set colC to count every column
      
      
repeat with y from (headR + 1) to (rowC)
        –1行分(ヘッダーカラムをのぞく)のデータを1D Listで取得
        
set tmpRangeStr to numAdrToColumnEncode(headC + 1) of AddressEncoder & (y as string) & ":" & numAdrToColumnEncode(colC) of AddressEncoder & (y as string)
        
set tValList to value of cells of range tmpRangeStr
        
        
–1D Listから値が連続している区間を求める
        
set sameBlock to detectSameValueRepeatationBlockIn1DArray(tValList) of detectRepeatation
        
        
–連続区間でループ
        
repeat with i in sameBlock
          copy i to {startX, endX} –データ内の項目Indexであることに留意
          
          
–重複値のセルをクリアする(初出セルの値は残す)
          
repeat with ii from (startX + 1) to endX
            set value of cell (ii + headC) of row y to ""
          end repeat
          
          
–重複していたセルをマージする
          
set mRangeStr to numAdrToColumnEncode(headC + startX) of AddressEncoder & (y as string) & ":" & numAdrToColumnEncode(headC + endX) of AddressEncoder & (y as string)
          
set mRange to range mRangeStr
          
merge mRange
        end repeat
      end repeat
    end tell
  end tell
end tell

script detectRepeatation
  property parent : AppleScript
  
use scripting additions
  
use framework "Foundation"
  
  
–巨大なデータの処理に向いていないかも?
  
on detectSameValueRepeatationBlockIn1DArray(aList)
    set dList to returnDuplicatesOnly(aList) of me
    
–>  {​​​​​"年間仕様", ​​​​​"YP仕様", ​​​​​"月間仕様"​​​}
    
    
set anArray to current application’s NSMutableArray’s arrayWithArray:aList
    
anArray’s addObject:""
    
    
set resList to {}
    
repeat with i in dList
      set j to contents of i
      
set anIndex to (anArray’s indexOfObject:j)
      
repeat with ii from (anIndex + 1) to ((length of aList))
        set jj to (anArray’s objectAtIndex:ii) as string
        
if jj is not equal to j then
          set the end of resList to {anIndex + 1, ii}
          
exit repeat
        end if
      end repeat
    end repeat
    
    
resList
    
–>  {​​​​​{​​​​​​​4, ​​​​​​​6​​​​​}, ​​​​​{​​​​​​​7, ​​​​​​​9​​​​​}, ​​​​​{​​​​​​​10, ​​​​​​​17​​​​​}​​​}
  end detectSameValueRepeatationBlockIn1DArray
  
  
on returnDuplicatesOnly(aList)
    set countedSet to current application’s NSCountedSet’s alloc()’s initWithArray:aList
    
set simpleSet to current application’s NSSet’s setWithArray:aList
    
countedSet’s minusSet:simpleSet
    
return countedSet’s allObjects() as list
  end returnDuplicatesOnly
end script

script AddressEncoder
  property parent : AppleScript
  
  
–10進数数値をExcel 2004/2008的カラム表現にエンコードするサブルーチン(エンコード範囲:1~1351)
  
on numAdrToColumnEncode(origNum)
    if origNum > 1351 then
      error "エラー:Numbersのカラム表現(A1形式)への変換ルーチンにおいて、想定範囲外(1351以上)のパラメータが指定されました"
    end if
    
    
set upperDigitEncTable to {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "A"}
    
set lowerDigitEncTable to {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "A"}
    
    
set oNum to origNum
    
set nTh to 26
    
set stringLength to 4
    
    
–数字が1桁の場合の対応
    
if origNum < 27 then
      set aRes to (item origNum of upperDigitEncTable) as string
      
return aRes
    end if
    
    
if origNum > 702 then
      –3桁になる場合
      
set upupNum to oNum div 676 –整数除算–上の上の桁
      
set oNum to oNum – (upupNum * 676)
      
set upNum to oNum div 26 –整数除算–上の桁
      
set lowNum to oNum mod 26 – 1 –余剰計算–下の桁
      
      
–つじつま合わせ処理 【強引】
      
if lowNum = -1 then
        set upNum to upNum – 1
        
set lowNum to 25
      end if
      
      
set upupChar to (item upupNum of upperDigitEncTable) as string
      
set upChar to (item upNum of upperDigitEncTable) as string
      
set lowChar to (item (lowNum + 1) of lowerDigitEncTable) as string
      
set resText to upupChar & upChar & lowChar
      
    else
      –2桁の場合
      
set upNum to oNum div 26 –整数除算–上の桁
      
set lowNum to oNum mod 26 – 1 –余剰計算–下の桁
      
      
–つじつま合わせ処理 【強引】
      
if lowNum = -1 then
        set upNum to upNum – 1
        
set lowNum to 25
      end if
      
      
set upChar to (item upNum of upperDigitEncTable) as string
      
set lowChar to (item (lowNum + 1) of lowerDigitEncTable) as string
      
set resText to upChar & lowChar
      
    end if
    
    
return resText
  end numAdrToColumnEncode
  
  
–Numbersの横方向アドレス(A~Zの26進数)文字列を10進数に変換
  
on colAddrToNumDecode(origStr)
    return aNthToDecimal(origStr, {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}) of me
  end colAddrToNumDecode
  
  
  
–n進数文字列を10進数に変換する
  
on aNthToDecimal(origStr, nTh)
    set resNumber to 0
    
    
set sList to reverse of (characters of origStr)
    
set aLen to length of nTh
    
set digitCount to 0
    
    
repeat with i in sList
      set j to contents of i
      
set aRes to offsetInList(j, nTh) of me
      
      
set resNumber to resNumber + (aLen ^ digitCount) * aRes
      
      
set digitCount to digitCount + 1
    end repeat
    
    
return resNumber as integer
  end aNthToDecimal
  
  
  
on offsetInList(aChar, aList)
    set anArray to NSArray’s arrayWithArray:aList
    
set aInd to (anArray’s indexOfObject:aChar)
    
if aInd = current application’s NSNotFound or (aInd as number) > 9.99999999E+8 then
      error "Invalid Character Error"
    else
      return (aInd as integer) + 1 –0 to 1 based index conversion
    end if
  end offsetInList
  
end script

★Click Here to Open This Script 

Posted in list Object control | Tagged 13.0savvy 14.0savvy 15.0savvy Pages | Leave a comment

Numbersで選択中の表を書籍掲載用にセル内容の整理(重複セルをまとめる)

Posted on 12月 2, 2024 by Takaaki Naganoya

Numbersの表を、書籍掲載用に体裁をととのえるAppleScriptです。書籍掲載時には、同じ値が横方向に連続している箇所は1つにまとめたいところなので、その作業を自動で行います。


▲こんな感じに掲載している表を作るためのScript

いずれかのセルを選択した表に対して処理を行います。表の各行のデータを取得し、データ連続区間を検出。連続区間の2つ目以降のセルの内容を消去したうえで、当該区間のセルをまとめます。

そんなに大きな表を処理するようにはできていません。色をつけるところまで自動化しようかとも考えたのですが、色についてはケースバイケースだろうと考え、そこまでは処理していません。


▲対象の表のいずれかのセルを選択してAppleScriptを実行


▲処理後の表

AppleScript名:Numbersで選択中の表を書籍掲載用にセル内容の整理(重複セルをまとめる).scpt
—
–  Created by: Takaaki Naganoya
–  Created on: 2024/12/02
—
–  Copyright © 2024 Piyomaru Software, All Rights Reserved
—

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

tell application "Numbers"
  tell front document
    tell active sheet
      try
        set theTable to first table whose class of selection range is range
      on error
        return "" –何も選択されてなかった場合
      end try
      
      
      
–セルを選択中の表を処理する
      
tell theTable
        set headR to header row count
        
set headC to header column count
        
set rowC to count every row
        
set colC to count every column
        
        
repeat with y from (headR + 1) to (rowC)
          –1行分(ヘッダーカラムをのぞく)のデータを1D Listで取得
          
set tmpRangeStr to numAdrToColumnEncode(headC + 1) of AddressEncoder & (y as string) & ":" & numAdrToColumnEncode(colC) of AddressEncoder & (y as string)
          
set tValList to value of cells of range tmpRangeStr
          
          
–1D Listから値が連続している区間を求める
          
set sameBlock to detectSameValueRepeatationBlockIn1DArray(tValList) of detectRepeatation
          
          
–連続区間でループ
          
repeat with i in sameBlock
            copy i to {startX, endX} –データ内の項目Indexであることに留意
            
            
–重複値のセルをクリアする(初出セルの値は残す)
            
repeat with ii from (startX + 1) to endX
              set value of cell (ii + headC) of row y to ""
            end repeat
            
            
–重複していたセルをマージする
            
set mRangeStr to numAdrToColumnEncode(headC + startX) of AddressEncoder & (y as string) & ":" & numAdrToColumnEncode(headC + endX) of AddressEncoder & (y as string)
            
set mRange to range mRangeStr
            
merge mRange
          end repeat
        end repeat
      end tell
    end tell
  end tell
end tell

script detectRepeatation
  property parent : AppleScript
  
use scripting additions
  
use framework "Foundation"
  
  
–巨大なデータの処理に向いていないかも?
  
on detectSameValueRepeatationBlockIn1DArray(aList)
    set dList to returnDuplicatesOnly(aList) of me
    
–>  {​​​​​"年間仕様", ​​​​​"YP仕様", ​​​​​"月間仕様"​​​}
    
    
set anArray to current application’s NSMutableArray’s arrayWithArray:aList
    
anArray’s addObject:""
    
    
set resList to {}
    
repeat with i in dList
      set j to contents of i
      
set anIndex to (anArray’s indexOfObject:j)
      
repeat with ii from (anIndex + 1) to ((length of aList))
        set jj to (anArray’s objectAtIndex:ii) as string
        
if jj is not equal to j then
          set the end of resList to {anIndex + 1, ii}
          
exit repeat
        end if
      end repeat
    end repeat
    
    
resList
    
–>  {​​​​​{​​​​​​​4, ​​​​​​​6​​​​​}, ​​​​​{​​​​​​​7, ​​​​​​​9​​​​​}, ​​​​​{​​​​​​​10, ​​​​​​​17​​​​​}​​​}
  end detectSameValueRepeatationBlockIn1DArray
  
  
on returnDuplicatesOnly(aList)
    set countedSet to current application’s NSCountedSet’s alloc()’s initWithArray:aList
    
set simpleSet to current application’s NSSet’s setWithArray:aList
    
countedSet’s minusSet:simpleSet
    
return countedSet’s allObjects() as list
  end returnDuplicatesOnly
end script

script AddressEncoder
  property parent : AppleScript
  
  
–10進数数値をExcel 2004/2008的カラム表現にエンコードするサブルーチン(エンコード範囲:1~1351)
  
on numAdrToColumnEncode(origNum)
    if origNum > 1351 then
      error "エラー:Numbersのカラム表現(A1形式)への変換ルーチンにおいて、想定範囲外(1351以上)のパラメータが指定されました"
    end if
    
    
set upperDigitEncTable to {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "A"}
    
set lowerDigitEncTable to {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "A"}
    
    
set oNum to origNum
    
set nTh to 26
    
set stringLength to 4
    
    
–数字が1桁の場合の対応
    
if origNum < 27 then
      set aRes to (item origNum of upperDigitEncTable) as string
      
return aRes
    end if
    
    
if origNum > 702 then
      –3桁になる場合
      
set upupNum to oNum div 676 –整数除算–上の上の桁
      
set oNum to oNum – (upupNum * 676)
      
set upNum to oNum div 26 –整数除算–上の桁
      
set lowNum to oNum mod 26 – 1 –余剰計算–下の桁
      
      
–つじつま合わせ処理 【強引】
      
if lowNum = -1 then
        set upNum to upNum – 1
        
set lowNum to 25
      end if
      
      
set upupChar to (item upupNum of upperDigitEncTable) as string
      
set upChar to (item upNum of upperDigitEncTable) as string
      
set lowChar to (item (lowNum + 1) of lowerDigitEncTable) as string
      
set resText to upupChar & upChar & lowChar
      
    else
      –2桁の場合
      
set upNum to oNum div 26 –整数除算–上の桁
      
set lowNum to oNum mod 26 – 1 –余剰計算–下の桁
      
      
–つじつま合わせ処理 【強引】
      
if lowNum = -1 then
        set upNum to upNum – 1
        
set lowNum to 25
      end if
      
      
set upChar to (item upNum of upperDigitEncTable) as string
      
set lowChar to (item (lowNum + 1) of lowerDigitEncTable) as string
      
set resText to upChar & lowChar
      
    end if
    
    
return resText
  end numAdrToColumnEncode
  
  
–Numbersの横方向アドレス(A~Zの26進数)文字列を10進数に変換
  
on colAddrToNumDecode(origStr)
    return aNthToDecimal(origStr, {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}) of me
  end colAddrToNumDecode
  
  
  
–n進数文字列を10進数に変換する
  
on aNthToDecimal(origStr, nTh)
    set resNumber to 0
    
    
set sList to reverse of (characters of origStr)
    
set aLen to length of nTh
    
set digitCount to 0
    
    
repeat with i in sList
      set j to contents of i
      
set aRes to offsetInList(j, nTh) of me
      
      
set resNumber to resNumber + (aLen ^ digitCount) * aRes
      
      
set digitCount to digitCount + 1
    end repeat
    
    
return resNumber as integer
  end aNthToDecimal
  
  
  
on offsetInList(aChar, aList)
    set anArray to NSArray’s arrayWithArray:aList
    
set aInd to (anArray’s indexOfObject:aChar)
    
if aInd = current application’s NSNotFound or (aInd as number) > 9.99999999E+8 then
      error "Invalid Character Error"
    else
      return (aInd as integer) + 1 –0 to 1 based index conversion
    end if
  end offsetInList
  
end script

★Click Here to Open This Script 

Posted in list Object control | Tagged 13.0savvy 14.0savvy 15.0savvy Numbers | Leave a comment

Numbersの選択範囲で空欄でないセルに指定の文字を入れる

Posted on 10月 17, 2024 by Takaaki Naganoya

Numbersの表を書き換えるためのAppleScriptです。表の選択範囲のうち、空欄でないセルに指定の文字(「●」)を入れます。

電子書籍掲載の「表」を作るのに、割と必要なものです。

「表」をまとめる段階では、

のように、生データをそのままセルに記載しておきますが、場所の利用効率でいえばそのまま生データで掲載していると無駄があります。

そこで、空欄ではないセルについては、「●」などの記号を記入することで、コンパクトな「表」に作り変える作業が発生します。本AppleScriptはそれを自動化したものです。

AppleScript名:選択範囲で空欄でないセルに指定の文字を入れる.scpt
—
–  Created by: Takaaki Naganoya
–  Created on: 2024/10/17
—
–  Copyright © 2024 Piyomaru Software, All Rights Reserved
—

script spd
  property uniqList : {}
end script

set strMark 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 cells of selection range
        
repeat with i in (uniqList of spd)
          set j to contents of i
          
set tmpVal to value of j
          
if tmpVal is not equal to missing value then
            set value of j to strMark
          end if
        end repeat
      end tell
    end tell
  end tell
end tell

★Click Here to Open This Script 

Posted in list Text | Tagged 13.0savvy 14.0savvy 15.0savvy Numbers | Leave a comment

Numbersで選択中の2列のセルを比較して並べ直して書き戻す v2

Posted on 10月 14, 2024 by Takaaki Naganoya

Numbers上でデータを整理しているときに、必要になって組んでみたものです。少し大きいAppleScriptですが、ありもののルーチンをつなぎ合わせて書いたので、とくに画期的な何かを書いたということはありません。

もともと、Numbers上にまとめたデータ(2列分)があって、それらを同じものは同じ行に並べ、削除されたものは空欄、追加されたものは下に列挙するという整理を行なっていました。


▲処理前の状態。2列x処理を行う分の行を選択した状態で本AppleScriptを実行する(スクリプトメニューなどを推奨)


▲処理後の状態。このように整理を行う

この作業をまとめて行うものです。そんなに高速化に配慮しているわけではないので、巨大なデータを扱うのには(このままでは)向いていないかもしれません。ただ、高速化の余地はいろいろあります。

もう、これは分かりきっていた話ですが、Numbers向けに凝ったAppleScriptを書くと、Numbersの機能はほとんど使わずに、AppleScriptの配列やらNSObjectのNSArrayやらを使いまくった「Cocoaの機能のオンパレード」みたいなAppleScriptになります。これは、Numbersに絶望的に何も機能がないためで、データの入出力しか行う余地がありません。

AppleScript名:選択中の2列のセルを比較して並べ直して書き戻す v2
—
–  Created by: Takaaki Naganoya
–  Created on: 2024/10/14
—
–  Copyright © 2024 Piyomaru Software, All Rights Reserved
—
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set curTable to getCurTable() of me
if curTable = "" then return

set {s1Row, s1Column, e1Row, e1Column} to getSelectionRange(curTable) of me
–> {73, 3, 86, 4}

set colWidth to e1Column – s1Column + 1
–> 2

if colWidth is not equal to 2 then
  display dialog "Numbers上の表の選択幅が2ではないので、処理終了します" buttons {"OK"} default button 1
  
return
end if

set rowHeight to e1Row – s1Row + 1
–> 15

–縦方向に列のセルの値を取得(左側)
set v1List to getValueByRange(curTable, s1Column, s1Row, e1Row) of me

–スイープ(空白セルのmissing valueを除去)
set v1aList to sweepList(v1List, missing value) of me
–> {"com.apple.eloquence.fr-CA.Grandpa", "com.apple.eloquence.fi-FI.Grandpa", " com.apple.eloquence.de-DE.Grandpa", " com.apple.eloquence.pt-BR.Grandpa", "com.apple.eloquence.en-US.Grandpa", "com.apple.eloquence.es-ES.Grandpa", " com.apple.eloquence.en-GB.Grandpa", " com.apple.eloquence.it-IT.Grandpa", " com.apple.eloquence.es-MX.Grandpa"}

–縦方向に列のセルの値を取得(右側)
set v2List to getValueByRange(curTable, e1Column, s1Row, e1Row) of me

–スイープ(空白セルのmissing valueを除去)
set v2aList to sweepList(v2List, missing value) of me
–> {"com.apple.eloquence.de-DE.Grandpa", "com.apple.eloquence.en-GB.Grandpa", "com.apple.eloquence.en-US.Grandpa", "com.apple.eloquence.es-ES.Grandpa", "com.apple.eloquence.es-MX.Grandpa", "com.apple.eloquence.fi-FI.Grandpa", "com.apple.eloquence.fr-CA.Grandpa", "com.apple.eloquence.fr-FR.Grandpa", "com.apple.eloquence.it-IT.Grandpa", "com.apple.eloquence.pt-BR.Grandpa", "com.apple.eloquence.ja-JP.Grandpa", "com.apple.eloquence.ko-KR.Grandpa", "com.apple.eloquence.zh-CN.Grandpa", "com.apple.eloquence.zh-TW.Grandpa"}

set dList to getDiffBetweenLists(v1aList, v2aList) of me
–> {addItems:{"com.apple.eloquence.zh-TW.Grandpa", "com.apple.eloquence.ko-KR.Grandpa", "com.apple.eloquence.ja-JP.Grandpa", "com.apple.eloquence.zh-CN.Grandpa"}, minusItems:{}}

set newList to {}
set minusList to minusItems of dList

repeat with i in v1aList
  set j to contents of i
  
if j is not in minusList then
    if j is in v2aList then
      set the end of newList to j
    else
      set the end of newList to ""
    end if
  else
    set the end of newList to ""
  end if
end repeat

set addList to addItems of dList
set addList to sort1DNumList(addList, true) of me –昇順ソート

set new2List to newList & addList

set newLen to length of new2List
if newLen > rowHeight then
  display dialog "新規データが大きいため(" & (rowHeight as string) & "行に対して、データが" & (newLen as string) & "件)データをNumbersに描き戻せません"
  
return –元のデータ範囲よりも、新規データ範囲(行)が多かったら処理を打ち切る(将来アップデート予定。行挿入などで対処)
end if

repeat (rowHeight – newLen + 1) times
  set the end of new2List to ""
end repeat

setValueByRange(curTable, e1Column, s1Row, e1Row, new2List) of me

on setValueByRange(curTable, s1Column, s1Row, e1Row, vList)
  tell application "Numbers"
    tell curTable
      tell column s1Column
        set cList to cells s1Row thru e1Row
      end tell
      
      
set aCount to 1
      
repeat with i in cList
        set aVal to item aCount of vList
        
set value of i to aVal
        
set aCount to aCount + 1
      end repeat
      
    end tell
  end tell
end setValueByRange

on getValueByRange(curTable, s1Column, s1Row, e1Row)
  tell application "Numbers"
    tell curTable
      tell column s1Column
        set vList to value of cells s1Row thru e1Row
        
return vList
      end tell
    end tell
  end tell
end getValueByRange

on getCurTable()
  tell application "Numbers"
    tell front document
      tell active sheet
        try
          set theTable to first table whose class of selection range is range
        on error
          return "" –何も選択されてなかった場合
        end try
        
        
return theTable
      end tell
    end tell
  end tell
end getCurTable

on getSelectionRange(theTable)
  tell application "Numbers"
    tell theTable
      set aSel to properties of selection range
      
set selName to name of aSel
      
set {s1, s2} to parseByDelim(selName, ":") of me
      
      
–始点の情報を取得する
      
set s1Row to (address of row of range s1) as integer
      
set s1Column to (address of column of range s1) as integer
      
      
–終点の情報を取得する
      
set e1Row to (address of row of range s2) as integer
      
set e1Column to (address of column of range s2) as integer
      
      
return {s1Row, s1Column, e1Row, e1Column}
    end tell
  end tell
end getSelectionRange

on parseByDelim(aData, aDelim)
  set curDelim to AppleScript’s text item delimiters
  
set AppleScript’s text item delimiters to aDelim
  
set dList to text items of aData
  
set AppleScript’s text item delimiters to curDelim
  
return dList
end parseByDelim

on sweepList(aList, sweepItem)
  set bList to {}
  
repeat with i in aList
    if contents of i is not equal to sweepItem then
      set the end of bList to contents of i
    end if
  end repeat
  
return bList
end sweepList

–リストの差分を取得_v2
on getDiffBetweenLists(aArray as list, bArray as list)
  set allSet to current application’s NSMutableSet’s setWithArray:aArray
  
allSet’s addObjectsFromArray:bArray
  
  
–重複する要素のみ抜き出す
  
set duplicateSet to current application’s NSMutableSet’s setWithArray:aArray
  
duplicateSet’s intersectSet:(current application’s NSSet’s setWithArray:bArray)
  
  
–重複部分を削除する
  
allSet’s minusSet:duplicateSet
  
set resArray to (allSet’s allObjects()) as list
  
  
set aSet to current application’s NSMutableSet’s setWithArray:aArray
  
set bSet to current application’s NSMutableSet’s setWithArray:resArray
  
aSet’s intersectSet:bSet –積集合
  
set addRes to aSet’s allObjects() as list
  
  
set cSet to current application’s NSMutableSet’s setWithArray:bArray
  
cSet’s intersectSet:bSet –積集合
  
set minusRes to cSet’s allObjects() as list
  
  
return {addItems:minusRes, minusItems:addRes}
end getDiffBetweenLists

–1D List(数値)をsort / ascOrderがtrueだと昇順ソート、falseだと降順ソート
on sort1DNumList(theList as list, aBool as boolean)
  tell current application’s NSSet to set theSet to setWithArray_(theList)
  
tell current application’s NSSortDescriptor to set theDescriptor to sortDescriptorWithKey_ascending_(missing value, aBool)
  
set sortedList to theSet’s sortedArrayUsingDescriptors:{theDescriptor}
  
return (sortedList) as list
end sort1DNumList

★Click Here to Open This Script 

Posted in diff list | Tagged 13.0savvy 14.0savvy 15.0savvy Numbers | Leave a comment

NSSpeechSynthesizerとAVSpeechSynthesisVoiceで返ってくるTTS Voice IDの違いを計算する

Posted on 10月 11, 2024 by Takaaki Naganoya

macOS 15上でNSSpeechSynthesizerとAVSpeechSynthesisVoiceで返ってくるTTS Voice IDの数が違う、

NSSpeechSynthesizer :205
AVSpeechSynthesisVoice:222

ことが気になりました。NSSpeechSynthesizerについては、あまり真面目にメンテナンスされていないからAVSpeechSynthesisVoiceを使えといった声も聞こえてきますが、具体的にどのあたりに「差」があるのかが気になります。

そこで、実際にAppleScriptで差分を計算して確認してみました。

–>{addItems:{“com.apple.ttsbundle.siri_Nicky_en-US_premium”, “com.apple.ttsbundle.siri_Hattori_ja-JP_premium”, “com.apple.ttsbundle.siri_Helena_de-DE_compact”, “com.apple.ttsbundle.siri_Yu-Shu_zh-CN_compact”, “com.apple.ttsbundle.siri_Gordon_en-AU_compact”, “com.apple.ttsbundle.siri_Martha_en-GB_compact”, “com.apple.ttsbundle.siri_O-Ren_ja-JP_premium”, “com.apple.ttsbundle.siri_Hattori_ja-JP_compact”, “com.apple.ttsbundle.siri_Nicky_en-US_compact”, “com.apple.ttsbundle.siri_Martin_de-DE_compact”, “com.apple.ttsbundle.siri_Li-Mu_zh-CN_compact”, “com.apple.ttsbundle.siri_Dan_fr-FR_compact”, “com.apple.ttsbundle.siri_Aaron_en-US_compact”, “com.apple.ttsbundle.siri_Catherine_en-AU_compact”, “com.apple.ttsbundle.siri_Marie_fr-FR_compact”, “com.apple.ttsbundle.siri_O-Ren_ja-JP_compact”, “com.apple.ttsbundle.siri_Arthur_en-GB_compact”}, minusItems:{}}

17個のTTS Voice IDが追加されたことを確認できました。AVSpeechSynthesisVoice側で検出されていないTTS Voiceはないことも確認。

TTS Voice IDの個人的な理解は上記の表のとおりです。NSSpeechSynthesizerで検出できなかったのは、「com.apple.ttsbundle」ではじまるSiri系の(おそらく他のメーカーからのOEM)Voice Character 17個です。

AppleScript名:NSSpeechSynthesizerとAVSpeechSynthesisVoiceで返ってくるTTS Voice IDの違いを計算する
— Created 2024-10-11 by Takaaki Naganoya
— 2019-2024 Piyomaru Software
use AppleScript version "2.8"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use framework "AVFoundation"

set aList to current application’s NSSpeechSynthesizer’s availableVoices() as list
set bList to (current application’s AVSpeechSynthesisVoice’s speechVoices()’s valueForKey:"identifier") as list
set a1Res to checkAllItemsAreSame(aList, bList) of me
–>{addItems:{"com.apple.ttsbundle.siri_Nicky_en-US_premium", "com.apple.ttsbundle.siri_Hattori_ja-JP_premium", "com.apple.ttsbundle.siri_Helena_de-DE_compact", "com.apple.ttsbundle.siri_Yu-Shu_zh-CN_compact", "com.apple.ttsbundle.siri_Gordon_en-AU_compact", "com.apple.ttsbundle.siri_Martha_en-GB_compact", "com.apple.ttsbundle.siri_O-Ren_ja-JP_premium", "com.apple.ttsbundle.siri_Hattori_ja-JP_compact", "com.apple.ttsbundle.siri_Nicky_en-US_compact", "com.apple.ttsbundle.siri_Martin_de-DE_compact", "com.apple.ttsbundle.siri_Li-Mu_zh-CN_compact", "com.apple.ttsbundle.siri_Dan_fr-FR_compact", "com.apple.ttsbundle.siri_Aaron_en-US_compact", "com.apple.ttsbundle.siri_Catherine_en-AU_compact", "com.apple.ttsbundle.siri_Marie_fr-FR_compact", "com.apple.ttsbundle.siri_O-Ren_ja-JP_compact", "com.apple.ttsbundle.siri_Arthur_en-GB_compact"}, minusItems:{}}

–1D List同士の全要素が(登場順序が変更になっていても)同じかどうかをチェック
on checkAllItemsAreSame(aList, bList)
  set dRes to getDiffBetweenLists(aList, bList) of me
  
set ddRes to (dRes is equal to {addItems:{}, minusItems:{}}) as boolean
  
if ddRes = true then
    return true
  else
    return dRes
  end if
end checkAllItemsAreSame

–1D List同士のdiffを検出
on getDiffBetweenLists(aArray as list, bArray as list)
  set allSet to current application’s NSMutableSet’s setWithArray:aArray
  
allSet’s addObjectsFromArray:bArray
  
  
–重複する要素のみ抜き出す
  
set duplicateSet to current application’s NSMutableSet’s setWithArray:aArray
  
duplicateSet’s intersectSet:(current application’s NSSet’s setWithArray:bArray)
  
  
–重複部分を削除する
  
allSet’s minusSet:duplicateSet
  
set resArray to (allSet’s allObjects()) as list
  
  
set aSet to current application’s NSMutableSet’s setWithArray:aArray
  
set bSet to current application’s NSMutableSet’s setWithArray:resArray
  
aSet’s intersectSet:bSet –積集合
  
set addRes to aSet’s allObjects() as list
  
  
set cSet to current application’s NSMutableSet’s setWithArray:bArray
  
cSet’s intersectSet:bSet –積集合
  
set minusRes to cSet’s allObjects() as list
  
  
return {addItems:minusRes, minusItems:addRes}
end getDiffBetweenLists

★Click Here to Open This Script 

Posted in list Text to Speech | Tagged 15.0savvy | Leave a comment

Keynote上で選択中のテキストアイテムを、位置情報をもとにテキスト連結してクリップボードへ

Posted on 5月 13, 2024 by Takaaki Naganoya

Keynoteで作業がめんどくさくなったら、その場でAppleScriptを書いて使うシリーズ。Keynote v14で動かしていますが、別にバージョン依存している箇所はありません。もっと古いKeynoteでも動くと思います(KeynoteのAppleScript対応機能的には、slideのselectionができるようになったv12が実用下限だと思っています)。

Keynote書類の、章トビラに内容を個別のテキストアイテムで箇条書きしていたような場合に、

これを、全部結合して1つのテキストアイテムに入れたくなる時があります。

そこで、本ScriptのようなものをmacOS標準搭載のスクリプトメニューに入れて、

呼び出すために作ったものです。

実行すると、それぞれのテキストアイテムをY座標に着目してソートを行い、上→下の順番にならべかえて、テキストを取り出し、改行をはさみつつ連結します。

この後で、もとのテキストアイテムにこの連結したテキストを入れることになります。

一番上(positionのY座標が一番小さい)のテキストアイテムだけ残してあとは削除するわけですが、このあたりのオブジェクト操作もAppleScriptから操作してしまったほうがよさそうです。

ただし、Keynoteはテキストアイテム内の文字の上寄せ/下寄せの制御をAppleScriptからできないので(キーボードショートかメニューでも操作する?)そのあたりに「残念感」が残ってしまうかもしれません。

macOS標準搭載のスクリプトメニューに入れるAppleScriptで、絵文字を大量に入れるのは、大量のAppleScriptをメニューに入れるため文字だけだと視認性が低く、色付き文字を入れてそれぞれを識別しやすくするためです。

AppleScript名:🧭位置情報🧭をもとに🈴テキスト連結🈴して📎📎クリップボードへ📎📎.scpt
use AppleScript
use scripting additions
use framework "Foundation"

set outList to {}
set outStr to ""

tell application "Keynote"
  tell front document
    set aSel to selection
    
    
if length of aSel = 0 then
      display dialog "Keynote書類上で何も選択されていません。" with title "オブジェクト選択エラー" buttons {"OK"} default button 1 with icon 2
      
return
    else if length of aSel = 1 then
      display dialog "Keynote書類上で複数のオブジェクトが選択されていません。" with title "オブジェクト選択エラー" buttons {"OK"} default button 1 with icon 2
      
return
    else if (class of first item of aSel = slide) then
      display dialog "Keynote書類上でスライドが選択されてしまっています。" with title "オブジェクト選択エラー" buttons {"OK"} default button 1 with icon 2
      
return
    end if
    
    
repeat with i in aSel
      set j to contents of i
      
set aClass to class of j
      
if aClass = text item then
        set {aPosX, aPosY} to position of j
        
set aCon to object text of j
        
set the end of outList to {xPos:aPosX, yPos:aPosY, textCon:aCon}
      end if
    end repeat
    
  end tell
end tell

set bList to sortListAscending(outList, "yPos") of me

repeat with i in bList
  set j to contents of i
  
set aText to textCon of j
  
set outStr to outStr & aText & return
end repeat

set the clipboard to outStr
beep 1

–入れ子のリストを昇順ソート(AppleScriptObjC)
on sortListAscending(theList as list, keyLabel)
  set anArray to current application’s NSMutableArray’s arrayWithArray:(theList)
  
set theDescriptor to current application’s NSSortDescriptor’s sortDescriptorWithKey:(keyLabel) ascending:(true)
  
set sortedList to anArray’s sortedArrayUsingDescriptors:{theDescriptor}
  
return sortedList as list
end sortListAscending

★Click Here to Open This Script 

Posted in list Object control Record Sort | Tagged 12.0savvy 13.0savvy 14.0savvy Keynote | Leave a comment

NaturalLanguage frameworkを使って類語語展開+意味的な距離を計測してソート

Posted on 3月 13, 2024 by Takaaki Naganoya

NaturalLanguage frameworkといえば、macOS 10.14で追加されたものですが、自然言語テキストが「何語」であるかを推測するなどの使い方をAppleScriptから行なってきました。正直、その程度しか「役に立つ機能がない」という認識でした。

日本語のサポートはまだまだですが、日本語でなければ意外と使えることがわかりました。

試しに、NaturalLanguage.frameworkの機能を用いて指定の英単語の類義語を生成して、それぞれの元の単語との意味的な距離を計算してみました。

自然言語処理的にわかりやすい言葉でいえば、類語語のリストをword2vecでベクトル化してコサイン距離を計算する、というところでしょうか。

類義語展開であれば、日本語WordNetを利用して検索するAppleScriptを4年ぐらい前に試作ずみなので、このOS側の類義語展開機能がなくても別に構わないのですが、word2vecやsentence2vecで単語や文章をベクトル化して意味的な距離を計測する演算については、利用したいところです。

ただ、OSの機能が向上するどころか退化しているようなので、この分野ではmacOSの進歩は期待できないのかもしれません。

AppleScript名:指定単語の類義語を展開して元の単語との距離を測る.scpt
—
–  Created by: Takaaki Naganoya
–  Created on: 2024/03/12
—
–  Copyright © 2024 Piyomaru Software, All Rights Reserved
—

use AppleScript version "2.4" — Yosemite (10.10) or later
use framework "Foundation"
use framework "NaturalLanguage"
use scripting additions

set targLang to current application’s NLLanguageEnglish
set aEmb to current application’s NLEmbedding’s wordEmbeddingForLanguage:(targLang)
if aEmb = missing value then return –NLLanguageJapanese is not available here in macOS 13

–類義語展開(Max.50)
set aWord to "computer"
set aSym to (aEmb’s neighborsForString:aWord maximumCount:20 distanceType:(current application’s NLDistanceTypeCosine)) as list

–コサイン距離を計測(0.0〜2.0)数字が小さいと近いはず。ちょっとでも意味が遠いと2.0になるという悪癖を持つ
set distList to {}
repeat with i in aSym
  set j to contents of i
  
set aDist to (aEmb’s distanceBetweenString:aWord andString:j distanceType:(current application’s NLDistanceTypeCosine))
  
set the end of distList to {wordName:j, wordDistance:aDist as real}
end repeat

–昇順ソート
set bList to sortRecListByLabel(distList, "wordDistance", true) of me
–> {{wordDistance:0.837697923183, wordName:"workstation"}, {wordDistance:0.875068962574, wordName:"mainframe"}, {wordDistance:0.886509418488, wordName:"laptop"}, {wordDistance:0.901307225227, wordName:"software"}, {wordDistance:0.901674091816, wordName:"computing"}, {wordDistance:0.904342055321, wordName:"palmtop"}, {wordDistance:0.951638877392, wordName:"desktop"}, {wordDistance:0.954249441624, wordName:"intranet"}, {wordDistance:0.958346903324, wordName:"keystroke"}, {wordDistance:0.961381614208, wordName:"notebook"}, {wordDistance:0.964299142361, wordName:"server"}, {wordDistance:0.970234155655, wordName:"hardware"}, {wordDistance:0.974493980408, wordName:"pager"}, {wordDistance:0.981385648251, wordName:"electronic"}, {wordDistance:0.984282553196, wordName:"peripheral"}, {wordDistance:0.993325233459, wordName:"machine"}, {wordDistance:0.996084809303, wordName:"diskette"}, {wordDistance:0.999181330204, wordName:"portable"}, {wordDistance:1.001676082611, wordName:"compatible"}, {wordDistance:1.00532245636, wordName:"programmer"}}

–リストに入れたレコードを、指定の属性ラベルの値でソート
on sortRecListByLabel(aRecList as list, aLabelStr as string, ascendF as boolean)
  set aArray to current application’s NSArray’s arrayWithArray:aRecList
  
set sortDesc to current application’s NSSortDescriptor’s alloc()’s initWithKey:aLabelStr ascending:ascendF
  
set sortedArray to aArray’s sortedArrayUsingDescriptors:{sortDesc}
  
set bList to (sortedArray) as anything
  
return bList
end sortRecListByLabel

★Click Here to Open This Script 

本当は単語ではなく「文章」の距離を計測できないと実用性が低いところです。word2vecではなくsentence2vecの演算を行いたいところ。

自作のAppleScriptによるアイデアプロセッサ「Kamenoko」も、当初から自然言語処理の機能を盛り込むことを企画していました。sentence2vecぐらいの演算を行なって、各ノードに書いてある文章同士の距離を計測して、距離に応じて色を変えるといった機能も検討していました。

ただ、そうした機能を実装するのに割とデータ量が多くなるとか、アプリとしてパッケージングするのに無理があるとか、もういっそWebサーバー側で処理したほうがいいんじゃないの? 的な話になって見送った経緯があります。

このNaturalLanguage.frameworkがもっと使えるように、なったらいいのに。簡体字の中国語に対応しているぐらいなので、日本語への対応も期待したいところですが……macOS 14では対応言語が英語だけになるなど、展開の仕方が謎であります。

Posted in list Natural Language Processing Record | Tagged 13.0savvy 14.0savvy | Leave a comment

Post navigation

  • Older posts

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

Google Search

Popular posts

  • 開発機としてM2 Mac miniが来たのでガチレビュー
  • CotEditorで2つの書類の行単位での差分検出
  • macOS 15, Sequoia
  • 指定のWordファイルをPDFに書き出す
  • Pages本執筆中に、2つの書類モード切り替えに気がついた
  • Numbersで選択範囲のセルの前後の空白を削除
  • メキシカンハットの描画
  • Pixelmator Pro v3.6.4でAppleScriptからの操作時の挙動に違和感が
  • AdobeがInDesign v19.4からPOSIX pathを採用
  • Safariで「プロファイル」機能を使うとAppleScriptの処理に影響
  • AppleScriptによる並列処理
  • Cocoa Scripting Course 続刊計画
  • macOS 14.xでScript Menuの実行速度が大幅に下がるバグ
  • NaturalLanguage.frameworkでNLEmbeddingの処理が可能な言語をチェック
  • AppleScript入門③AppleScriptを使った「自動化」とは?
  • Keynote/Pagesで選択中の表カラムの幅を均等割
  • Keynote、Pages、Numbers Ver.14.0が登場
  • macOS 15 リモートApple Eventsにバグ?
  • デフォルトインストールされたフォント名を取得するAppleScript
  • AppleScript入門① AppleScriptってなんだろう?

Tags

10.11savvy (1101) 10.12savvy (1242) 10.13savvy (1391) 10.14savvy (587) 10.15savvy (438) 11.0savvy (283) 12.0savvy (212) 13.0savvy (190) 14.0savvy (142) 15.0savvy (121) CotEditor (66) Finder (51) iTunes (19) Keynote (116) 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 (54) 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
  • 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年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