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

月: 2022年3月

NSCharacterSetの使い方を間違えた

Posted on 3月 30, 2022 by Takaaki Naganoya

これまでに、NSMutableCharacterSetを使うべきところにNSCharacterSetを指定していたAppleScriptがあって、これは自分のミスだったのですが……これまで、この書き方で動いてしまって気が付かなかったものでした(Thanks Shane!)

このところ、AppleScriptの処理系やmacOS自体のバグが続いたので、不可思議な問題を見つけると「これどーなの?」と関係筋に確認をとっています。Appleにレポートする前に複数のScripterに確認をとって、「本当にそうなのか?」「再現性のあるトラブルか?」という話をしています。そんな中で、これは自分のミスでした。

on chkSymbol:checkString
	set muCharSet to NSCharacterSet's alloc()'s init()
	muCharSet's addCharactersInString:"$\"!~&=#[]._-+`|{}<>?%^*/'@-/:;(),"
	set ret to my chkCompareString:checkString baseString:muCharSet
	return ret as boolean
end chkSymbol:

それが、macOS 12.3で急に厳密に動かなくなり….逆にいえば、「なんでこれまでは動いていたんだろう?」というところではあるのですが、割と文字種別の判定はいろんなScriptで行なっているので影響が大きいところです。

on chkSymbol:checkString
	set muCharSet to NSMutableCharacterSet's alloc()'s init()
	muCharSet's addCharactersInString:"$\"!~&=#[]._-+`|{}<>?%^*/'@-/:;(),"
	set ret to my chkCompareString:checkString baseString:muCharSet
	return ret as boolean
end chkSymbol:

Cocoa Scripting Course #1 NSStringの付録サンプルScriptに該当するものがあるため、バグ情報を掲載しています。
また、差し替えたものをダウンロードできるように購入ページ上のアーカイブを更新いたします。

(Visited 71 times, 1 visits today)
Posted in Text | Tagged 12.0savvy NSCharacterSet NSMutableCharacterSet | Leave a comment

メニューからAppleScriptを呼び出すツールへの不満

Posted on 3月 28, 2022 by Takaaki Naganoya

macOS標準搭載のスクリプトメニューをはじめ、これまでにいろいろなツールが登場してきました。

しかし、どれもこれも機能が不十分で、満足できるものではありません。使えば使うほど「なんか違う」と感じてしまいます。

(1)メニューツールとScriptの連携ができない
(2)メニューに入れたScriptの説明を表示する機能がない
(3)明示的なメインスレッド実行ができない
(4)エンドユーザーにはFinder上のコンテクストメニューは認知されているものの、メニューバーに表示するスクリプトメニューの認知度が低い
(5)メニューに入れるScriptをオンラインアップデートできない

というところでしょうか。

Script Menuは、(1)〜(5)すべて満たしていません。
Fast Scriptでは、(2)〜(5)を満たしていません(1ができるのはえらい)。
Service Stationは、(1)〜(3)(5)を満たしていません。
Event Scriptは、(1)〜(5)すべて満たしていません。

とくに、(2)(3)(5)が問題だと思っています。各アプリケーション内蔵のスクリプトメニューも同様です。

メニューに入れてフォルダ分けしているとはいえ、名前だけ見てもそのScriptがどのような内容であったかを覚えていられないと思います。その内容を思い出すために(2)が必要です。

メインスレッド実行してくれないと実行できないScriptが存在しているため、(3)は欠かせません。

Scriptを自分で書いてメニューに入れられるユーザーがそれほどいないため、提供側がScript内容を配信してアップデートできるようにする必要があると思います。

ただし、Mac App Store経由で配信すると、(5)のような運用は許されません。そのため、Mac App Store以外で配信する形にしなければなりません。

さらに、メニュー内容の多言語対応も問題です。英語環境では英語で、日本語環境では日本語で表示されてほしいところです。

大事なのは、内容(Script)側であってスクリプトメニューアプリケーション側ではないのでは? というのが自分の考えです。

(Visited 47 times, 1 visits today)
Posted in news | Tagged Script Menu | Leave a comment

新刊電子書籍「Cocoa Scripting Course #4 System Hardware & Software Information」を刊行

Posted on 3月 28, 2022 by Takaaki Naganoya

電子書籍新刊「Cocoa Scripting Course #4 System Hardware & Software Information」を刊行しました。全561ページ、添付サンプルScript数665本となっています。最新のmacOS 12とM1 Mac環境での検証・対応を行なっています。

→ 販売ページ

AppleがmacOS 11上で作った「M1上でAppleScript+Cocoaの処理が遅くなるバグ」に邪魔され、これを解消するようテストやバグレポートを重ね、macOS 12側で問題が解決されました。こうした状況を受けてようやく本シリーズの刊行に復帰できました。

監修のedama2氏をはじめ、LateNight SoftwareのMark Alldrit、Shane Stanley、収録・紹介に許可をいただいた各種Frameworkの作者の皆様に感謝申し上げます。

(Visited 34 times, 1 visits today)
Posted in Books news | Leave a comment

macOS 12.3上でFinder上で選択中のファイルをそのままオープンできない件

Posted on 3月 28, 2022 by Takaaki Naganoya

macOS 12.xはAppleScriptの処理系に対して、主にセキュリティ面でいろいろ修正が加わっています。

この修正は、セキュリテイを「高める」という名目のもとに行われているのですが、セキュリティ面での課題さえ片付けられれば、その他に悪影響を及ぼしていたとしても「知ったことではない」というのがAppleの態度です。そして、その問題に対してユーザー側から文句が出てこなければ、そのままです。

–> View Demo Movie

とくに、深謀遠慮な考えとか、素晴らしい見通しとかはなく、「上から言われたからやっている」というやっつけ仕事感を感じます。

AppleはSteve Jobsが作り上げた秘密警察みたいな組織になっていて、チーム間の権限の切り分けが病的なまでに行われており、チームが違うと会社が違うぐらいの隔たりが発生しています。それは、Steve Jobsという「垣根を無視して横断して歩く異物」がいたから成立する組織であって、官僚化、硬直化が絶賛進行中といったところです。

話を戻しますが….たしかに、そうした機能的なアップを伴わない修正で何も問題(副作用)が起こらなければ「セキュリティが高まったのでよかったね」という美談になるわけですが、たいていの場合にはそうなりません。意図していなかった箇所に副作用が生じます。

あるいは、セキュリティのポリシー同士が実は矛盾を生んでいる、という状況になっていて、Aという問題とBという問題を解決した結果、あらたにCというもっと巨大な問題が発生する、とかいった状況は容易にあり得るわけです。それでも、各担当者は誠意をもってその仕事に取り組んでいるわけで、こうした「人間的に尊敬できて素晴らしい能力を持ったスタッフ」による「熱心かつ誠意あふれる真摯な仕事」が合成された結果、「見たことも聞いたこともない間抜けな理由から生じる猛毒にまみれた悪意」が合成されてしまうことが、現在のTim CookのAppleの下ではあり得るのです。

