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

タグ: 15.0savvy

執筆中:スクリプトエディタ Scripting Book with AppleScript

Posted on 1月 1 by Takaaki Naganoya

あけましておめでとうございます。

目下執筆中なのが、「スクリプトエディタScripting Book with AppleScript」という本です。

AppleScriptでスクリプトエディタを操作してさまざまな処理を行うことをテーマに据えています。不可能を可能にする系の内容がぎっしり。割とカロリー高めな内容です。

スクリプトエディタはMac OS X 10.3か4のときにスクリプタブルになり、従来のCarbonではなくCocoaで書き直されました。生産性を向上させるためにスクリプトエディタを操作するScriptingはその頃から行なってきたのですが、ノウハウの総量は巨大なものの、これを必要としているユーザーがどの程度いるのか? という懸念から、まとめることをためらっていました。

ただ、まとめずに放置しておいては、有用なノウハウも風化してしまうため、この機会にまとめてみることにしたものです。

目下、400ページほど書いてみましたが、これはAppleScriptコマンドリファレンスを含んだものであり、記事ページについては「数ページの箇所もあれば数十ページの章もあって、バランスがよくない」といった印象です。

いったん寝かせて放っておくと、いい感じに発酵して(角がとれて)マイルドな味わいになるかもしれません。

Posted in Books | Tagged 13.0savvy 14.0savvy 15.0savvy | 2 Comments

choose fileで指定したsdefを読み込み、sdef中のサンプル(用例)を個別にHTML書き出しする

Posted on 12月 30, 2024 by Takaaki Naganoya

スクリプトエディタから書き出したsdefファイルを選択すると、指定の書き出し先フォルダにsdef内のAppleScriptサンプルをHTML形式で書き出すAppleScriptです(最初のバージョンでHTMLの実体参照デコード処理をハードコーディングしていたのを、Cocoaの機能を利用するよう書き換えました)。

スクリプトエディタでAppleScript用語辞書を表示させた状態で、ファイル書き出しすると個別のsdefファイルとして保存できます。この状態のsdefにアプリのバージョン番号を付加して、バージョン履歴として保存しています。

こうして保存しておいたsdef内のサンプルAppleScriptをHTMLとして書き出します。Pixelmator Proに58本のサンプルScriptが入っていたので、けっこうな分量になります。それを手作業で取り出すのは手間なので、Scriptで取り出すことにしました。

それを収集するために作ったのが本Scriptです。

本来、スクリプトエディタで表示(xinclude解消+レンダリング)させたsdefを処理させるAppleScriptで、いちいちxincludeの展開を行わせるのは無意味なのですが、本Scriptはもともと「アプリのBundle IDを指定してsdefのパスを求めて処理する」ようになっていたため、仕様がとがりすぎて汎用性がいまひとつだったので、「スクリプトエディタで書き出したsdefを処理」するように書き換えたという経緯があるためです。説明したら余計にわからなくなったような、、、、

AppleScript名:choose fileで指定したsdefを読み込み、sdef中のサンプル(用例)を個別にHTML書き出しする v2.scptd
—
–  Created by: Takaaki Naganoya
–  Created on: 2024/12/31
—
–  Copyright © 2022-2024 Piyomaru Software, All Rights Reserved
—

use AppleScript
use framework "Foundation"
use framework "AppKit"
use scripting additions

set sdefAlias to (choose file of type {"com.apple.scripting-definition"} with prompt "書き出したSDEFを選択")
set sdefFullPath to (POSIX path of sdefAlias)

–SDEF読み込み(Xincludeの展開が必要な状態)
tell current application
  set theXML to read sdefAlias as «class utf8»
end tell

–NSXMLDocumentの生成、Xincludeを有効に
set {theXMLDoc, theError} to current application’s NSXMLDocument’s alloc()’s initWithXMLString:theXML options:(current application’s NSXMLDocumentXInclude) |error|:(reference)

set aDocStr to (theXMLDoc’s XMLData)
set aDocStr2 to (current application’s NSString’s alloc()’s initWithData:(aDocStr) encoding:(current application’s NSUTF8StringEncoding)) as string

set sampleList to (extractStrFromTo(aDocStr2, "<html>", "</html>") of me)
set sampleCount to length of sampleList
if sampleCount = 0 then return

set outFol to POSIX path of (choose folder with prompt "Select Output Folder")

set aCount to 1

repeat with i in sampleList
  set j to (contents of i)
  
  
if j is not equal to "" then
    set j1 to decodeCharacterReference(j) of me
    
set j2 to "<!DOCTYPE html><html><meta charset=utf-8><title>" & (aCount as string) & "</title><body>" & j1 & "</body></html>"
    
    
set wPath to outFol & (aCount as string) & ".html"
    
set fRes to writeToFileAsUTF8(j2, wPath) of me
    
if fRes = false then error
    
    
set aCount to aCount + 1
  end if
end repeat

–指定パスからアプリケーションのScriptabilityをbooleanで返す
on retAppSdefNameFromBundleIPath(appPath as string)
  set aDict to (current application’s NSBundle’s bundleWithPath:appPath)’s infoDictionary()
  
set aRes to aDict’s valueForKey:"OSAScriptingDefinition"
  
if aRes = missing value then return false
  
set asRes to aRes as string
  
  
return asRes as string
end retAppSdefNameFromBundleIPath

–指定文字と終了文字に囲まれた内容を抽出
on extractStrFromTo(aParamStr, fromStr, toStr)
  set theScanner to current application’s NSScanner’s scannerWithString:aParamStr
  
set anArray to current application’s NSMutableArray’s array()
  
  
repeat until (theScanner’s isAtEnd as boolean)
    set {theResult, theKey} to theScanner’s scanUpToString:fromStr intoString:(reference)
    
theScanner’s scanString:fromStr intoString:(missing value)
    
set {theResult, theValue} to theScanner’s scanUpToString:toStr intoString:(reference)
    
if theValue is missing value then set theValue to "" –>追加
    
theScanner’s scanString:toStr intoString:(missing value)
    
anArray’s addObject:theValue
  end repeat
  
  
return (anArray as list)
end extractStrFromTo

on writeToFileAsUTF8(aStr, aPath)
  set cStr to current application’s NSString’s stringWithString:aStr
  
set thePath to POSIX path of aPath
  
set aRes to cStr’s writeToFile:thePath atomically:false encoding:(current application’s NSUTF8StringEncoding) |error|:(missing value)
  
return aRes as boolean
end writeToFileAsUTF8

