AppleScript

AppleScript 予約語


Table 1-1 AppleScript reserved words, listed alphabetically link
Table 1-1  AppleScript reserved words, listed alphabetically

about

above

after

against

and

apart from

around

as

aside from

at

back

before

beginning

behind

below

beneath

beside

between

but

by

considering

contain

contains

contains

continue

copy

div

does

eighth

else

end

equal

equals

error

every

exit

false

fifth

first

for

fourth

from

front

get

given

global

if

ignoring

in

instead of

into

is

it

its

last

local

me

middle

mod

my

ninth

not

of

on

onto

or

out of

over

prop

property

put

ref

reference

repeat

return

returning

script

second

set

seventh

since

sixth

some

tell

tenth

that

the

then

third

through

thru

timeout

times

to

transaction

true

try

until

where

while

whose

with

without


Class
Table 2-1 Default coercions supported by AppleScript LINK

Table 2-1  Default coercions supported by AppleScript

Convert from class

To class

Notes

alias

list (single-item)

text

application

list (single-item)

This is both an AppleScript class and an application class.

boolean

integer

list (single-item)

text

class

list (single-item)

text

constant

list (single-item)

text

date

list (single-item)

text

file

list (single-item)

text

integer

list (single-item)

real

text

Coercing an integer to a number does not change its class.

list (single-item)

any class to which the item can be coerced if it is not part of a list

list (multiple-item)

text, if each of the items in the list can be coerced to a text object

number

integer

list (single-item)

real

text

Values identified as values of class number are really values of either class integer or class real.

POSIX file

see file

POSIX file is a pseudo-class equivalent to the file class.

real

integer

list (single-item)

In coercing to integer, any fractional part is rounded.

Coercing a real to a number does not change its class.

record

list

All labels are lost in the coercion and the resulting list cannot be coerced back to a record.

reference

any class to which the referenced object can be coerced

script

list (single-item)

text

integer

list (single-item)

real

Can coerce to integer or real only if the text object represents an appropriate number.

unit types

integer

list (single-item)

real

text

Can coerce between unit types in the same category, such as inches to kilometers (length) or gallons to liters (liquid volume).


Table 7-1 AppleScript commands LINK

Table 7-1  AppleScript commands

Command

Description

AppleScript suite

activate

Brings an application to the front, and opens it if it is on the local computer and not already running.

log

In Script Editor, displays a value in the Event Log History window or in the Event Log pane of a script window.

Clipboard Commands suite

clipboard info

Returns information about the clipboard.

set the clipboard to

Places data on the clipboard.

the clipboard

Returns the contents of the clipboard.

File Commands suite

info for

Returns information for a file or folder.

list disks

Returns a list of the currently mounted volumes.

Deprecated Use tell application "System Events" to get the name of every disk.

list folder

Returns the contents of a specified folder.

Deprecated Use tell application "System Events" to get the name of every disk item of ....

mount volume

Mounts the specified AppleShare volume.

path to (application)

Returns the full path to the specified application.

path to (folder)

Returns the full path to the specified folder.

path to resource

Returns the full path to the specified resource.

File Read/Write suite

close access

Closes a file that was opened for access.

get eof

Returns the length, in bytes, of a file.

open for access

Opens a disk file for the read and write commands.

read

Reads data from a file that has been opened for access.

set eof

Sets the length, in bytes, of a file.

write

Writes data to a file that was opened for access with write permission.

Internet suite

open location

Opens a URL with the appropriate program.

Miscellaneous Commands suite

current date

Returns the current date and time.

do shell script

Executes a shell script using the sh shell.

get volume settings

Returns the sound output and input volume settings.

random number

Generates a random number.

round

Rounds a number to an integer.

set volume

Sets the sound output and/or input volume.

system attribute

Gets environment variables or attributes of this computer.

system info

Returns information about the system.

time to GMT

Returns the difference between local time and GMT (Universal Time).

Scripting suite

load script

Returns a script object loaded from a file.

run script

Runs a script or script file

scripting components

Returns a list of all scripting components.

store script

Stores a script object into a file.

Standard suite

copy

Copies one or more values into variables.

count

Counts the number of elements in an object.

get