「Finder上で選択中のファイルをそのままオープンする」

というのは、ここ数年というよりもAppleScriptを覚えたてのころにちょろっと書いて実行したぐらいであり、実際のところ「それがどうした?」というレベルの処理です。

AppleScript名:Finder上で選択中のファイルをオープン.scpt
–macOS 12.3でエラーになる処理
tell application "Finder"
  open selection
end tell

★Click Here to Open This Script 

Finder上で選択したファイルに対する処理は、きょうび何かのアプリケーションに渡さなくてもAppleScriptだけで処理できてしまうことが多いということもありますし(画像とか)、選択されたファイルをそのままオープンするという「1=1」みたいな処理はやりません。

選択したフォルダの中をすべてSpotlight経由で走査して、指定の形式のファイルだけをリストアップして、順次処理するようなものになっています。

ただ、10年たっても20年たっても「1=1」みたいな処理しかしていない人がけっこういて驚かされると同時に、意外なところで(Adobeのアプリケーションでアプリケーション間の連携に)使っていたりして、修正されないと困るケースは多いようです。

Shane StanleyがLateNight Softwareのフォーラムに投稿した、こうした処理への迂回Scriptがありました。さすがです。

Finder経由で書類のオープンと、その書類を作成したアプリケーションの起動を促すという、macOS 12.3で問題が起こっている処理を、Cocoaの機能を用いることで迂回してしまおうというものです。

ただ、そのままではFinder上で指定したファイルを1つオープンするという実証コードのレベルのものだったので、複数のファイルが選択されたものをオープンするように書き足してみました。

AppleScript名:macOS 12.3でFinder上の選択中のファイルをオープン.scpt
—
–  Created by: Shane Stanley
–  Created on: 2022/03/24

–  Modified by: Takaaki Naganoya
–  Modified on: 2022/03/27
—
— macOS 12.3でFinder上のselectionをただopenすると、作成したアプリケーションは起動するが、書類はオープンされないバグ
– に対処したもの。複数ファイルの選択状態を処理する場合がほとんどなので、若干追記
– ただ、漫然と選択したファイルをオープンするという処理はやっていないので(なにがしかの処理を自前でやるので)

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

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

openFiles(aSel) of me

on openFiles(pathList as list)
  repeat with i in pathList
    set j to contents of i
    
openFile(POSIX path of j) of me
  end repeat
end openFiles

on openFile(thePath as string) — POSIX path
  set ws to current application’s NSWorkspace’s sharedWorkspace()
  
set theURL to current application’s |NSURL|’s fileURLWithPath:thePath
  
ws’s openURL:theURL
end openFile

★Click Here to Open This Script 

(Visited 112 times, 2 visits today)
Posted in Bug file news URL | Tagged 12.0savvy Finder | Leave a comment

macOS 12.x上のAppleScriptのトラブルまとめ

Posted on 3月 20, 2022 by Takaaki Naganoya

現在進行形で発生しているAppleScript系のトラブルについてまとめておきます。macOS 12になって、AppleScriptの処理系の根幹部分にいろいろ手が加わっており(だったら機能追加してほしい気がする)、不具合なのかセキュリティポリシーとの不整合なのか(そんなもん、社内で調整してほしい)よくわからない問題がいろいろ生じています。

Apple自身が機能ごとのリリースノートを出さないようになり、こういうときに困ります。

問題1:Scriptを実行すると「表があふれました」と謎のエラーが表示される(解決したか不明)

macOS 12.3で解消されるか? と見ていましたが、完全に対処できている感じではない様子。
→ 関連情報:SkimのAppleScriptサポート機能にバグ

問題2:12.3betaで発生した「AppleScript書類をオープンできない」問題(解決)

これについては、12.3Release版では発生していないもよう。息が止まるかと思うほど焦りました。電子書籍1つ作るにしても、手間のかかる作業の多くをAppleScriptで自動化。そうでなければ、そんなにポンポン書けません。

問題3:インストールされていないアプリケーションを操作するScriptをオープンできない(未解決)

ただし、そのMacにインストールされていないアプリケーションを操作するScriptをオープンしようとすると、これまでは「どのアプリケーションですか?」とユーザーに問い合わせしていましたが、これが一律にエラーになるようです。
→ macOS 12.5 beta5において、インストールされていないアプリケーションに対するAppleScriptをオープンした場合には、オリジナルのままオープンされ、コンパイル(構文確認)すると書き換えられるといった動作を行うことを確認しています

問題4:悪意を持って作られたAppleScriptバイナリ(アプレット?)のセキュリティ上の問題(CVE-2022-22626)(解決)

悪意を持って作成したAppleScriptバイナリは予期しない強制終了、ないしはプロセスが確保していたメモリを暴露(他のプロセスから読み書き&実行できてしまう?)する問題があったとのこと。

悪意を持って作ったことがないのと、ランタイムプログラムのメモリ処理の問題のようなので(???)、Scriptを書いている側には「そんなのあったの?」という話です。

個人的には、AppleScriptをアプレット化して動かすことは少なく、Script DebuggerかScript Menuで動かしている場合がほとんどです。

問題5:Finder上のselection itemsをオープンした際に、作成したアプリは起動されるがファイルはオープンされない問題

Finder上で選択したファイルを、指定のアプリケーションや、各ファイルを作成したアプリケーションで開かせようとした場合に、アプリケーションのプロセスは起動するものの、指定の書類はオープンされないという問題。macOS 12.3上で発生した新たな問題の様子。

先に対象のアプリケーションを起動しておくとファイルオープンの処理は通るというケースもあれば、そうではないというケースも。
→ macOS 12.3.1/12.4beta1で解消

問題6:macOS 12のスクリプトエディタで、Context Menu機能にバグ(未解決)


macOS 12のスクリプトエディタで、Script Assistantとして/Library/Scriptsに入れているAppleScriptをコンテクストメニューから呼び出せるようになっていますが、そこにカスタムScriptを入れて呼び出すと(絵文字入りファイル名)コンテクストメニュー上に重複した項目が表示されるというバグです。
→ 途中で「直った」という連絡をもらったのですが、まったく直っていませんでした。Appleのエンジニアは字が読めないか、目が見えないのでしょう。最低限、字が読めないとバグは取れないですよね?

問題7:アプリケーション同士のイベントのやりとりが2回以上発生するとエラー-609になるバグ

macOS 12.5 beta 5で発生した前代未聞のバグ(?)。

現在のTim Cook体制下で狙っていると見られる「セキュリティ確保のためには動かないコンピュータが最高!」の思想を体現する機能の実現のためか、こうしたアプリケーション同士のイベントの送信をカウントしているようです。これがバグなのか意図したものなのかは不明ですが、カウントして準備を始めたということだけは言えるでしょう。