–文字置換
on repChar(origText as string, targStr as string, repStr as string)
  set {txdl, AppleScript’s text item delimiters} to {AppleScript’s text item delimiters, targStr}
  
set temp to text items of origText
  
set AppleScript’s text item delimiters to repStr
  
set res to temp as text
  
set AppleScript’s text item delimiters to txdl
  
return res
end repChar

–実体参照をデコード
on decodeCharacterReference(aStr)
  set anNSString to current application’s NSString’s stringWithString:aStr
  
set theData to anNSString’s dataUsingEncoding:(current application’s NSUTF16StringEncoding)
  
set styledString to current application’s NSAttributedString’s alloc()’s initWithHTML:theData documentAttributes:(missing value)
  
set plainText to (styledString’s |string|()) as string
  
return plainText
end decodeCharacterReference

★Click Here to Open This Script 

Posted in file File path sdef XML | Tagged 13.0savvy 14.0savvy 15.0savvy | 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

CotEditor v5.0.7でwrite to consoleにオプションが追加される

Posted on 12月 23, 2024 by Takaaki Naganoya

オープンソースのテキストエディタ「CotEditor」の「write to console」コマンドにオプションが追加されました。

title(実行したAppleScript名の表記)と、timestamp表示の有無を指定できるようになっています。

ただし、これらのオプションが効くには条件があります。CotEditorの外部から、スクリプトエディタやScript Debuggerなどで実行したAppleScript内でCotEditorに対してwrite to consoleコマンドを実行した場合には、これらのオプションを指定していても、とくにtitle(ファイル名)については効きません。

CotEditorの内蔵スクリプトメニュー内で実行したAppleScriptにおいて「write to console」コマンドを実行した場合にはtitle(ファイル名)、timestamp(日時)の指定が有効です。

AppleScript名:コンソールテスト1.scpt
tell application "CotEditor"
  write to console "ぴよまるさんだよ" with title without timestamp
  
write to console "ぴよぴよさんだよ" with title and timestamp
end tell

★Click Here to Open This Script 

Posted in news Object control | Tagged 14.0savvy 15.0savvy CotEditor | Leave a comment

iWork apps 14.3にアップデート

Posted on 12月 22, 2024 by Takaaki Naganoya

Keynote、Pages、NumbersのiWork appsがバージョン14.3にアップデートしていました(気づかなかった)。

アップデート内容もたいしてありませんし、Apple Inteligenceを利用した機能なので、日本語環境では利用できません。

AppleScript用語辞書についても、とくに前バージョンから変更はありません。

Posted in news | Tagged 14.0savvy 15.0savvy Keynote Numbers Pages | Leave a comment

Keynoteで選択中のオブジェクトをリサイズ

Posted on 12月 20, 2024 by Takaaki Naganoya

Keynote書類上で選択中のオブジェクトのリサイズを行うAppleScriptです。

本Scriptの作成とテストはKeynote 14.214.3上で行いました。

Keynote書類は、4:3の書類と16:9の書類が存在しており、4:3の書類を16:9にリサイズしても内容についてはとくに変更は加えられず、逆に16:9の書類を4:3に変換すると、中身がぐしゃぐしゃになります。

「じゃあ、オブジェクトをグループ化してリサイズすれば?」

という話になりますが、やってみるとこれはうまく動きません。

iWork Apps間でのオブジェクトのコピー&ペーストにも問題があります。

たとえば、KeynoteからPagesにペーストした瞬間に「文字の回り込み」がデフォルトでオンになってしまい(この挙動が邪魔)、隣接するオブジェクトを避けて文字が回り込み、おかしな状態になります。

Keynote書類のリサイズ、他のiWork Appへのデータ使い回しを便利に行うために、オブジェクトのリサイズ処理というのは重要なテーマであり続けています。ただ、重要ではあるものの、iWork App上のオブジェクトのコントロール機能がAppleScript側に公開されていないため、手作業なしに複数オブジェクトをまとめてリサイズすることは(現状では)不可能です。


▲処理前 Keynote書類上のオブジェクトを選択した状態


▲処理後 本Scriptを実行したことにより、Keynote書類上の各種オブジェクトが1/2のサイズになっている。ただし、lineの太さがそのままだったり、text alignの都合でバランスが悪くなってしまった箇所がある

なので、ここに示したScriptは「あくまでも試作品」レベルのものであり、この困難な作業に対する「銀の弾丸」ではありません。

lineオブジェクトの線の太さを制御できないですし、テキストオブジェクトの左寄せ/右寄せといった制御がAppleScriptからできないため、テストデータを処理してみてもこれらの手作業が必要だと感じます。

それでも、100%すべて手作業で調整するよりは「いくぶんマシ」なものでしょう。

AppleScript名:選択中のオブジェクトのリサイズ.scptd
—
–  Created by: Takaaki Naganoya
–  Created on: 2024/12/20
—
–  Copyright © 2024 Piyomaru Software, All Rights Reserved
—

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

set aScale to 2

tell application "Keynote"
  tell front document
    set aSel to selection
    
    
repeat with i in aSel
      set j to contents of i
      
set aClass to class of j
      
      
      
if aClass is not in {document, slide} then
        set aPos to position of j
        
copy aPos to {xPos, yPos}
        
        
set aWidth to width of j
        
set aHeight to height of j
        
        
        
if (aClass = text item) or (aClass = shape) then
          tell j
            try
              set firstSize to size of first character of object text
              
set targSize to firstSize / aScale
              
ignoring application responses
                set size of every character of object text to targSize
              end ignoring
            end try
          end tell
        else if aClass = table then
          tell j
            set cList to every cell
            
repeat with ii in cList
              set jj to contents of ii
              
set aSize to font size of jj
              
ignoring application responses
                set font size of jj to (aSize / aScale)
              end ignoring
            end repeat
          end tell
        else if aClass = line then
          set lineW to width of j
          
–set width of j to (lineW / aScale)
        end if
        
        
ignoring application responses
          set j’s width to (aWidth / aScale)
          
set j’s height to (aHeight / aScale)
          
set j’s position to {xPos / aScale, yPos / aScale}
        end ignoring
      end if
    end repeat
  end tell
end tell

★Click Here to Open This Script 

Posted in Object control | Tagged 14.0savvy 15.0savvy Keynote | Leave a comment

指定フォルダ以下の画像のMD5チェックサムを求めて、重複しているものをピックアップ

Posted on 12月 19, 2024 by Takaaki Naganoya