Returns the value of a script expression or an application object.

launch

Launches the specified application without sending it a run command.

run

For an application, launches it. For a script application, launches it and sends it the run command. For a script script object, executes its run handler.

set

Assigns one or more values to one or more script variables or application objects.

String Commands suite

ASCII character

Converts a number to a character.

Deprecated starting in AppleScript 2.0. Use the id property of the text class instead.

ASCII number

Converts a character to its numeric value.

Deprecated starting in AppleScript 2.0. Use the id property of the text class instead.

localized string

Returns the localized string for the specified key.

offset

Finds one piece of text inside another.

summarize

Summarizes the specified text or text file.

User Interaction suite

beep

Beeps one or more times.

choose application

Allows the user to choose an application.

choose color

Allows the user to choose a color.

choose file

Allows the user to choose a file.

choose file name

Allows the user to specify a new file reference.

choose folder

Allows the user to choose a folder.

choose from list

Allows the user to choose one or more items from a list.

choose remote application

Allows the user to choose a running application on a remote machine.

choose URL

Allows the user to specify a URL.

delay

Pauses for a fixed amount of time.

display alert

Displays an alert.

display dialog

Displays a dialog box, optionally requesting user input.

display notification

Displays a notification.

say

Speaks the specified text.

|

[LINK]AppleScript(更新)

過去のドキュメント
https://applescriptlibrary.wordpress.com/

JXA-Cookbook
JavaScript for Automationのチュートリアル
https://github.com/JXA-Cookbook/JXA-Cookbook/wiki

do shell script
https://developer.apple.com/library/archive/technotes/tn2065/_index.html

AppleScript Language Guide 2.0
https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide


AppleScript Terminology and Apple Event Codes
https://developer.apple.com/library/archive/releasenotes/AppleScript/ASTerminology_AppleEventCodes/TermsAndCodes.html


Foundation
https://developer.apple.com/documentation/foundation

AppleScript ObjC
https://developer.apple.com/library/archive/releasenotes/ScriptingAutomation/RN-AppleScriptObjC/index.html

|

新規AppleScriptファイルを作成する


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions
property refMe : a reference to current application

set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDownloadsDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDownloadsDirPathURL to ocidURLsArray's firstObject()
set aliasDefaultLocation to (ocidDownloadsDirPathURL's absoluteURL()) as alias
##################
###ダイアログ
set strName to (name of current application) as text
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
set strDefaultFileName to "お好きな名前で.applescript" as text
set strPromptText to "名前を決めてください" as text
set strMesText to "名前を決めてください" as text
###ファイル名 ダイアログ
try
  set aliasSaveFilePath to (choose file name strMesText default location aliasDefaultLocation default name strDefaultFileName with prompt strPromptText) as «class furl»
on error
return "キャンセルしました"
end try
##################
###パス
set strSaveFilePath to (POSIX path of aliasSaveFilePath) as text
set ocidSaveFilePathStr to refMe's NSString's stringWithString:(strSaveFilePath)
set ocidSaveFilePath to ocidSaveFilePathStr's stringByStandardizingPath()
set ocidSaveFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidSaveFilePath) isDirectory:false)

##################
###コンテンツ ここにスクリプトの内容を記述
### "のエスケープと改行 タブ等を\n\t等に置換する事
set strSaveData to ("return (current date) as date") as text
set ocidSaveData to refMe's NSString's stringWithString:(strSaveData)
##################
###保存
set listDone to ocidSaveData's writeToURL:(ocidSaveFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error|:(reference)
return

|

パスワード生成v2


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application
###ダイアログを前に
tell current application
  set strName to name as text
end tell
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
###ダイアログ
set aliasIconPath to POSIX file "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/LockedIcon.icns"
set strMes to ("桁数指定してください")
set numDeg to (13) as integer
set recordResult to (display dialog strMes with title "入力してください" default answer numDeg buttons {"キャンセル", "記号あり", "記号なし"} default button "記号あり" cancel button "キャンセル" giving up after 20 with icon aliasIconPath without hidden answer)