ただ、Dockに登録したアプリケーションに書類をドラッグ&ドロップすると3回目からはエラーになりますし、FinderのToolbarに登録したアプリケーションのアイコンを3回クリックしてもエラー-609になります。とうてい、まともな状態とは言えません。

macOS 12.5でこの機能がオンになるものとは思っていませんが、Apple側が何かよからぬ企みを行っていることだけは明らかです。

「地獄への道は善意で敷き詰められている」(The road to hell is paved with good intentions)という言葉があります。セキュリティ強化の美名のもとにこれが実現したとき、コンピュータが役立たずの置物になってしまいます。Tim Cook CEOによる最悪の施策として記憶されることでしょう。頭が悪すぎです。
→ macOS 12.5(21G69)で解決???? Release Notesに記載されてもいないので不明

(Visited 281 times, 1 visits today)
Posted in Bug news | Tagged 12.0savvy | Leave a comment

ドラッグ&ドロップ機能の未来?

Posted on 3月 17, 2022 by Takaaki Naganoya

目下、Tim Cook体制のもと「セキュリティ至上主義」が掲げられ、機能の有用性とセキュリティ(機能を制限、削除する)をてんびんにかけると、後者が重視されるようになっています。

そんな中、ドラッグ&ドロップの機能についてはいろいろ制約を受けたり、一部で使えなくなっていくのではないかという「懸念」を持っています。

実際、macOS 10.12以降、AppleScriptドロップレット(ファイルのドラッグ&ドロップを受信して動作するAppleScriptの実行プログラム)がOS側のセキュリティ機能による動作の影響(xattr)を受け、まっとうな処理方法では期待されるファイル処理ができなくなっています(回避策はあります)。

このため、macOS上でもFinder上でiOS並みのファイル操作、ドラッグ&ドロップでファイル/フォルダを移動させる程度の処理しか許可されず、アプリケーション側にまとめてファイルを渡すような処理ができなくなる「かも」しれません。

このドラッグ&ドロップによるファイルの一括指示の機能を維持するために、「display drop dialog Script Library」というライブラリをedama2氏との協力のもと(自分は要望を出したぐらいで作ったのはedama2氏)、配布しています。

アラートダイアログで指定のファイルタイプの書類のFinderからのドラッグ&ドロップを受け付けます。わざわざDropletを作らなくてもファイルのドラッグ&ドロップを受け付けるためには、こうしたインタフェースがないとまずいんじゃないか? という予測のもとに企画したものです。

目下、macOS 12.3でFinderに対してファイルのAppleScriptからオープン操作を行わせると、「creatorのアプリケーションは起動するもののファイルがオープンされない」という現象が発生しており(エラーダイアログが出る例があったり、出ない例があったり)、Apple社内でも整合性が取れていない状況のようです。

Appleとしては個別のテクノロジーについて発言したり、WWDCでも技術ではなくマーケティング的なセッションが増えて「見るべきものがない」状況になっていますが、こうした状況は好ましいものとは言えません。

(Visited 332 times, 3 visits today)
Posted in Bug news | Tagged 12.0savvy | Leave a comment

Cocoa Scripting Course #4 近日刊行

Posted on 3月 16, 2022 by Takaaki Naganoya

Cocoa Scripting Courseの第4巻、「System Hardware & Software Information」を近日刊行いたします。

→ 発売しました!

第4巻では、ハードウェアやOSのソフトウェア情報、アプリケーション・バンドルからの情報取得を幅広く紹介しています。現時点で480ページぐらいです。

思えば、3巻目を刊行したあとに「M1 MacとmacOS 11の組み合わせだとしぬほどCocoa Scriptingが遅くなる」ことに気づいてAppleにレポート。この問題を片付けるまで続刊の刊行は見合わせざるを得ない状況でした。

「Appleの最新鋭マシンが10年前のMacBook Air 11インチより10倍遅いってマジか?」

みたいなレポートを行い、この煽りまくる(&詳細なデータとAppleScriptのプログラムを添えた)バグレポートが効いたとも言われています(本当のところは分かりませんけれども)。少なくとも、レポートしなかったら直っていなかったことでしょう。

無事、macOS 12でM1およびIntel CPU上でCocoa Scriptingを行なったときのスピード低下問題が解決。

この問題が解決したので、ようやく続刊の刊行に復帰した次第です。以前から地道に続け、飽きたら別の本に着手し、並列で4〜5冊進行しておりました。

Cocoa Scripting Courseはそんなに部数が出る本ではないので、ついつい後回しになりがちです。

(Visited 36 times, 1 visits today)
Posted in Books news | Leave a comment

[新刊]つたわる資料のつくりかた

Posted on 3月 15, 2022 by Takaaki Naganoya

あらたに電子書籍を刊行しました。「つたわる資料のつくりかた」。資料を作るすべての人に向けた、資料作成の基礎を解説する本です。Amazon Kindleで配信中。

(Visited 46 times, 1 visits today)
Posted in Books news | Leave a comment

クリップボードの画像を指定色でモノクロ化してクリップボードへ v3

Posted on 3月 13, 2022 by Takaaki Naganoya

クリップボードに入れた画像を、グレースケール化したあとに指定の色のベタ塗り画像とフィルタで合成し、単色の色付き画像に変換するAppleScriptです。

資料に掲載する画像の情報量を減らすために、単色画像に変換したいと考えました。Photoshopだと2つのレイヤーの重ね合わせで指定して処理するような内容です。ただ、もうPhotoshopにできるぐらいのことの大部分は、AppleScriptだけで単独でできてしまうのが2022年的な状況です。

アプリケーションを使わずに処理するためには、CIFilterを用いて画像処理して、単色画像にすることになります。

CIFilterにもいろいろな画像フィルタ機能が用意されているわけで、ここから「どのフィルタを使うか」選ぶことになります。

# フィルタが200種類ぐらいあるんですけど!!

このような場合のために、FileMaker Proで作った「FileMaker Pro PowerPack」だとひととおりのCIFilterをサンプルデータで処理できるようにしておきました。

FileMaker Proのデータベース上にサンプルデータをコピー&ペーストしておけば、DB上でフィルタ処理してどのような処理をしてくれるかがわかります。

いやーー、作っておいてよかったー。「なんでこんなにフィルタ処理ばっかりあるんだよ!」的な話がありましたが、こうして実際に役立つわけで。フィルタの名称、編集できるテストデータ、処理結果が表示されるところまで……「動かせる資料」的なものに仕上がっています>FileMaker Pro PowerPack

ひととおりAppleScriptを作ってみて、いろいろ調整してみたところ……調整し切れなかったので、edama2さんに相談して(送りつけて)こんな感じに仕上がりました。