指定フォルダ以下の画像(種別問わず)をすべてピックアップして、それぞれMD5チェックサムを計算し、重複しているものをピックアップしてデータとして出力するAppleScriptです。実行にはScript Debuggerを必要とします。内蔵のMD5計算Frameworkはx64/Apple Silicon(ARM64E)のUniversal Binaryでビルドしてあります。

–> –> Download photoDupLister(Script Bundle with Framework in its bundle)

# 本Scriptのファイル収集ルーチンが、再帰で下位フォルダの内容をすべてピックアップするものではありませんでした
# 実際に指定フォルダ以下すべての画像を収集する(Spotlightで)ようにしてみたら5.5万ファイルの処理に26分ほどかかりました

MD5チェックサムが同じということは、同じ画像である可能性が高いものです。

ここで、各画像のチェックサムを計算するさいに、サムネイルを生成してからチェックサムを計算するかどうかという話があります。

サムネイルを作成すべき派の言い分は、そのほうが計算量が減らせるし、同一画像の縮尺違い(拡大/縮小率違い)を求めることもできるというものです。

サムネイル作成否定派の言い分は、そんなもん作る前に画像のチェックサムを計算してしまえ、逆に手間だというものでした。

これは、どちらの意見ももっともだったので、実際にシミュレーションを行ってみるしかないでしょう。そこで、ありもののルーチンを集めて実際に作ってみたのが本Scriptです。サムネイルは作らないで処理してみました。

自分のMacBook Air M2のPicturesフォルダに入っていた約5,000の画像ファイルを処理したところ、16ペアの重複画像がみつかりました。処理にかかる時間はおよそ9秒です(実行するたびに所要時間が若干変化)。おそらく、Intel Macで実行すると数十秒から数分かかるのではないかと。

実用性を確保したい場合には、画像を回転しつつチェックサムを1画像あたり4パターン求めるとか、やはり同じサイズのサムネイル画像を生成してサムネイルに対してMD5チェックサムを計算するとか、画像の類似度を計算するオプションなども欲しいところです。

また、処理内容が並列処理向きなので、並列で処理してみてもよいでしょう。マシン環境を調べてSoCのPコアの個数をかぞえて、Pコアと同数の処理アプレットを生成して並列実行。……余計な処理を行うせいで速くならない可能性が高そうです。

AppleScript名:指定フォルダ以下の画像のMD5チェックサムを求めて、重複しているものをピックアップ
— Created 2015-10-01 by Takaaki Naganoya
— Modified 2015-10-01 by Shane Stanley–With Cocoa-Style Filtering
— Modified 2018-12-01 by Takaaki Naganoya
— Modified 2024-12-19 by Takaaki Naganoya
use AppleScript version "2.8"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use framework "md5Lib" –https://github.com/JoeKun/FileMD5Hash

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 NSCountedSet : a reference to current application’s NSCountedSet
property NSURLTypeIdentifierKey : a reference to current application’s NSURLTypeIdentifierKey

script spd
  property fList : {}
  
property fRes : {}
  
property md5List : {}
  
property fmdList : {}
  
property dupRes : {}
  
property outList : {}
end script

set anUTI to "public.image"

set aFol to choose folder
–set aFol to path to pictures folder

set (fList of spd) to getFilePathList(aFol) of me

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

–すべての画像のMD5チェックサムを計算
set (md5List of spd) to {}
set (fmdList of spd) to {}

repeat with i in (fRes of spd)
  set j to contents of i
  
set md5Res to (current application’s FileHash’s md5HashOfFileAtPath:(j)) as string
  
set the end of (md5List of spd) to md5Res
  
set the end of (fmdList of spd) to {filePath:j, md5:md5Res}
end repeat

–チェックサムが重複している画像を取り出す
set fmdArray to NSArray’s arrayWithArray:(fmdList of spd)

set (dupRes of spd) to returnDuplicatesOnly((md5List of spd)) of me
set (outList of spd) to {}
set procMDs to {}

repeat with i in (dupRes of spd)
  set j to contents of i
  
  
if j is not in procMDs then
    set aRes to filterDictArrayByLabel(fmdArray, "md5 == ’" & j & "’") of me
    
    
set tmpMD5 to filePath of (first item of aRes)
    
    
set tmpRes to {}
    
repeat with ii in aRes
      set jj to contents of ii
      
set the end of tmpRes to filePath of jj
    end repeat
    
    
set aRec to {md5:j, fileRes:tmpRes}
    
set the end of (outList of spd) to aRec
    
set the end of procMDs to j
  end if
end repeat

return (outList of spd)

–リストに入れたレコードを、指定の属性ラベルの値で抽出
on filterDictArrayByLabel(aArray, aPredicate as string)
  –抽出
  
set aPredicate to current application’s NSPredicate’s predicateWithFormat:aPredicate
  
set filteredArray to aArray’s filteredArrayUsingPredicate:aPredicate
  
  
–NSArrayからListに型変換して返す
  
set bList to filteredArray as list
  
return bList
end filterDictArrayByLabel

on getFilePathList(aFol)
  set aURL 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:aURL includingPropertiesForKeys:{} options:(current application’s NSDirectoryEnumerationSkipsHiddenFiles) |error|:(missing value)
  
return urlArray as anything
end getFilePathList

–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

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 check sum file Image UTI | Tagged 12.0savvy 13.0savvy 14.0savvy 15.0savvy | Leave a comment

MD5, SHA-1, SHA-3などのチェックサムを計算する

Posted on 12月 19, 2024 by Takaaki Naganoya

md5、sha-1、sha-3などのチェックサムを計算するAppleScriptです。

AppleScript、といいつつ、これらの処理の主体はすべてObjective-Cで書かれたプログラム(を、Cocoa Framework化したもの)です。

この種類の、ファイルの内容をすべて加算して計算するような処理は、インタプリタ型言語であるAppleScriptは苦手な処理です。何か、頭を使って処理量を減らすような工夫が通じません。

その結果、これらのScriptはScript Debugger上か、Script Debuggerから書き出したEnhanced Applet、その他のFramework呼び出しをサポートしているいくつかのAppleScript実行環境でしか実行できません。

Xcodeを用いてGUIなしヘルパーアプリを作って、他のAppleScript実行環境から呼び出しやすいようにSDEFを介して動かすようにすることも可能ですが、フリーで配布するほどの何かがあるわけでもありません。

なので、現状はこのままです。これらすべてのFrameworkを各ユーザー環境の~/Library/Frameworksフォルダにインストールして使用してください。x64/ARM64EのUniversal Binaryでビルドしてあります。