set strText to text returned of recordResult as text
###不要な文字の除去
set ocidResponseText to (refMe's NSString's stringWithString:(strText))
###タブと改行を除去しておく
set ocidTextM to refMe's NSMutableString's alloc()'s initWithCapacity:(0)
ocidTextM's appendString:(ocidResponseText)
##改行除去
set ocidTextM to ocidTextM's stringByReplacingOccurrencesOfString:("\n") withString:("")
set ocidTextM to ocidTextM's stringByReplacingOccurrencesOfString:("\r") withString:("")
##タブ除去
set ocidTextM to ocidTextM's stringByReplacingOccurrencesOfString:("\t") withString:("")
####戻り値を半角にする
set ocidNSStringTransform to (refMe's NSStringTransformFullwidthToHalfwidth)
set ocidTextM to (ocidTextM's stringByApplyingTransform:ocidNSStringTransform |reverse|:false)
###数字以外の値を取る
set ocidDecSet to refMe's NSCharacterSet's decimalDigitCharacterSet
set ocidCharSet to ocidDecSet's invertedSet()
set ocidCharArray to ocidTextM's componentsSeparatedByCharactersInSet:(ocidCharSet)
set numInteger to (ocidCharArray's componentsJoinedByString:"") as integer
###4文字以下はここで止める
if numInteger < 4 then
return "4文字以下はパスワードとは言いません"
end if

set numSetA to (round of (numInteger / 4) rounding up) as integer
set numTmp3 to numInteger - numSetA as integer
set numSetB to (round of (numTmp3 / 3) rounding down) as integer
set numTmp2 to numTmp3 - numSetB as integer
set numSetC to (round of (numTmp2 / 2) rounding down) as integer
set numSetD to numTmp2 - numSetC as integer

###ボタンによる分岐
if button returned of recordResult is "記号なし" then
  
  # set strCharSetA to "abcdefghijklmnopqrstuvwxyz"
  ##loijを使わないパターン
  set strCharSetA to "abcdefghkmnpqrstuvwxyz"
  # set strCharSetB to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  ##Oとiを使わないパターン
  set strCharSetB to "ABCDEFGHJKLMNPQRSTUVWXYZ"
  set strCharSetC to "0123456789"
  set strCharSetD to "abcdefghkmnpqrstuvwxyzABCDEFGHKMNPQRSTUVWXYZ23456789"
  
else if button returned of recordResult is "記号あり" then
  set strText to text returned of recordResult as text
  
  # set strCharSetA to "abcdefghijklmnopqrstuvwxyz"
  ##loijを使わないパターン
  set strCharSetA to "abcdefghkmnpqrstuvwxyz"
  # set strCharSetB to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  ##Oとiを使わないパターン
  set strCharSetB to "ABCDEFGHJKLMNPQRSTUVWXYZ"
  set strCharSetC to "0123456789"
  set strCharSetD to "@#$%&!¥=+?_-"
  
else
return "キャンセルしました"
end if


###出力用テキスト初期化
set strOutPutText to ("") as text
###パスワードは8コ生成する
repeat 8 times
  ###パスワード用文字列の初期化
  set strLineTextA to ("") as text
  repeat numSetA times
    ###文字数を数えて
    set numCntCharSet to (count of character of strCharSetA) as integer
    ###文字数内のランダム番号
    set numRandomNo to (random number from 1 to numCntCharSet) as integer
    ###ランダム番号の文字列を取り出して
    set strTmp to character numRandomNo of strCharSetA
    ###繋げてパスワード用の文字列とする
    set strLineTextA to (strLineTextA & strTmp) as text
  end repeat
  
  set strLineTextB to ("") as text
  repeat numSetB times
    ###文字数を数えて
    set numCntCharSet to (count of character of strCharSetB) as integer
    ###文字数内のランダム番号
    set numRandomNo to (random number from 1 to numCntCharSet) as integer
    ###ランダム番号の文字列を取り出して
    set strTmp to character numRandomNo of strCharSetB
    ###繋げてパスワード用の文字列とする
    set strLineTextB to (strLineTextB & strTmp) as text
  end repeat
  
  set strLineTextC to ("") as text
  repeat numSetC times
    ###文字数を数えて
    set numCntCharSet to (count of character of strCharSetC) as integer
    ###文字数内のランダム番号
    set numRandomNo to (random number from 1 to numCntCharSet) as integer
    ###ランダム番号の文字列を取り出して
    set strTmp to character numRandomNo of strCharSetC
    ###繋げてパスワード用の文字列とする
    set strLineTextC to (strLineTextC & strTmp) as text
  end repeat
  
  set strLineTextD to ("") as text
  repeat numSetD times
    ###文字数を数えて
    set numCntCharSet to (count of character of strCharSetD) as integer
    ###文字数内のランダム番号
    set numRandomNo to (random number from 1 to numCntCharSet) as integer
    ###ランダム番号の文字列を取り出して
    set strTmp to character numRandomNo of strCharSetD
    ###繋げてパスワード用の文字列とする
    set strLineTextD to (strLineTextD & strTmp) as text
  end repeat
  set strLineText to (strLineTextA & strLineTextB & strLineTextC & strLineTextD) as text
  set listLineText to every character of strLineText as list
  set ocidLineTextArrayM to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
ocidLineTextArrayM's addObjectsFromArray:(listLineText)
  
  ###指定の文字数分くりかえし
  set strLineOutPutText to "" as text
  ###文字数を数えて
  set numCntLineText to (count of character of strLineText) as integer
  repeat
    ###ランダム番号から
    set numRandomNo to (random number from 1 to numCntLineText) as integer
    ##対象の場所の文字を抜いて
    set ocidOutPutTmp to ocidLineTextArrayM's objectAtIndex:(numRandomNo - 1)
    ##その場所の文字は削除する
ocidLineTextArrayM's removeObjectAtIndex:(numRandomNo - 1)
    ##取り出した文字はテキストに
    set strLineOutPutText to (strLineOutPutText & (ocidOutPutTmp as text)) as text
    ##1文字減ったのでランダム番号も変わる
    set numCntLineText to numCntLineText - 1 as integer
    ###指定文字数で終了
    if numCntLineText = 0 then
      exit repeat
    end if
  end repeat
  ###パスワード用の文字列毎に改行を入れて
  set strLineText to (strLineOutPutText & "\n") as text
  ###出力用テキストにする
  set strOutPutText to (strOutPutText & strLineText) as text
end repeat


#####ダイアログを前面に
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
###ダイアログ
set strIconPath to "/System/Library/CoreServices/Finder.app/Contents/Resources/Finder.icns"
set aliasIconPath to POSIX file strIconPath as alias
set recordResult to (display dialog "戻り値" with title "戻り値です" default answer strOutPutText buttons {"クリップボードにコピー", "キャンセル", "OK"} default button "OK" cancel button "キャンセル" giving up after 20 with icon aliasIconPath without hidden answer)

if button returned of recordResult is "クリップボードにコピー" then
  set strText to text returned of recordResult as text
  ####ペーストボード宣言
  set appPasteboard to refMe's NSPasteboard's generalPasteboard()
  set ocidText to (refMe's NSString's stringWithString:(strText))
appPasteboard's clearContents()
appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
end if


|

GoogleDriveのパスを取得する


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#com.cocolog-nifty.quicktimer.icefloe
#
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application


##########################################
###【1】ドキュメントのパスをNSString
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidLibraryDirURL to ocidURLsArray's firstObject()
set ocidPlistFilePathURL to ocidLibraryDirURL's URLByAppendingPathComponent:("Preferences/com.google.drivefs.settings.plist")

##########################################
### 【2】PLISTを可変レコードとして読み込み
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidPlistFilePathURL)

##########################################
### 【3】値の取得
set ocidStringValue to (ocidPlistDict's valueForKey:("PerAccountPreferences"))

##########################################
### 【4】DICTに読み込む
###NSDATAに
set ocidStringData to ocidStringValue's dataUsingEncoding:(refMe's NSUTF8StringEncoding)
###JSONSerialization
set ocidOption to refMe's NSJSONReadingMutableContainers
set listJSONSerialization to refMe's NSJSONSerialization's JSONObjectWithData:(ocidStringData) options:(ocidOption) |error|:(reference)
set ocidJsonData to item 1 of listJSONSerialization
##########################################
###ダイアログ用のリスト
set listAccount to {} as list
### 【5】複数アカウント
set ocidAccountArray to (ocidJsonData's valueForKeyPath:("per_account_preferences"))
###アカウントの数だけ繰り返し
repeat with itemAccountArray in ocidAccountArray
  ###OS12以降は
  set ocidDirPath to (itemAccountArray's valueForKeyPath:("value.mount_point_path"))
  set ocidDirName to ocidDirPath's lastPathComponent()
  set end of listAccount to (ocidDirName as text)
  ###OS12以前の場合はこちら
  # set end of listAccount to (ocidDirPath as text)
  ###リストにフォルダ名=アカウント名を取得する
  
end repeat
##########################################
### 【6】ダイアログ
try
  ###ダイアログを前面に出す
  tell current application
    set strName to name as text
  end tell
  if strName is "osascript" then
    tell application "Finder"
      activate
    end tell
  else
    tell current application
      activate
    end tell
  end if
  set listResponse to (choose from list listAccount with title "選んでください" with prompt "選んでください" default items (item 1 of listAccount) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
on error
  log "エラーしました"
return "エラーしました"
end try
if (item 1 of listResponse) is false then
return "キャンセルしました"
end if
set strDirName to (item 1 of listResponse) as text

##########################################
### 【7】開く
###
if strDirName contains "/" then
  set strCoreStoragePath to (strDirName) as text
  set ocidGoogleDriveDirPathStr to refMe's NSString's stringWithString:(strCoreStoragePath)
  set ocidGoogleDriveDirPath to ocidGoogleDriveDirPathStr's stringByStandardizingPath()
  set ocidGoogleDriveDirPathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidGoogleDriveDirPath) isDirectory:false)
else
  set strCoreStoragePath to ("CloudStorage/" & strDirName) as text
  ###NSURLにしておいて
  set ocidGoogleDriveDirPathURL to ocidLibraryDirURL's URLByAppendingPathComponent:(strCoreStoragePath)
end if
##パスにして
set ocidGoogleDriveDirPath to ocidGoogleDriveDirPathURL's |path|()
###パスの有無を確認
set boolDirExists to appFileManager's fileExistsAtPath:(ocidGoogleDriveDirPath) isDirectory:(true)
if boolDirExists = true then
  ###パスがあるなら開く
  set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
appSharedWorkspace's selectFile:(missing value) inFileViewerRootedAtPath:(ocidGoogleDriveDirPath)
else if boolDirExists = false then
return "ディレクトリが見つかりません"
end if








|

濁音 半濁音 レコード


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

###【1】半角カナ 濁音 半濁音 レコード
set recordKanaDakuon to {|ガ|:"ガ", |ギ|:"ギ", |グ|:"グ", |ゲ|:"ゲ", |ゴ|:"ゴ", |ザ|:"ザ", |ジ|:"ジ", |ズ|:"ズ", |ゼ|:"ゼ", |ゾ|:"ゾ", |ダ|:"ダ", |ヂ|:"ヂ", |ヅ|:"ヅ", |デ|:"デ", |ド|:"ド", |バ|:"バ", |ビ|:"ビ", |ブ|:"ブ", |ベ|:"ベ", |ボ|:"ボ", |パ|:"パ", |ピ|:"ピ", |プ|:"プ", |ペ|:"ペ", |ポ|:"ポ"} as record
set ocidKanaDakuonDict to refMe's NSDictionary's alloc()'s initWithDictionary:(recordKanaDakuon)
set ocidKanaDakuonKeyArray to ocidKanaDakuonDict's allKeys()

###【2】半角カナ 濁音 半濁音 別文字 レコード
set recordKanaDakuonW to {|ガ|:"ガ", |ギ|:"ギ", |グ|:"グ", |ゲ|:"ゲ", |ゴ|:"ゴ", |ザ|:"ザ", |ジ|:"ジ", |ズ|:"ズ", |ゼ|:"ゼ", |ゾ|:"ゾ", |ダ|:"ダ", |ヂ|:"ヂ", |ヅ|:"ヅ", |デ|:"デ", |ド|:"ド", |バ|:"バ", |ビ|:"ビ", |ブ|:"ブ", |ベ|:"ベ", |ボ|:"ボ", |パ|:"パ", |ピ|:"ピ", |プ|:"プ", |ペ|:"ペ", |ポ|:"ポ"} as record
set ocidKanaDakuonWDict to refMe's NSDictionary's alloc()'s initWithDictionary:(recordKanaDakuonW)
set ocidKanaDakuonWKeyArray to ocidKanaDakuonWDict's allKeys()

###【3】全角カナ 濁音 半濁音 別文字 レコード
set recordKanaWDakuonW to {|ガ|:"ガ", |ギ|:"ギ", |グ|:"グ", |ゲ|:"ゲ", |ゴ|:"ゴ", |ザ|:"ザ", |ジ|:"ジ", |ズ|:"ズ", |ゼ|:"ゼ", |ゾ|:"ゾ", |ダ|:"ダ", |ヂ|:"ヂ", |ヅ|:"ヅ", |デ|:"デ", |ド|:"ド", |バ|:"バ", |ビ|:"ビ", |ブ|:"ブ", |ベ|:"ベ", |ボ|:"ボ", |パ|:"パ", |ピ|:"ピ", |プ|:"プ", |ペ|:"ペ", |ポ|:"ポ"} as record
set ocidKanaWDakuonWDict to refMe's NSDictionary's alloc()'s initWithDictionary:(recordKanaWDakuonW)
set ocidKanaWDakuonWKeyArray to ocidKanaWDakuonWDict's allKeys()

###【4】全角ひら 濁音 半濁音 別文字 レコード
set recordHiraKanaDakuonW to {|が|:"が", |ぎ|:"ぎ", |ぐ|:"ぐ", |げ|:"げ", |ご|:"ご", |ざ|:"ざ", |じ|:"じ", |ず|:"ず", |ぜ|:"ぜ", |ぞ|:"ぞ", |だ|:"だ", |ぢ|:"ぢ", |づ|:"づ", |で|:"で", |ど|:"ど", |ば|:"ば", |び|:"び", |ぶ|:"ぶ", |べ|:"べ", |ぼ|:"ぼ", |ぱ|:"ぱ", |ぴ|:"ぴ", |ぷ|:"ぷ", |ぺ|:"ぺ", |ぽ|:"ぽ"} as record
set recordHiraKanaDakuonWDict to refMe's NSDictionary's alloc()'s initWithDictionary:(recordHiraKanaDakuonW)
set ocidHiraKanaDakuonWKeyArray to recordHiraKanaDakuonWDict's allKeys()

###【5】半角レコード
set recordKana to {|。|:"。", |「|:"「", |」|:"」", |、|:"、", |・|:"・", |ヲ|:"ヲ", |ァ|:"ァ", |ィ|:"ィ", |ゥ|:"ゥ", |ェ|:"ェ", |ォ|:"ォ", |ャ|:"ャ", |ュ|:"ュ", |ョ|:"ョ", |ッ|:"ッ", |ー|:"ー", |ア|:"ア", |イ|:"イ", |ウ|:"ウ", |エ|:"エ", |オ|:"オ", |カ|:"カ", |キ|:"キ", |ク|:"ク", |ケ|:"ケ", |コ|:"コ", |サ|:"サ", |シ|:"シ", |ス|:"ス", |セ|:"セ", |ソ|:"ソ", |タ|:"タ", |チ|:"チ", |ツ|:"ツ", |テ|:"テ", |ト|:"ト", |ナ|:"ナ", |ニ|:"ニ", |ヌ|:"ヌ", |ネ|:"ネ", |ノ|:"ノ", |ハ|:"ハ", |ヒ|:"ヒ", |フ|:"フ", |ヘ|:"ヘ", |ホ|:"ホ", |マ|:"マ", |ミ|:"ミ", |ム|:"ム", |メ|:"メ", |モ|:"モ", |ヤ|:"ヤ", |ユ|:"ユ", |ヨ|:"ヨ", |ラ|:"ラ", |リ|:"リ", |ル|:"ル", |レ|:"レ", |ロ|:"ロ", |ワ|:"ワ", |ン|:"ン"} as record
set ocidKanaDict to refMe's NSDictionary's alloc()'s initWithDictionary:(recordKana)
set ocidKanaKeyArray to ocidKanaDict's allKeys()

|

[UnInstall]パセリrcs300ドライバーアン・インストール

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#                    要管理者権限
#
#
#                       com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.4"
use framework "Foundation"

use scripting additions

property refMe : a reference to current application
set objFileManager to refMe's NSFileManager's defaultManager()


###NSOperatingSystemVersion
set recordOsVersion to (refMe's NSProcessInfo's processInfo)'s operatingSystemVersion()
set numMajorVersion to recordOsVersion's majorVersion() as integer
-->13
####対象のパス
set strFilePath to "/usr/local/libexec/SmartCardServices/drivers/ifd-ccid-rcs300.bundle" as text
####OSが13以上なら
if numMajorVersion ≥ 13 then
    ####パス
    set ocidFilePathStr to refMe's NSString's stringWithString:strFilePath
    set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
    set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
    ####有無チェック
    set boolFileExist to (ocidFilePathURL's checkResourceIsReachableAndReturnError:(missing value))
    if boolFileExist is false then
        log "OS13以上で旧ドライバーがありません未インストール=このケースは無いのが正"
        return "ファイルがありません未インストール=このケースはこれでOK処理終了"
    else
        log "OS13以上で旧ドライバーがあります-->削除処理を実行します"
    end if
    log boolFileExist
    return
    set listResult to (objFileManager's trashItemAtURL:ocidFilePathURL resultingItemURL:(missing value) |error|:(reference))
    
    if (item 1 of listResult) is false then
        set ocidUserTrashPathArray to (objFileManager's URLsForDirectory:(refMe's NSTrashDirectory) inDomains:(refMe's NSUserDomainMask))
        set ocidUserTrashPathURL to ocidUserTrashPathArray's objectAtIndex:0
        set ocidUserTrashPath to ocidUserTrashPathURL's |path|()
        set strUserTrashPath to ocidUserTrashPath as text
        set theComandText to ("/bin/mv \"" & strFilePath & "\" \"" & strUserTrashPath & "\"") as text
        do shell script theComandText with administrator privileges
        log "ゴミ箱に入れましたデバイスの電源OFF->ON再起動してください"
    else
        log "ゴミ箱に入れましたデバイスの電源OFF->ON再起動してください"
        return
    end if
    ####OS13以下の場合は必要なので処理しない
else
    log "macOS13 以下には必須です"
    return
end if

|

[Admin]Osのバージョンを求める


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions
property refMe : a reference to current application



################################
####OSのバージョン
set ocidProcessInfo to refMe's NSProcessInfo's processInfo()
set ocidOsVersion to ocidProcessInfo's operatingSystemVersion()

set numMajorVersion to (item 1 of ocidOsVersion) as integer
set numMinorVersion to (item 2 of ocidOsVersion) as integer
set numPatchVersion to (item 3 of ocidOsVersion) as integer

log numMajorVersion
log numMinorVersion
log numPatchVersion

log ocidProcessInfo's operatingSystemVersionString as text



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

set recordSystemInfo to system info
set strVersion to (system version of recordSystemInfo) as text
log strVersion

tell application "Finder"
  set strVersion to version as text
  log strVersion
end tell


#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
#                       com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.4"
use framework "Foundation"

use scripting additions

property refMe : a reference to current application


###NSOperatingSystemVersion
set recordOsVersion to (refMe's NSProcessInfo's processInfo)'s operatingSystemVersion()
-->(*majorVersion:13, minorVersion:2, patchVersion:0*)

set strMajorVersion to recordOsVersion's majorVersion()
-->13

set strOsVersion to (refMe's NSProcessInfo's processInfo)'s operatingSystemVersionString()
-->(*バージョン13.2(ビルド22D49*)

tell application "Finder"
    set strVersion to version as text
end tell
-->13.2

set strSystemVersion to do shell script "sw_vers -productVersion| cut -b-5" as text
--> "13.2"

set strFilePath to "/System/Library/CoreServices/SystemVersion.plist" as text
set strSystemVersion to do shell script "/usr/bin/defaults read " & strFilePath & " ProductVersion" as text
--> "13.2"

|

[JAVA]JAVA関連のファイルをゴミ箱に入れる

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application
property refNSString : a reference to refMe's NSString
property refNSURL : a reference to refMe's NSURL


set strFilePath to "~/.Trash"
set ocidRelativePath to refNSString's stringWithString:strFilePath
-->(*~/.Trash*)(*__NSCFString*)
set ocidFullPath to ocidRelativePath's stringByStandardizingPath
-->(*/Users/ユーザー名/.Trash*)(*NSPathStore2*)
set ocidTrashURL to refNSURL's alloc()'s initFileURLWithPath:ocidFullPath
set strTrashPath to ocidTrashURL's fileSystemRepresentation() as text


set strCommandText to "/usr/bin/sudo /bin/mv /Library/LaunchAgents/com.oracle.java* \"" & strTrashPath & "\""
log strCommandText as text
try
do shell script strCommandText with administrator privileges
end try

set strCommandText to "/usr/bin/sudo /bin/mv /Library/LaunchDaemons/com.oracle.java* \"" & strTrashPath & "\""
log strCommandText as text
try
do shell script strCommandText with administrator privileges
end try

set strCommandText to "/usr/bin/sudo /bin/mv \"/Library/Internet Plug-Ins/JavaAppletPlugin.plugin\" \"" & strTrashPath & "\""
log strCommandText as text
try
do shell script strCommandText with administrator privileges
end try



set strCommandText to "/usr/bin/sudo /bin/mv \"/Library/PreferencesPanes/JavaControlPanel.prefPane\" \"" & strTrashPath & "\""
log strCommandText as text
try
do shell script strCommandText with administrator privileges
end try


set strCommandText to "/usr/bin/sudo /bin/mv \"/Library/Java/JavaVirtualMachines\" \"" & strTrashPath & "\""
log strCommandText as text
try
do shell script strCommandText with administrator privileges
end try

set strCommandText to "/usr/bin/sudo /bin/mv \"/Library/Application Support/Oracle/Java\" \"" & strTrashPath & "\""
log strCommandText as text
try
do shell script strCommandText with administrator privileges
end try


set strCommandText to "/usr/bin/sudo /bin/mv $HOME/Library/Application\\ Support/Oracle/Java \"" & strTrashPath & "\""
log strCommandText as text
try
do shell script strCommandText with administrator privileges
end try

set strCommandText to "/usr/bin/sudo /bin/mv $HOME/Library/Internet\\ Plug-Ins/JavaAppletPlugin.plugin \"" & strTrashPath & "\""
log strCommandText as text
try
do shell script strCommandText with administrator privileges
end try

set strCommandText to "/usr/bin/sudo /bin/mv $HOME/Library/Preferences/com.oracle.java* \"" & strTrashPath & "\""
log strCommandText as text
try
do shell script strCommandText with administrator privileges
end try


set strCommandText to "/usr/bin/sudo /bin/mv $HOME/Library/LaunchAgents/com.oracle.java* \"" & strTrashPath & "\""
log strCommandText as text
try
do shell script strCommandText with administrator privileges
end try

|

[open location]ゲスト (AUTH=No User Authent)

afp://[user[;AUTH=uamname][:password]@]host[:port]/volumename
mount_afp "afp://;AUTH=No%20User%20Authent@myserver/guestVolume" /Volumes/guest


tell application "Finder"


set strUrl to "ftp://;AUTH=No%20User%20Authent@192.168.0.0" as text

open location strUrl


end tell




afp://ユーザー名:パスワード@192.168.0.0/Public


ftp://;AUTH=No%20User%20Authent@foo.hoge.com/Public

ftp://anonymous:guest@192.168.0.0/Public

ftp://guest:guest@192.168.0.0/Public


smb://;AUTH=No%20User%20Authent@foo.hoge.com/Public

smb://anonymous:guest@192.168.0.0/Public

smb://guest:guest@192.168.0.0/Public


afp://;AUTH=No%20User%20Authent@foo.hoge.com/Public

afp://anonymous:guest@192.168.0.0/Public

afp://guest:guest@192.168.0.0/Public


|

その他のカテゴリー

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