これでなんとか動くはずなのに、なぜこうなるのか。。。CIFilterを実際に日常的に使うツールで使ったのは実はこれが最初だったので、意外な挙動に割と困りました。


▲画面上の指定範囲のスクリーンショットを撮ってクリップボードへ


▲ScriptをmacOS標準搭載のスクリプトメニューから呼び出すことを前提に作った。


▲クリップボードの内容をペーストすると、単色化された画像が出力される

AppleScript名:クリップボードの画像を指定色でモノクロ化してクリップボードへ v3.scpt
—
–  Created by: Takaaki Naganoya
–  Created on: 2022/03/11
—
–  Copyright © 2022 Piyomaru Software, All Rights Reserved
–  v2 Takaaki Naganoya : マスクが1/4の大きさになったり2倍になったりしていた
–  v3 edama2:上記の問題に対処。クリーンナップ
—
use AppleScript version "2.7"
use framework "AppKit"
use framework "CoreImage"
use framework "Foundation"
use scripting additions

on run
  my main()
end run

on main()
  –クリップボード内のデータをNSImageとして取得
  
set sourceImg to my getClipboardASImage()
  
  
# 色指定
  
set aColor to my makeNSColorFromRGBA255val(252, 2, 128, 255)
  
  
  
# 同じ大きさの塗りつぶし画像を作成
  
tell current application’s NSImage’s alloc()
    tell initWithSize_(sourceImg’s |size|())
      lockFocus()
      
aColor’s |set|()
      
set aRect to current application’s NSMakeRect(0, 0, its |size|()’s width, its |size|()’s height)
      
current application’s NSBezierPath’s fillRect:aRect
      
unlockFocus()
      
set fillImg to it
    end tell
  end tell
  
  
# NSImage –> CIimage
  
set sourceImage to my convNSImageToCIimage(sourceImg)
  
set fillImage to my convNSImageToCIimage(fillImg)
  
  
set newImage to my filterImage2(fillImage, sourceImage)
  
  
my restoreClipboard({newImage})
end main

on filterImage2(fillImage, sourceImage)
  
  
set redValue to 0.295719844358
  
set greenValue to 0.295719844358
  
set blueValue to 0.295719844358
  
set alphaVlaue to 1.0
  
set aCIColor to current application’s CIColor’s alloc()’s initWithRed:redValue green:greenValue blue:blueValue alpha:alphaVlaue
  
  
tell current application’s CIFilter
    — CIFilter(モノクロ化)
    
tell filterWithName_("CIColorMonochrome")
      setDefaults()
      
setValue_forKey_(sourceImage, "inputImage")
      
setValue_forKey_(aCIColor, "inputColor")
      
set filteredImage to valueForKey_("outputImage")
    end tell
    
    
— CIFilter(モノクロ化)
    
tell filterWithName_("CIAdditionCompositing")
      setDefaults()
      
setValue_forKey_(fillImage, "inputImage")
      
setValue_forKey_(filteredImage, "inputBackgroundImage")
      
set theCIImage to valueForKey_(current application’s kCIOutputImageKey)
    end tell
  end tell
  
  
# CIImage –> NSImage
  
set imageRep to current application’s NSCIImageRep’s alloc()’s initWithCIImage:theCIImage
  
set rNSImage to current application’s NSImage’s alloc()’s initWithSize:(imageRep’s |size|())
  
rNSImage’s addRepresentation:imageRep
  
  
return rNSImage
end filterImage2

# NSImage –> CIimage
on convNSImageToCIimage(aNSImage)
  set tiffDat to aNSImage’s TIFFRepresentation()
  
set aRep to current application’s NSBitmapImageRep’s imageRepWithData:tiffDat
  
set newImg to current application’s CIImage’s alloc()’s initWithBitmapImageRep:aRep
  
return newImg
end convNSImageToCIimage

— クリップボードの内容をNSImageとして取り出して返す
on getClipboardASImage()
  set thePasteboard to current application’s NSPasteboard’s generalPasteboard()
  
set theAttributedStringNSArray to thePasteboard’s readObjectsForClasses:({current application’s NSImage}) options:(missing value)
  
set theNSImage to theAttributedStringNSArray’s objectAtIndex:0
  
return theNSImage
end getClipboardASImage

on restoreClipboard(theArray as list)
  set thePasteboard to current application’s NSPasteboard’s generalPasteboard()
  
thePasteboard’s clearContents()
  
thePasteboard’s writeObjects:theArray
end restoreClipboard

on makeNSColorFromRGBA255val(redValue as integer, greenValue as integer, blueValue as integer, alphaValue as integer)
  set aRedCocoa to (redValue / 255) as real
  
set aGreenCocoa to (greenValue / 255) as real
  
set aBlueCocoa to (blueValue / 255) as real
  
set aAlphaCocoa to (alphaValue / 255) as real
  
set aColor to current application’s NSColor’s colorWithCalibratedRed:aRedCocoa green:aGreenCocoa blue:aBlueCocoa alpha:aAlphaCocoa
  
return aColor
end makeNSColorFromRGBA255val

★Click Here to Open This Script 

(Visited 45 times, 1 visits today)
Posted in filter Image | Tagged 12.0savvy CIColor CIImage NSBezierPath NSCIImageRep NSColor NSImage NSPasteboard | Leave a comment

指定のPDFの本文テキストの文字数をカウント

Posted on 3月 9, 2022 by Takaaki Naganoya

指定のPDFの本文テキストを取り出し、文字数をカウントするAppleScriptです。


▲「AppleScriptによるWebブラウザ自動操縦ガイド」の文字数をカウントしようとした

300ページを超える、わりと大きな本のPDFデータから文字を取り出したので、それなりの文字数になりました。つまり、Cocoaの有効活用を考えないとデータサイズ的につらそうなデータ量になることが予想されました。

当初、(文字処理については)Cocoaの機能をあまり活用しないv2を作ったものの、処理にM1 Mac miniで30秒ほどかかりました。すべてNSStringのまま(AppleScriptのstringに型変換せずに)処理してみたら、案の定、大幅に処理が高速化され6秒あまりで完了。

ただし、両者でカウントした文字数が1万文字ぐらい違っていたので、(PDFから取得した文字の)Unicode文字のNormalize方式を変更したところ、両者で同じ結果になりました。また、処理速度に改変前から大幅な変化はありませんでした。

文字数を数えるという処理だとさすがにデータ数が膨大になるため、NSStringで処理したほうがメリットが大きいようです。

# あれ? 5文字ぐらい違う、、、、絵文字の部分か?

AppleScript名:指定のPDFの本文テキストの文字数を数える v2
use AppleScript version "2.8" –macOS 12 or later
use framework "Foundation"
use framework "PDFKit" –Comment Out under macOS 11
–use framework "Quartz"–Uncomment under macOS 11
use scripting additions