–> Download md5Lib.framework(To ~/Libraries/Frameworks)

–> Download md5FromDataKit.framework(To ~/Libraries/Frameworks)

–> Download SHA3Kit.framework(To ~/Libraries/Frameworks)

AppleScript名:ファイルのMD5、SHA1、SHA512のハッシュ値を求める
— Created 2016-02-11 by Takaaki Naganoya
— 2016 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "md5Lib" –https://github.com/JoeKun/FileMD5Hash

set aPath to POSIX path of (choose file)

set a to (current application’s FileHash’s md5HashOfFileAtPath:aPath) as string
–>  "329e854b9993405414c66faac0e80b86"

set b to (current application’s FileHash’s sha1HashOfFileAtPath:aPath) as string
–>  "50847286df61f304d142c6a0351e39029f010fc2"

set c to (current application’s FileHash’s sha512HashOfFileAtPath:aPath) as string
–>  "5132a7b477652db414521b36……..1a6ff240e861752c"
return {a, b, c}

★Click Here to Open This Script 

AppleScript名:NSStringからSHA-3のハッシュ値を求める
— Created 2017-08-09 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "SHA3Kit" –https://github.com/jaeggerr/NSString-SHA3

set origData to (current application’s NSString’s stringWithString:"hello")
set aHash1 to (origData’s sha3:256) as string
–> "1C8AFF950685C2ED4BC3174F3472287B56D9517B9C948127319A09A7A36DEAC8"

set aHash2 to (origData’s sha3:224) as string

set aHash3 to (origData’s sha3:384) as string

set aHash4 to (origData’s sha3:512) as string

★Click Here to Open This Script 

AppleScript名:NSDataからMD5値を計算する
— Created 2016-02-11 by Takaaki Naganoya
— 2016 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "md5FromDataKit" –https://github.com/siuying/NSData-MD5

set aStr to "ぴよまるソフトウェア"
set aNSStr to current application’s NSString’s stringWithString:aStr
set aData to aNSStr’s dataUsingEncoding:(current application’s NSUTF8StringEncoding)
set aMD5Hex to (current application’s NSData’s MD5HexDigest:aData) as string
–>  "2d0b4e205f274f20b17dc8ca4870f1db"

set aMD5 to (current application’s NSData’s MD5Digest:aData)’s |description|() as string
–>  <2d0b4e20 5f274f20 b17dc8ca 4870f1db>

★Click Here to Open This Script 

Posted in check sum | Tagged 11.0savvy 12.0savvy 13.0savvy 14.0savvy 15.0savvy | Leave a comment

2024年に書いた価値あるAppleScript

Posted on 12月 17, 2024 by Takaaki Naganoya

2024年に使用していたmacOS:macOS 13+macOS 15

毎年行なっている、Piyomaru Softwareが書いたAppleScriptの1年を振り返る記事の2024年版です。

2008年から10年ほど運営を続けてきた旧「AppleScriptの穴」Blogが2018年の年初にホスティング会社との行き違いでシャットダウンされ、ゼロから再構築したのがこの現行の「AppleScriptの穴」Blogです。

→ 2018年に書いた価値あるAppleScript
→ 2019年に書いた価値あるAppleScript
→ 2020年に書いた価値あるAppleScript
→ 2021年に書いた価値あるAppleScript
→ 2022年に書いた価値あるAppleScript
→ 2023年に書いた価値あるAppleScript

旧「AppleScriptの穴」Blogの内容については、データベースから抜き出したデータをもとに再構成した「Blogアーカイブ本」にまとめています。

AppleScriptの穴Blogアーカイブvol.1
AppleScriptの穴Blogアーカイブvol.2
AppleScriptの穴Blogアーカイブvol.3
AppleScriptの穴Blogアーカイブvol.4
AppleScriptの穴Blogアーカイブvol.5
AppleScriptの穴Blogアーカイブvol.6

本Blogは、もともとは、2000年代初頭に開発していた「人工知能インタフェース Newt On」のソースコード部品バラバラにして掲載し、用いた部品を個別にメンテナンスすることを「隠れた目的」としていました。また、Scripter間のノウハウの共有を推進することも目的としています。

AppleScript以外の一般的なテーマの記事については、こちらにいろいろ投稿しています。

https://note.com/140software/

前述のとおり、2018年1月にいちど本Blogは消えていました。その際に、「本Blogが存在しない場合にはどのような現象が起こるのか」を観察。その結果、AppleScriptについて知識を持たない人たちが好き勝手に「嘘」を流布しはじめる、という現象が観測されました。本Blogはそうした「嘘つき」を封じ込めるためのキーストーンとしての役割を果たしているといえます。

電子書籍の発行状況

本Blogを公開しているだけでは、ホスティング費用やドメイン費用がかかるだけで、何も収益が生まれません。そこで、本Blog+αの情報を整理してまとめた電子書籍を発行しています。本Blog読者のみなさまにおかれては、電子書籍を購入することで本Blog運営を支えていただけますと幸いです。

電子書籍の2024年における刊行は、現時点で95冊。年間8冊となっています。

Cocoa Scripting Course #7 NSColor
Cocoa Scripting Course #8 File path Processing
Cocoa Scripting Course #9 File Processing
AppleScriptでたのしむ レトロ・グラフィックス プログラム集
Pages+AppleScriptで本をつくろう!
AppleScript基礎テクニック集(32)複数のアプリをコントロール
AppleScript基礎テクニック集(33)選択中のオブジェクト取得
AppleScript 基礎テクニック集(34)電源制御

目下、既刊本の最新環境へのアップデートを実行中です。

2024年に書いたAppleScriptの中で注目すべきもの

余白トリミング実験 v3

余白トリミング実験 v3

2024年に書いたScriptのうちで一番気合いが入っているのが、この画像の余白トリミングです。AppleScriptでそんな画像処理ができるとは思ってもいませんでしたが、実際にやってみたらそれなりに機能して、それなりの速度で動きました。

Outline View Lib

Outline View Lib

NSOutlineViewを手軽に使えるライブラリです。他のアプリで作った階層データ(Keynoteのマスターページ名など)をプレビューするなどの用途に使えます。

書式つきテキストを組み立てて、画像を追加し、RTFDとして保存 v2

書式つきテキストを組み立てて、画像を追加し、RTFDとして保存 v2

電子書籍用にまとめていたScriptの中のひとつです。RTFDの新規保存については書いたことがなかったので、「書いておいたほうがよいだろう」と。同様にScptd(バンドル形式AppleScript)の作成Scriptも書いておきたいところ&scptdの実行Script(Script Viewを自前で作成して)も書いておきたいところですが、公表されているAPIの範囲では実行できるものが見当たりません。

アラートダイアログ上にWebViewで3Dコンテンツを表示(WebGL+three.js)v4

アラートダイアログ上にWebViewで3Dコンテンツを表示(WebGL+three.js)v4

これも、ずいぶん前に試作品を見ていたのですが、前バージョンが動かなくなって久しかったのでアップデートしておきました。あくまで、デモ用で実用性が皆無ですが、そういうものなんでしょう。

Pagesで、現在表示中のページから離れたページのオブジェクト情報を取得できない

Pagesで、現在表示中のページから離れたページのオブジェクト情報を取得できない

Pagesが怪奇現象を起こすことについては、ずいぶん前から知っていたのですが、その発生条件と範囲を明確にできたことは意義深いことです。

指定のSDEFファイルからコマンドを抽出

指定のSDEFファイルからコマンドを抽出

SDEF処理系AppleScriptはいろいろ組んでいますが、電子書籍作成時にアプリのアップデート履歴を表で示すためにこうしたScriptが必要です。

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

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

ChatGPTに書かせたAppleScriptです。バージョン依存しなかったり、他の言語で書いてあるものを翻訳するようなScriptだと割とまともなAppleScriptを出力してくれます。ただし、高速化の余地があるレベルの(遅い)Scriptだったので、自前で高速化してみました。

Excel__Numbersセルアドレスの相互変換

Excel__Numbersセルアドレスの相互変換

ChatGPTに書かせたAppleScriptです。こちらも、OSのバージョンに依存せず、他の言語でも書ける内容だったので、問題なく処理できるScriptが出力されました。

Posted in news | Tagged 13.0savvy 15.0savvy | Leave a comment

指定言語でNLEmbeddingを処理できるかチェック_13_14_15

Posted on 12月 16, 2024 by Takaaki Naganoya

NaturalLanguage.frameworkのごくごく入門的なオブジェクト「NLEmbedding」を利用できるか、各言語でチェックを行ったところ、macOS 13、14で予想外の結果が返ってきた内容をmacOS 15で再確認してみました。

ラテン系言語を中心に中国語がサポートされているあたりがあまりにも特徴的なNaturalLanguage.framework。多くの機能を日本語で利用できないことは分かりきっていたのですが、macOS 14で対応言語が激減。このまま廃止されるのかと驚いていたのですが、macOS 15で復旧していました。

どうしてmacOS 14.x台で復旧していなかったのか。ひたすら不思議です。

AppleScript名:指定言語でNLEmbeddingを処理できるかチェック_13_14_15.scpt
—
–  Created by: Takaaki Naganoya
–  Created on: 2024/03/13
—
–  Copyright © 2024 Piyomaru Software, All Rights Reserved
—

use AppleScript version "2.8"
use framework "Foundation"
use framework "NaturalLanguage"
use scripting additions

–The result is on macOS 13.6.5 / 14.4 / 15.2
set aRes to testNLLanguage("NLLanguageEnglish") of me –> true–> true –true
set aRes to testNLLanguage("NLLanguageFrench") of me –> true–>false (macOS 14)—> true
set aRes to testNLLanguage("NLLanguageGerman") of me –> true–>false (macOS 14)–> true
set aRes to testNLLanguage("NLLanguageItalian") of me –> true–>false (macOS 14)–> true
set aRes to testNLLanguage("NLLanguagePortuguese") of me –> true–>false (macOS 14)–> true
set aRes to testNLLanguage("NLLanguageSimplifiedChinese") of me –> true–>false (macOS 14)–> true
set aRes to testNLLanguage("NLLanguageSpanish") of me –> true–>false (macOS 14)–> true

set aRes to testNLLanguage("NLLanguageUndetermined") of me –> true –>Natural Language framework doesn’t recognize(macOS 14).–> true
–macOS 14.7.2で再確認したところtrueに

set aRes to testNLLanguage("NLLanguageAmharic") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageArabic") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageArmenian") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageBengali") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageBulgarian") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageBurmese") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageCatalan") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageCherokee") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageCroatian") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageCzech") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageDanish") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageDutch") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageFinnish") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageGeorgian") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageGreek") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageGujarati") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageHebrew") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageHindi") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageHungarian") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageIcelandic") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageIndonesian") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageJapanese") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageKannada") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageKazakh") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageKhmer") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageKorean") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageLao") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageMalay") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageMalayalam") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageMarathi") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageMongolian") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageNorwegian") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageOriya") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguagePersian") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguagePolish") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguagePunjabi") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageRomanian") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageRussian") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageSinhalese") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageSlovak") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageSwedish") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageTamil") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageTelugu") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageThai") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageTibetan") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageTraditionalChinese") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageTurkish") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageUkrainian") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageUrdu") of me –> false–> false–> false
set aRes to testNLLanguage("NLLanguageVietnamese") of me –> false–> false–> false

on testNLLanguage(aLangName)
  set aText to "use AppleScript
use framework \"Foundation\"
use framework \"NaturalLanguage\"

  set targLang to (current application’s " & aLangName & ")
  set aEmb to current application’s NLEmbedding’s wordEmbeddingForLanguage:(targLang)
  if aEmb = missing value then return false
  return true
  "

  
return run script aText
end testNLLanguage

★Click Here to Open This Script 

Posted in Natural Language Processing | Tagged 13.0savvy 14.0savvy 15.0savvy NLEmbedding | Leave a comment

Bluetoothに接続中のデバイス名を取得するv6

Posted on 12月 13, 2024 by Takaaki Naganoya

3年ぐらい前に書いてあった、Mac本体にペアリングして接続しているBluetoothのデバイス名を取得するAppleScriptです。

AppleScript名:Bluetoothに接続中のデバイス名を取得するv6.scptd
—
–  Created by: Takaaki Naganoya
–  Created on: 2024/12/13
—
–  Copyright © 2024 Piyomaru Software, All Rights Reserved
—

use AppleScript version "2.8"
use scripting additions
use framework "Foundation"
use framework "IOBluetooth"

set pRes to getBluetoothPowerState() of me
if pRes = false then return