script spd
  property cRes : ""
  
property cList : {}
end script

set (cRes of spd) to ""
set (cList of spd) to {}

set (cRes of spd) to getTextFromPDF(POSIX path of (choose file of type {"pdf"})) of me
set (cList of spd) to current application’s NSArray’s arrayWithArray:(characters of (cRes of spd))
set cLen to (cList of spd)’s |count|()
return cLen
–> 256137 (24.763sec)

on getTextFromPDF(posixPath)
  set theURL to current application’s |NSURL|’s fileURLWithPath:posixPath
  
set thePDF to current application’s PDFDocument’s alloc()’s initWithURL:theURL
  
return (thePDF’s |string|()’s precomposedStringWithCompatibilityMapping()) as text
end getTextFromPDF

★Click Here to Open This Script 

AppleScript名:指定のPDFの本文テキストの文字数を数える v3
use AppleScript version "2.8" –macOS 12 or later
use framework "Foundation"
use framework "PDFKit" –Comment Out under macOS 11
–use framework "Quartz"–Uncomment under macOS 11
use scripting additions

script spd
  property cRes : ""
  
property cList : {}
end script

set (cRes of spd) to ""
set (cList of spd) to {}

set (cRes of spd) to getTextFromPDF(POSIX path of (choose file of type {"pdf"})) of me
set cLen to (cRes of spd)’s |length|
return cLen as anything
–> 256142 (6.28 sec)

on getTextFromPDF(posixPath)
  set theURL to current application’s |NSURL|’s fileURLWithPath:posixPath
  
set thePDF to current application’s PDFDocument’s alloc()’s initWithURL:theURL
  
return (thePDF’s |string|()’s precomposedStringWithCompatibilityMapping())
end getTextFromPDF

★Click Here to Open This Script 

わずかとはいえ、違いが出ていることは確かなので、1つのPDFに対して2つの処理方法でテキストを取り出して、それを配列に入れて集合演算して差分をとってみました。M1でも処理に1分少々かかりました。こういう処理は、M1 MaxでもM1 Ultraでも所要時間は変わらないことでしょう(逆にM1の方が処理時間が短い可能性まである)。

どうやら改行コードの解釈で文字数カウント結果に違いが出たようです。

AppleScript名:テキストの抽出方法による文字数の相違チェック.scptd
use AppleScript version "2.8" –macOS 12 or later
use framework "Foundation"
use framework "PDFKit" –Comment Out under macOS 11
–use framework "Quartz"–Uncomment under macOS 11
use scripting additions

script spd
  property cRes : ""
  
property cList : {}
end script

set (cRes of spd) to ""
set (cList of spd) to {}

set docPath to POSIX path of (choose file of type {"pdf"})

set (cRes of spd) to getTextFromPDF1(docPath) of me
set (cList of spd) to characters of (cRes of spd)
set anArray to current application’s NSArray’s arrayWithArray:(cList of spd)

set bStr to getTextFromPDF2(docPath) of me
set bArray to current application’s NSMutableArray’s new()
set bLen to (bStr’s |length|) as anything
repeat with i from 0 to (bLen – 1)
  set tmpStr to (bStr’s substringWithRange:(current application’s NSMakeRange(i, 1)))
  (
bArray’s addObject:(tmpStr))
end repeat

set aRes to diffLists(anArray, bArray) of me
set bRes to diffLists(bArray, anArray) of me
return {aRes, bRes}

on getTextFromPDF1(posixPath)
  set theURL to current application’s |NSURL|’s fileURLWithPath:posixPath
  
set thePDF to current application’s PDFDocument’s alloc()’s initWithURL:theURL
  
return (thePDF’s |string|()’s precomposedStringWithCompatibilityMapping()) as text
end getTextFromPDF1

on getTextFromPDF2(posixPath)
  set theURL to current application’s |NSURL|’s fileURLWithPath:posixPath
  
set thePDF to current application’s PDFDocument’s alloc()’s initWithURL:theURL
  
return (thePDF’s |string|()’s precomposedStringWithCompatibilityMapping())
end getTextFromPDF2

–1D List同士のdiffを計算する
on diffLists(aList, bList)
  set aSet to current application’s NSMutableSet’s setWithArray:aList
  
set bSet to current application’s NSMutableSet’s setWithArray:bList
  
set aRes to calcSetDifference(aSet, bSet) of me
  
return aRes
end diffLists

–2つのNSMutableSetの補集合を求める
on calcSetDifference(aSet, bSet)
  aSet’s minusSet:bSet –補集合
  
set aRes to aSet’s allObjects() as list
  
return aRes
end calcSetDifference

★Click Here to Open This Script 

(Visited 62 times, 1 visits today)
Posted in PDF Text | Tagged 12.0savvy NSURL PDFDocument | Leave a comment

macOS 12のスクリプトエディタで、Context Menu機能にバグ

Posted on 3月 4, 2022 by Takaaki Naganoya

「AppleScriptによるWebブラウザ自動操縦ガイド」に添付している「Piyomaru Context Menu Assistant」。

スクリプトエディタのコンテクストメニューからAppleScriptを呼び出せるスクリプトエディタの機能を利用して、macOS標準装備の貧相で使い物にならないScriptを全部捨てて、そのかわりに強力なものをインストールするものです。


▲macOS標準でインストールされている、Script Assistant。古い、使えない、役に立たないの3拍子


▲Piyomaru Softwareが書籍のオマケでご提供しているPiyomaru Script Assistant(macOS 10.14.6)


▲macOS 12.3 beta 5上で表示したPiyomaru Script Assistant。メニュー項目(≒ファイル名)が2重に表示されている(macOS 12.3 beta5)

このScript Assistantが、macOS 12.3 beta 5上でメニュー項目が重複して表示されてしまうという現象に遭遇しています。

これは、macOS側のAppleが作ったバグであります。

(Visited 98 times, 1 visits today)
Posted in Bug | Tagged 12.0savvy | 1 Comment

書籍フォルダの階層をさかのぼって、ツメに掲載する最大チャプターを推測 v2

Posted on 3月 4, 2022 by Takaaki Naganoya

電子書籍を作るのにPagesやKeynoteを使っており、「AppleScriptによるWebブラウザ自動操縦ガイド」(以下、Webブラウザガイド)も全ページPagesで作っています。

PagesやKeynoteでは書籍作成用としては機能が素朴すぎて、足りない点はAppleScriptでツールを作って、作業の手間を減らしています。それらの補助Scriptは、各種パラメータをその本に合わせて固定して使用しています。

Webブラウザガイドは全14章で構成されているため、ページの左右につけている「ツメ」(Index)は1から14までの数字が入っています。