set dArray to current application’s IOBluetoothDevice’s pairedDevices()
set dRes to my filterRecListByLabel1(dArray, "isConnected != 0")
set dNameList to (dRes’s valueForKeyPath:"name") as list
–> {"Logicool Z600", "Takaaki Naganoya のキーボード #1", "Takaaki Naganoya のマウス"}
–> {"Logicool Z600", "AirPods Pro", "DUALSHOCK 4 Wireless Controller"}

–リストに入れたレコードを、指定の属性ラベルの値で抽出
on filterRecListByLabel1(aRecList, 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
  
return filteredArray
end filterRecListByLabel1

–Mac本体のBluetoothのパワー状態を取得
on getBluetoothPowerState()
  set aCon to current application’s IOBluetoothHostController’s alloc()’s init()
  
set pRes to (aCon’s powerState()) as boolean
end getBluetoothPowerState

★Click Here to Open This Script 

Posted in Bluetooth System | Tagged 13.0savvy 14.0savvy 15.0savvy | Leave a comment

Skim v1.7.6でopen locationコマンドを実装するも動作せず

Posted on 12月 12, 2024 by Takaaki Naganoya

オープンソースのPDFリーダー「Skim」のバージョン1.7.6において「open location」コマンドが実装されましたが、実際に試してみると動きません。確認は最新版の1.7.7で行いました。

これまでにも追加したコマンドを次のバージョンで廃止して、翌々バージョンで復活させたりと、いろいろその歴史をひもとくと「おっとっと」な動きが見られるので、そういうものなんでしょう。

本Blog上に存在するPDFのURLを指定。open locationでダウンロード+表示を試みるものの、表示されずにエラーになる。

→ Skimが「http://」をサポートしていないとのこと。https://からのダウンロードおよび表示は確認しました。

AppleScript名:Skim v17.6で追加されたopen locationのテスト.scpt
set aURL to "http://piyocast.com/as/wp-content/uploads/2018/09/GUNDAM-UI.pdf"

tell application "Skim"
  set erRes to (open location aURL with error reporting)
end tell

★Click Here to Open This Script 

Posted in Bug | Tagged 13.0savvy 14.0savvy 15.0savvy Skim | Leave a comment

新刊電子書籍「AppleScript基礎テクニック(34)電源制御」を刊行

Posted on 12月 10, 2024 by Takaaki Naganoya

新刊電子書籍「AppleScript基礎テクニック(34)電源制御」を刊行しました。全57ページ、サンプルAppleScriptアーカイブつき。Piyomaru Softwareによる電子書籍の95冊目です。
→ 販売ページ

ちょっとAppleScriptを書けるようになった方が、必要に感じてふりかえる「基礎」的な内容をプレゼン資料風に絵でご紹介する「AppleScript基礎テクニック集」の34冊目、Macの電源制御に関する1冊です。 スリープ、シャットダウン、スリープ解除日時指定、バッテリー残量取得、電源種別の判定など、電源制御系の機能は、AppleScriptに添える「気の利いた」スパイス。知っておくと役立つ、実際に動かすと楽しい電源制御機能について、詳細にご紹介します。 いまはMacBook Airで1日中バッテリーで駆動できるのでシビアな計算が必要な場面は減ったように感じますが、それでもバッテリー残量を取得する処理はAppleScriptでも欠かせません。電源制御は使って動かすと面白い処理です。

目次

■最初に:macOS 13以降では最初にステージマネージャを必ずオフにしてください
  macOS 13.x
  macOS 14.x
  macOS 15.x
  その他、オフにすることが望ましい機能

■電源制御 関連機能
  macOSの各種電源コントロール機能
  AppleScriptからスリープ実行
  指定日時にスリープ解除
  電源種別判定
  バッテリー残量データ取得

■スリープ
  2つのスリープ処理
  スリープ処理
  ディスプレイ消灯処理

■スリープ解除
  スリープ解除(スケジュール登録)
  スリープ解除日時設定のAppleScript①〜③

■スリープ解除検出
  スリープ解除検出、2つの方法
  一番単純なスリープ解除検出
  システム通知を利用したスリープ解除検出①〜③

■電源オフ
  電源オフは2コース

■電源種別判定
  電源種別判定

■Mac本体のバッテリー残量取得
  バッテリー情報を取得する前に
  デスクトップ機とノート機の区別①〜③
  取得できるMac本体のバッテリー仕様
  Mac本体のバッテリー残量を取得

■その他資料
  ログアウト処理
  再起動
  CPU種別判定
  CPU動作クロック取得
  Apple Siliconの各種温度センサーの値を取得①〜③

Posted in Books news | Tagged 13.0savvy 14.0savvy 15.0savvy | Leave a comment

Excel 現在のシート上に存在しているpictureをすべて削除する

Posted on 12月 7, 2024 by Takaaki Naganoya

Excelでオープンしている最前面の書類の現在表示中のシート上に配置されているpicture(画像)をすべて削除するAppleScriptです。

pictureを大量に配置するScriptの後始末をするために作成したものです(書き捨てレベル)。

数万セルのデータを取得して、ふたたび書き戻すような処理を行っても数秒。セルのデータのI/Oが超高速なExcelですが、画像などのオブジェクト操作は時間がかかり、本Scriptで900個程度のpictureオブジェクト(画像)を削除すると、それなりに待たされます。しかも、ignoring responsesで非同期実行しても待たされます。


▲実行前


▲実行後

AppleScript名:現在のシート上に存在しているpictureをすべて削除する.scpt
—
–  Created by: Takaaki Naganoya
–  Created on: 2024/12/07
—
–  Copyright © 2024 Piyomaru Software, All Rights Reserved
—

tell application "Microsoft Excel"
  tell active workbook
    tell active sheet
      ignoring application responses
        delete every picture
      end ignoring
    end tell
  end tell
end tell

★Click Here to Open This Script 

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

Excel 指定範囲のセルの上に画像を配置

Posted on 12月 7, 2024 by Takaaki Naganoya

指定範囲(30×30)のセルの位置に画像を配置するAppleScriptです。

画像配置Scriptに対して「特定のセルを指定すると配置できずにエラーになる」という反応があったので、テストを行うために書いたものです。

結局、セルアドレスを「B5」ではなく「b5」と小文字で書いたことがエラーの原因でした。Excelのセルアドレスを小文字で書くなんて聞いたことがないのですが、たしかにこれに対処できないのは問題です。

なので、セルのcolumnを計算するルーチンで大文字/小文字を無視するように書き換えました。

AppleScript名:指定範囲のセルの上に画像を配置.scpt
—
–  Created by: Takaaki Naganoya
–  Created on: 2024/12/06
—
–  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

–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|()

repeat with targCellRow from 1 to 30
  repeat with targCellCol from 1 to 30
    
    
–Column No, & Row No. –> x position & y position
    
set {targCellX, targCellY} to retExcelCellPositiont(targCellCol, targCellRow) of me
    
    
–Place image on worksheet and resize and relocate it
    
tell application "Microsoft Excel"
      activate
      
      
tell active workbook
        tell active sheet
          ignoring application responses
            set newPic to make new picture at beginning with properties {file name:(anImagePOSIX), height:(overlaySize’s |height|), width:(overlaySize’s |width|), top:targCellY, left position:targCellX}
          end ignoring
        end tell
      end tell
    end tell
  end repeat
end repeat

–指定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
        ignoring case
          set columnNumber to columnNumber * 26 + (offset of char in "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
        end ignoring
      end using terms from
    end repeat
    
    
— 数値を返す
    
return {columnNumber, (rowPart as integer)}
  end cellToNumber
end script

★Click Here to Open This Script 

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

Excel 配置されている画像の左上のアドレスを取得してA1形式で返す

Posted on 12月 7, 2024 by Takaaki Naganoya

Microsoft Excelで、ワークシートに貼り込んだ画像の左上のセルアドレスを求めるAppleScriptです。

AppleScript名:配置されている画像の左上のアドレスを取得してA1形式で返す.scpt
—
–  Created by: Takaaki Naganoya
–  Created on: 2024/12/06
—
–  Copyright © 2024 Piyomaru Software, All Rights Reserved
—

tell application "Microsoft Excel"
  tell active workbook
    tell active sheet
      set aPic to picture 1
      
      
set tlCell to top left cell of aPic
      
set xCell to first column index of tlCell
      
set yCell to first row index of tlCell
      
      
set cellAdr to (numberToCell(xCell) of AddressEncoder) & (yCell as string)
      
–> "B5"
    end tell
  end tell
end tell

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
        ignoring case
          set columnNumber to columnNumber * 26 + (offset of char in "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
        end ignoring
      end using terms from
    end repeat
    
    
— 数値を返す
    
return {columnNumber, (rowPart as integer)}
  end cellToNumber
  
end script

★Click Here to Open This Script 

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

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

Posted on 12月 6, 2024 by Takaaki Naganoya

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

前バージョンが「動かない」という話があって、「そんなバカな?!」と、半信半疑でユーザーと同じドライブ名、フォルダ名、ファイル名、画像形式を採用したら(JPEG形式)同様にエラーになりました。自分がテストしたのは内蔵SSDで、画像形式はPNGだったのですが……

そこで、書き換えてJPEG画像でも、外付けドライブでもエラーにならないように書き換えてみました。

AppleScript名:指定セルに指定画像を貼り込む v2.scpt
—
–  Created by: Takaaki Naganoya
–  Created on: 2024/12/06
—
–  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 "C5"
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 newPic to make new picture at beginning with properties {file name:(anImagePOSIX), height:(overlaySize’s |height|), width:(overlaySize’s |width|), top:targCellY, left position:targCellX}
    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 Object control | Tagged 13.0savvy 14.0savvy 15.0savvy Excel | Leave a comment

アラートダイアログ上にWebViewで3Dコンテンツを表示(WebGL+three.js)v4

Posted on 12月 6, 2024 by Takaaki Naganoya

アラートダイアログ上にWkWebViewを作成して、さまざまなグラフや3Dアニメーションを表示してきた「箱庭ダイアログ」の1つの到達点、「periodictable」(元素周期表)選択UIの表示デモAppleScriptです。

–> Download Script Bundle

実行は掲載リストではなく上記のリンクからダウンロードしたAppleScriptバンドルを、かならずスクリプトエディタでオープンして(Script Debugger不可)、Controlキーを押しながらスクリプトエディタの「スクリプト」メニューから「フォアグラウンドで実行」コマンドで実行してください。

「フォアグラウンド」はApple(の外注のローカライズ業者による)ローカライズ内容が間違っていて、実際には「メインスレッドで実行」が正しいのですが、まあいいです。

以前に掲載したバージョン(v3)は、掲載後しばらくはそのまま動いていることが確認されたのですが、その後のCDN上のJavaScriptライブラリのアップデートにともない、動作しなくなっていました。本v4はその点を解決したもので、技術的により進化したというよりも、「勝手に動かなくなる点に対処した」程度のものとお考えください。

periodictableのUser Interface自体、目を惹くものであり、とても楽しいものです。ただ、真剣にその内容を解析し、汎用的に利用できるかどうかを検討してみると、おおよそ120個程度の要素に対して、重みづけを与えずに自由選択するような用途でないと実用性が得られないことがわかりました。たいてい、情報には重要度などの重みがありますが、本User Interfaceはそれがあると邪魔な感じです。

また、少ないデータ……2個や3個の要素から選択するのでは、用をなしません。用途が限定されすぎているというべきなのか、この用途にしか合わないというべきなのか。

JavaScriptとAppleScriptの間での選択項目のやり取りを行う手段についても、edama2氏が実際に稼働するデモを作ったのを見せてもらい、たしかにそうした処理ができることを確認しています。

それでも、いまひとつ実用性がないので、あくまで本プログラムは「デモ用」と割り切っています。

「CDN上のJavaScriptライブラリがアップデートして動かなくなる問題」についても、1つの解決策が見えてきました。ローカルにJavaScriptライブラリを配置して読み込んで使えばいいというものです。実際に、本ScriptバンドルのResourceフォルダ内にそれらのファイルが入っています。

これで勝手にアップデートされないため、放っておくと動かなくなるといった問題への解決策となっています。ただ、その一方でメイン処理を呼び出すさいに強制的なメインスレッド実行を行わせても、実行できないという謎の現象が発生。これについては、問題解決の手段自体はあるはずです(たぶん)。

AppleScript名:アラートダイアログ上にWebViewで3Dコンテンツを表示(WebGL+three.js)v4.scptd
—
–  Created by: Takaaki Naganoya
–  Created on: 2020/06/13
–  Modified on: 2023/03/07
—
–  Copyright © 2020-2023 Piyomaru Software, All Rights Reserved
—
use AppleScript version "2.7"
use framework "Foundation"
use framework "AppKit"
use framework "WebKit"
use scripting additions

property |NSURL| : a reference to current application’s |NSURL|
property NSAlert : a reference to current application’s NSAlert
property NSString : a reference to current application’s NSString
property NSButton : a reference to current application’s NSButton
property WKWebView : a reference to current application’s WKWebView
property WKUserScript : a reference to current application’s WKUserScript
property NSURLRequest : a reference to current application’s NSURLRequest
property NSRunningApplication : a reference to current application’s NSRunningApplication
property NSUTF8StringEncoding : a reference to current application’s NSUTF8StringEncoding
property WKUserContentController : a reference to current application’s WKUserContentController
property WKWebViewConfiguration : a reference to current application’s WKWebViewConfiguration
property WKUserScriptInjectionTimeAtDocumentEnd : a reference to current application’s WKUserScriptInjectionTimeAtDocumentEnd

property returnCode : 0

on run
  –https://www.cresco.co.jp/blog/entry/7427/
  
— By sgi-chang @ UX Design Center
  
set myStr to (POSIX path of (path to me)) & "/Contents/Resources/index.html"
  
  
set paramObj to {myMessage:"WebGL & three.js Test", mySubMessage:"This is a WebGL UI using three.js", htmlPath:myStr}
  
my browseFileWebContents:paramObj –for debug
  
–my performSelectorOnMainThread:"browseFileWebContents:" withObject:(paramObj) waitUntilDone:true
end run

on browseFileWebContents:paramObj
  set aMainMes to myMessage of paramObj
  
set aSubMes to mySubMessage of paramObj
  
set htmlPathStr to (htmlPath of paramObj)
  
  
set aWidth to 1600
  
set aHeight to 900
  
  
–WebViewをつくる
  
set aConf to WKWebViewConfiguration’s alloc()’s init()
  
  
–指定HTML内のJavaScriptをFetch
  
tell current application
    set htmlString to read ((POSIX file htmlPathStr) as alias) as «class utf8»
  end tell
  
set jsSource to pickUpFromToStr(htmlString, "<script src", "</script>") of me
  
  
set userScript to WKUserScript’s alloc()’s initWithSource:jsSource injectionTime:(WKUserScriptInjectionTimeAtDocumentEnd) forMainFrameOnly:true
  
set userContentController to WKUserContentController’s alloc()’s init()
  
userContentController’s addUserScript:(userScript)
  
aConf’s setUserContentController:userContentController
  
  
set aWebView to WKWebView’s alloc()’s initWithFrame:(current application’s NSMakeRect(0, 0, aWidth, aHeight)) configuration:aConf
  
aWebView’s setNavigationDelegate:me
  
aWebView’s setUIDelegate:me
  
aWebView’s setTranslatesAutoresizingMaskIntoConstraints:true
  
using terms from scripting additions
    set bURL to |NSURL|’s fileURLWithPath:(POSIX path of (path to me))
  end using terms from
  
set htmlURL to current application’s |NSURL|’s fileURLWithPath:htmlPathStr
  
aWebView’s loadFileURL:(htmlURL) allowingReadAccessToURL:(bURL)
  
  
— set up alert  
  
set theAlert to NSAlert’s alloc()’s init()
  
tell theAlert
    its setMessageText:aMainMes
    
its setInformativeText:aSubMes
    
its addButtonWithTitle:"OK"
    
–its addButtonWithTitle:"Cancel"
    
its setAccessoryView:aWebView
    
    
set myWindow to its |window|
  end tell
  
  
— show alert in modal loop
  
NSRunningApplication’s currentApplication()’s activateWithOptions:0
  
my performSelectorOnMainThread:"doModal:" withObject:(theAlert) waitUntilDone:true
  
  
–Stop Web View Action
  
set bURL to |NSURL|’s URLWithString:"about:blank"
  
set bReq to NSURLRequest’s requestWithURL:bURL
  
aWebView’s loadRequest:bReq
  
  
if (my returnCode as number) = 1001 then error number -128
end browseFileWebContents:

on doModal:aParam
  set (my returnCode) to (aParam’s runModal()) as number
end doModal:

on viewDidLoad:aNotification
  return true
end viewDidLoad:

on fetchJSSourceString(aURL)
  set jsURL to |NSURL|’s URLWithString:aURL
  
set jsSourceString to NSString’s stringWithContentsOfURL:jsURL encoding:(NSUTF8StringEncoding) |error|:(missing value)
  
return jsSourceString
end fetchJSSourceString

on pickUpFromToStr(aStr as string, s1Str as string, s2Str as string)
  set a1Offset to offset of s1Str in aStr
  
if a1Offset = 0 then return false
  
set bStr to text (a1Offset + (length of s1Str)) thru -1 of aStr
  
set a2Offset to offset of s2Str in bStr
  
if a2Offset = 0 then return false
  
set cStr to text 1 thru (a2Offset – (length of s2Str)) of bStr
  
return cStr as string
end pickUpFromToStr

–リストを任意のデリミタ付きでテキストに
on retArrowText(aList, aDelim)
  set aText to ""
  
set curDelim to AppleScript’s text item delimiters
  
set AppleScript’s text item delimiters to aDelim
  
set aText to aList as text
  
set AppleScript’s text item delimiters to curDelim
  
return aText
end retArrowText

on array2DToJSONArray(aList)
  set anArray to current application’s NSMutableArray’s arrayWithArray:aList
  
set jsonData to current application’s NSJSONSerialization’s dataWithJSONObject:anArray options:(0 as integer) |error|:(missing value) –0 is
  
set resString to current application’s NSString’s alloc()’s initWithData:jsonData encoding:(current application’s NSUTF8StringEncoding)
  
return resString
end array2DToJSONArray

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

★Click Here to Open This Script 

Posted in 3D Animation Web Contents Control | Tagged 13.0savvy 14.0savvy 15.0savvy | 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

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の処理に影響
  • Cocoa Scripting Course 続刊計画
  • macOS 14.xでScript Menuの実行速度が大幅に下がるバグ
  • AppleScript入門③AppleScriptを使った「自動化」とは?
  • Keynote/Pagesで選択中の表カラムの幅を均等割
  • デフォルトインストールされたフォント名を取得するAppleScript
  • macOS 15 リモートApple Eventsにバグ?
  • Keynote、Pages、Numbers Ver.14.0が登場
  • macOS 15でも変化したText to Speech環境
  • AppleScript入門① AppleScriptってなんだろう?
  • macOS 14で変更になったOSバージョン取得APIの返り値

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