今後もツメチェックAppleScript(座標、塗りつぶし色と非選択色の自動判別、ファイル名からの該当章の自動ピックアップ)を他の書籍用にも運用していくつもりですが、この「全14章」という仕様は固定なので、章構成が異なる他の本のプロジェクトでは、自動で章の数をかぞえてくれるとよさそうだと考えました。

だいたい電子書籍のファイルについては、フォルダ分けして2階層ぐらいで管理しているので、その階層数については決め打ちでDoc rootフォルダを計算(parent of parent of….)するようにしました。そして、全フォルダのフォルダ名称を取得。

ダイアログで最終章を選択させると、そこから章番号を自動抽出して(「XX章」と書かれていることが前提)、その番号を返します。

こういう用途を考えると、階層構造をそのまま選択できるNSOutlineViewを選択用の部品に使えると便利で……これまでにもedama2さんと意見交換しつつNSOutlineViewをNSAlertダイアログ上に表示するといった試作も何回か検討してきたのですが、スクリプトエディタ/Script Debugger上で記述するAppleScriptObjCではこの部品を扱うのがとても難しいんですね。

ならば、Xcode上で記述するAppleScriptObjCにAppleScript用語辞書を持たせて、階層ファイル構造を選択させる専用の補助アプリケーションを作ってもいいのかも? ただ、Xcode 13.x系が壊れて使えないままの環境であるため、いまXcodeでビルドするわけにもいかないのでした。

choose fileコマンドやchoose folderコマンドに「icon view」「list view」「column view」といった初期表示状態を指定できる機能があれば、それで済むような気もしますが、どうせAppleに要望出してもこういうのは通らないので、自分で作ったほうが確実で早いですわー。

にしても、この通常ウィンドウと見分けがつかないファイル選択ダイアログ、macOS 11で最初に見たときには「正気か?!」と、腰を抜かしました。あいかわらず、この決定を下した責任者は●●だと思いますが、せめてもう少し視覚的に見分けがつくようにできなかったもんでしょうか。

AppleScript名:書籍フォルダの階層をさかのぼって、ツメに掲載する最大チャプターを推測 v2.scptd
—
–  Created by: Takaaki Naganoya
–  Created on: 2022/02/26
—
–  Copyright © 2022 Piyomaru Software, All Rights Reserved
—

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

tell application "Pages"
  tell front document
    set filePath to (file of it) as alias
  end tell
end tell

tell application "Finder"
  set parentFol to (parent of parent of filePath)
  
tell parentFol
    set fNames to name of every folder
  end tell
end tell

set folName to contents of (choose from list fNames with prompt "書籍のツメに載せる最終章のフォルダを選択")
set cNum to retChapter(folName as string) of me
–> 14

–ファイル名から「章」情報を抽出
on retChapter(aStr)
  set wList to words of aStr
  
set aCount to 1
  
repeat with ii in wList
    set jj to contents of ii
    
if jj = "章" then
      return contents of item (aCount – 1) of wList
    end if
    
set aCount to aCount + 1
  end repeat
  
return 0 –Illeagal file name
end retChapter

★Click Here to Open This Script 

(Visited 40 times, 1 visits today)
Posted in Books file File path Text | Tagged 12.0savvy Finder Pages | 1 Comment

Skimで現在表示中のページ(見開き2ページ、書籍モード)をJPEG画像で書き出す

Posted on 3月 2, 2022 by Takaaki Naganoya

SkimでPDFを、見開き2ページ、書籍モードで表示させた状態で、見開きごと2ページ分の画像をJPEG画像で書き出すAppleScriptです。

macOS 12.3 beta 5、Skim v1.6.8で動作を確認してあります。macOS 12に合わせてPDFKitを直接useコマンドで使用指定しています。


▲SkimでPDFをオープンした状態で実行。見開き2ページ、書籍モードを設定している状態


▲macOS標準搭載のスクリプトメニューから呼び出すことを前提に作ってあります


▲見開き2ページのうち、右ページを選択しているか、左ページを選択しているかの状態を検出して処理


▲出力結果。表示中のPDFと同じフォルダ内に作成される

AppleScript名:Skimで現在表示中のページ(見開き2ページ、書籍モード)をJPEG画像で書き出す
— Created 2022-03-02 by Takaaki Naganoya
— 2022 Piyomaru Software
use AppleScript version "2.7"
use scripting additions
use framework "Foundation"
use framework "Quartz"
use framework "PDFKit"
use framework "AppKit"

property |NSURL| : a reference to current application’s |NSURL|
property NSString : a reference to current application’s NSString
property NSImage : a reference to current application’s NSImage
property NSScreen : a reference to current application’s NSScreen
property NSNumber : a reference to current application’s NSNumber
property NSZeroPoint : a reference to current application’s NSZeroPoint
property PDFDocument : a reference to current application’s PDFDocument
property NSJPEGFileType : a reference to current application’s NSJPEGFileType
property NSCompositeCopy : a reference to current application’s NSCompositeCopy
property NSGraphicsContext : a reference to current application’s NSGraphicsContext
property NSBitmapImageRep : a reference to current application’s NSBitmapImageRep
property NSNumberFormatter : a reference to current application’s NSNumberFormatter
property NSImageInterpolationHigh : a reference to current application’s NSImageInterpolationHigh

tell application "Skim"
  set docCount to count every document
  
if docCount = 0 then return
  
  
tell front document
    set curViewSets to view settings
    
set curMode to display mode of curViewSets
    
    
if curMode is not in {two up, two up continuous} then
      display dialog "2ページ見開きモードでないため、処理を終了します。" with title "error" with icon 0
      
return
    end if
    
    
set bMode to displays as book of curViewSets
    
if bMode = false then
      display dialog "「書籍モード」でないため、処理を終了します。" with title "error" with icon 0
      
return
    end if
    
    
set curInd to index of current page
    
set docFile to file of it
  end tell
end tell

–PDFのファイルパスから実際のPDFを求める
set aPOSIX to POSIX path of docFile
set aURL to (|NSURL|’s fileURLWithPath:aPOSIX)
set aPDFdoc to PDFDocument’s alloc()’s initWithURL:aURL

–PDFのページ数を求める
set pCount to aPDFdoc’s pageCount() –ページ数

if curInd = pCount then
  display dialog "このページはPDFの最終ページなので、見開き表示になっていない可能性があります。" with title "エラー"
  
return
end if

if curInd = 1 then
  display dialog "このページはPDFの最初のページなので、見開き表示になっていない可能性があります。" with title "エラー"
  
return
end if

–見開き中の選択ページが奇数(右ページ)だった場合の対処
if chkOddNum(curInd) = true then set curInd to curInd – 1

–Detect Retina Environment
set compFactor to 1.0 –1.0 — 0.0 = max jpeg compression, 1.0 = none

set retinaF to NSScreen’s mainScreen()’s backingScaleFactor()
if retinaF = 1.0 then
  set aScale to 2.0 –Non Retina Env
else
  set aScale to 1.0 –Retina Env
end if

–Pick Up a PDF page as an image (Left Side Page)
set thisPageL to (aPDFdoc’s pageAtIndex:(curInd – 1))
set imgL to (NSImage’s alloc()’s initWithData:(thisPageL’s dataRepresentation()))
set pageL to renderPDFPageToNSImage(imgL, (curInd – 1), aScale) of me

–Pick Up a PDF page as an image (Right Side Page)
set thisPageR to (aPDFdoc’s pageAtIndex:(curInd – 0))
set imgR to (NSImage’s alloc()’s initWithData:(thisPageR’s dataRepresentation()))
set pageR to renderPDFPageToNSImage(imgR, (curInd – 0), aScale) of me

–Calc 2 pages’ width and others
set origWidth to (pageR’s |size|()’s width)
set newWidth to origWidth * 2
set newHeight to pageR’s |size|()’s height

–Make 2 pages’ blank image
set aSize to current application’s NSMakeSize(newWidth, newHeight)
set newImage to NSImage’s alloc()’s initWithSize:aSize

–Compositte each Left and Right page image
overlayNSImageByLeftTopOrigin(newImage, pageL, {0, 0}) of me
overlayNSImageByLeftTopOrigin(newImage, pageR, {origWidth, 0}) of me

–Save Image as JPEG
set theData to newImage’s TIFFRepresentation()
set newRep to (NSBitmapImageRep’s imageRepWithData:theData)
set targData to (newRep’s representationUsingType:(NSJPEGFileType) |properties|:{NSImageCompressionFactor:compFactor, NSImageProgressive:false})
set zText to retZeroPaddingText((curInd + 1), 4) of me
set outPath to addString_beforeExtensionIn_addingExtension_("_" & zText, aPOSIX, "jpg")
(
targData’s writeToFile:outPath atomically:true) –書き出し

on renderPDFPageToNSImage(anImage, aPageNum, aScale)
  set pointSize to anImage’s |size|()
  
  
set newSize to current application’s NSMakeSize((pointSize’s width) * aScale, (pointSize’s height) * aScale)
  
set newImage to (NSImage’s alloc()’s initWithSize:newSize)
  
  
newImage’s lockFocus()
  (
anImage’s setSize:newSize)
  (
NSGraphicsContext’s currentContext()’s setImageInterpolation:(NSImageInterpolationHigh))
  (
anImage’s drawAtPoint:(NSZeroPoint) fromRect:(current application’s CGRectMake(0, 0, newSize’s width, newSize’s height)) operation:(NSCompositeCopy) fraction:2.0)
  
newImage’s unlockFocus()
  
return newImage
end renderPDFPageToNSImage

–ファイルパス(POSIX path)に対して、文字列(枝番)を追加。任意の拡張子を追加
on addString:extraString beforeExtensionIn:aPath addingExtension:aExt
  set pathString to NSString’s stringWithString:aPath
  
set theExtension to pathString’s pathExtension()
  
set thePathNoExt to pathString’s stringByDeletingPathExtension()
  
  
set newPath to (thePathNoExt’s stringByAppendingString:extraString)’s stringByAppendingPathExtension:aExt
  
return newPath as string
end addString:beforeExtensionIn:addingExtension:

on retZeroPaddingText(aNum, aLen)
  set tText to ("0000000000" & aNum as text)
  
set tCount to length of tText
  
set resText to text (tCount – aLen + 1) thru tCount of tText
  
return resText
end retZeroPaddingText

–2つのNSImageを重ね合わせ合成してNSImageで返す(x,yで配置座標を指定) –newImageを参照渡し
on overlayNSImageByLeftTopOrigin(newImage, composeImage, aTargPos as list)
  set backSize to newImage’s |size|()
  
set bHeight to (height of backSize)
  
  
set overlaySize to composeImage’s |size|()
  
copy aTargPos to {x1, tempy1}
  
set x2 to (width of overlaySize)
  
set y2 to (height of overlaySize)
  
set y1 to bHeight – y2 + tempy1
  
  
newImage’s lockFocus()
  
  
set bRect to {{x1, y1}, {x2, y2}} –macOS 10.13 or later
  
set newImageRect to {{0, 0}, (newImage’s |size|)}
  
newImage’s drawInRect:newImageRect
  
composeImage’s drawInRect:bRect
  
  
newImage’s unlockFocus()
end overlayNSImageByLeftTopOrigin

on retUUIDfilePath(aPath, aExt)
  set aUUIDstr to (NSUUID’s UUID()’s UUIDString()) as string
  
set aPath to ((NSString’s stringWithString:aPath)’s stringByDeletingLastPathComponent()’s stringByAppendingPathComponent:aUUIDstr)’s stringByAppendingPathExtension:aExt
  
return aPath
end retUUIDfilePath

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

–奇数かどうかチェック
on chkOddNum(aNum)
  set a to aNum mod 2
  
if a = 1 then
    return true
  else
    return false
  end if
end chkOddNum

–偶数かどうかチェック
on chkEvenNum(aNum)
  set a to aNum mod 2
  
if a = 0 then
    return true
  else
    return false
  end if
end chkEvenNum

★Click Here to Open This Script 

(Visited 56 times, 1 visits today)
Posted in PDF | Tagged 12.0savvy | Leave a comment

macOS 12.3 beta 5、ASの障害が解消される(?)

Posted on 3月 2, 2022 by Takaaki Naganoya

macOS 12.3 beta 3/beta 4で発生していたAppleScriptの処理系全般にわたって発生していた障害が、beta 5で解消されたように見えます。

本Blogへのプログラムリスト掲載時に使っている「AS Publisher v1.8」(AppleScriptでAppleScriptを処理して掲載用のHTMLを生成するプログラム)自体が動作せず、Blogに投稿できない(横にある別Ver.OSのマシンでやればいいんですが)状況が続いていました。

本日配信されていたmacOS 12.3 beta 5で解消されたように見えます。手元にあるScriptが膨大すぎて、全数チェックするわけにもいきませんが、オープンできずにいたAppleScript書類はオープン/実行できています。

昨日リリースした書籍に掲載予定だったリストに動かないものがあって、掲載を見送る処理&使用しているプログラムの作者にお詫びのメールを送っていたのですが、なんのことはない、このbeta 3/4のバグのせいでした(beta 5にアップデートしたら何事もなかったように動いた)。

AppleScript書類をオープンできないとか実行できないといった「最悪レベルの問題」を起こさないことは確認できていますが、やっぱり「内部の表があふれる」的なエラーを出すScriptはまだあるようです。

macOS 11や10.15でそのようなエラーを起こす例を見なかったScriptなので、やはりmacOS 12環境に固有の問題が何かまだ残されているということなんでしょう。

macOS 12.3 beta 5、古めのMac OS X 10.2ぐらいの時期に書かれたAppleScript書類で、現在すでにOSにインストールされていない各種補助アプリケーションを呼び出しているものを、アプリケーション選択ダイアログを出さずに、いきなり「オープンできない」とダイアログを出して切り捨てる動作を行なっています。Script Debugger経由ではオープンできるため、依然として注意が必要です。

(Visited 190 times, 1 visits today)
Posted in Bug news | Tagged 12.0savvy | 8 Comments

新刊発売:AppleScriptによるWebブラウザ自動操縦ガイド

Posted on 3月 2, 2022 by Takaaki Naganoya

macOS用の7つのWebブラウザ(Safari、Chrome、Chromium、Microsoft Edge、Vivaldi、Brave Browser、Opera)を操作するAppleScript本です。PDF形式306ページ。

→ 販売ページ

1章 めんどうな操作を自動化しよう!

人間の手で操作して情報を集めたり、データ入力するのは非効率。スクリプトから操作して自動操作

2章 スクリプトエディタの使い方

AppleScript専用のスクリプトエディタの使い方など、基礎的な内容をご紹介。

3章 WebブラウザをAppleScriptから動かそう

macOS用Webブラウザの大半はAppleScriptから操作可能。AppleScript対応は必須の機能!

4章 Webブラウザの情報を取り出そう

Webブラウザ自体が大量の情報を管理しています。まずは、ブラウザの情報を調べてみましょう。

5章 指定URLをオープンしよう

誰にでも確実に行える操作です。かならず経験しておきましょう。URLをオープンした後が大事です。

6章 コンテンツをキャプチャして保存しよう

表示内容を変化しないデータや、再利用可能なデータとして残しておくことは、重要な処理です。

7章 Webコンテンツにアクセスしよう

HTML内の操作対象にアクセスするための、さまざまなアプローチをご紹介

8章 Webコンテンツを画面部品として操作しよう

画面上の部品と同様にWebコンテンツにアクセスして強引に操作する「奥の手」GUI Scripting

9章 ログイン、ログアウトしてみよう

ユーザー登録が必要なWebサイトの処理を行うために必須の作業です。意外とクリアしにくい箇所

10章 データをダウンロードして処理しよう

直接ダウンロードできないファイルのダウンロード完了を検出して、ファイル処理しよう! ダウンロード後にファイル整理したりファイル名を変更したり

11章 仮想ディスプレイでユーザーの誤操作を防ごう

ユーザーからの操作をガードするために、仮想ディスプレイを用意してWebブラウザを表示! 画面上から強引にScriptで動かすと、ユーザーの誤操作が一番の大敵

12章 さまざまな実行環境を知ろう

AppleScriptにはいろいろな実行環境があって、環境ごとにできる/できないことがあります。時間と気持ちに余裕のある時にでも読んでおくとよいでしょう。

13章 実例:Quoraの統計データを取得しよう

実際に、Quoraのアクセス情報ページにアクセスし、自分の投稿情報を取得してみよう!

14章 さまざまな技術資料。興味があったら読んでね

アプリケーション・オブジェクトの指定方法/AppleScript用語辞書の確認方法/Webブラウザの基礎的なScripting/Google Chrome系のWebブラウザのsdef/AppleScriptの歴史/AppleScriptのエラーコード表/AppleScript予約語一覧/各Webブラウザの用語辞書の変更履歴

(Visited 128 times, 2 visits today)
Posted in Books news | Tagged Brave Browser Chromium Google Chrome Opera Safari Vivaldi | Leave a comment

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

Google Search

Popular posts

  • AppleScriptによるWebブラウザ自動操縦ガイド
  • macOS 13, Ventura(継続更新)
  • ドラッグ&ドロップ機能の未来?
  • macOS 12.x上のAppleScriptのトラブルまとめ
  • PFiddlesoft UI Browserが製品終了に
  • macOS 12.3 beta 5、ASの障害が解消される(?)
  • SF Symbolsを名称で指定してPNG画像化
  • 新刊発売:AppleScriptによるWebブラウザ自動操縦ガイド
  • macOS 12.3上でFinder上で選択中のファイルをそのままオープンできない件
  • Pixelmator Pro v2.4.1で新機能追加+AppleScriptコマンド追加
  • Safariで表示中のYouTubeムービーのサムネイル画像を取得
  • macOS 12のスクリプトエディタで、Context Menu機能にバグ
  • 人類史上初、魔導書の観点から書かれたAppleScript入門書「7つの宝珠」シリーズ開始?!
  • UI Browserがgithub上でソース公開され、オープンソースに
  • macOS 12.5(21G72)がリリースされた!
  • Pages v12に謎のバグ。書類上に11枚しか画像を配置できない→解決
  • 新発売:AppleScriptからSiriを呼び出そう!
  • iWork 12.2がリリースされた
  • macOS 13 TTS Voice環境に変更
  • NSCharacterSetの使い方を間違えた

Tags

10.11savvy (1102) 10.12savvy (1243) 10.13savvy (1391) 10.14savvy (586) 10.15savvy (434) 11.0savvy (274) 12.0savvy (174) 13.0savvy (34) CotEditor (60) Finder (47) iTunes (19) Keynote (97) NSAlert (60) NSArray (51) NSBezierPath (18) NSBitmapImageRep (21) NSBundle (20) NSButton (34) NSColor (51) NSDictionary (27) NSFileManager (23) NSFont (18) NSImage (42) NSJSONSerialization (21) NSMutableArray (62) NSMutableDictionary (21) NSPredicate (36) NSRunningApplication (56) NSScreen (30) NSScrollView (22) NSString (118) NSURL (97) NSURLRequest (23) NSUTF8StringEncoding (30) NSUUID (18) NSView (33) NSWorkspace (20) Numbers (55) Pages (36) Safari (41) Script Editor (20) WKUserContentController (21) WKUserScript (20) WKWebView (23) WKWebViewConfiguration (22)

カテゴリー

  • 2D Bin Packing
  • 3D
  • AirDrop
  • AirPlay
  • Animation
  • AppleScript Application on Xcode
  • beta
  • Bluetooth
  • Books
  • boolean
  • bounds
  • Bug
  • Calendar
  • call by reference
  • Clipboard
  • Code Sign
  • Color
  • Custom Class
  • dialog
  • drive
  • 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
  • Machine Learning
  • Map
  • Markdown
  • Menu
  • Metadata
  • MIDI
  • MIME
  • Natural Language Processing
  • Network
  • news
  • Noification
  • Notarization
  • Number
  • Object control
  • OCR
  • OSA
  • PDF
  • Peripheral
  • PRODUCTS
  • QR Code
  • Raw AppleEvent Code
  • Record
  • 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)
  • 未分類

アーカイブ

  • 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