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

タグ: 10.13savvy

display情報の取得

Posted on 2月 20, 2018 by Takaaki Naganoya
AppleScript名:display情報の取得
— Created 2015-01-13 by Takaaki Naganoya
— 2015 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"

–Retina Displayを含む構成のとき(macOS 10.10.x)
set dInfoList to retScreenInfos()
–>  {{screenSize:{{width:1920.0, height:1200.0}}, screenResol:{{width:144.0, height:144.0}}, screenIsScreen:true, screenNumber:"69501832", screenColorSpace:"NSCalibratedRGBColorSpace", screenColDepth:"8"}, {screenSize:{{width:1920.0, height:1200.0}}, screenResol:{{width:144.0, height:144.0}}, screenIsScreen:true, screenNumber:"69513475", screenColorSpace:"NSCalibratedRGBColorSpace", screenColDepth:"8"}, {screenSize:{{width:1920.0, height:1200.0}}, screenResol:{{width:144.0, height:144.0}}, screenIsScreen:true, screenNumber:"69731202", screenColorSpace:"NSCalibratedRGBColorSpace", screenColDepth:"8"}, {screenSize:{{width:1920.0, height:1080.0}}, screenResol:{{width:72.0, height:72.0}}, screenIsScreen:true, screenNumber:"458586661", screenColorSpace:"NSCalibratedRGBColorSpace", screenColDepth:"8"}}

–Retina Displayを含む構成のとき(macOS 10.12.6)
–> {{screenSize:{{width:1920.0, height:1200.0}}, screenResol:{{width:144.0, height:144.0}}, screenIsScreen:true, screenNumber:"69731202", screenColorSpace:"NSCalibratedRGBColorSpace", screenColDepth:"8"}, {screenSize:{{width:1920.0, height:1080.0}}, screenResol:{{width:72.0, height:72.0}}, screenIsScreen:true, screenNumber:"458586661", screenColorSpace:"NSCalibratedRGBColorSpace", screenColDepth:"8"}}

–Retina Displayを含まない構成のとき(MacBook Pro Retina本体のLid Closed Mode時)(macOS 10.10.x)
–set dInfoList to retScreenInfos()
–>  {{screenSize:{{width:1920.0, height:1200.0}}, screenResol:{{width:72.0, height:72.0}}, screenIsScreen:true, screenNumber:"69501832", screenColorSpace:"NSCalibratedRGBColorSpace", screenColDepth:"8"}, {screenSize:{{width:1920.0, height:1200.0}}, screenResol:{{width:72.0, height:72.0}}, screenIsScreen:true, screenNumber:"69513475", screenColorSpace:"NSCalibratedRGBColorSpace", screenColDepth:"8"}, {screenSize:{{width:1920.0, height:1080.0}}, screenResol:{{width:72.0, height:72.0}}, screenIsScreen:true, screenNumber:"458586661", screenColorSpace:"NSCalibratedRGBColorSpace", screenColDepth:"8"}}

–Retina Displayを含まない構成のとき(MacBook Pro Retina本体のLid Closed Mode時)(macOS 10.12.6)
–> {{screenSize:{{width:1920.0, height:1200.0}}, screenResol:{{width:72.0, height:72.0}}, screenIsScreen:true, screenNumber:"69501831", screenColorSpace:"NSCalibratedRGBColorSpace", screenColDepth:"8"}, {screenSize:{{width:1920.0, height:1200.0}}, screenResol:{{width:72.0, height:72.0}}, screenIsScreen:true, screenNumber:"69513476", screenColorSpace:"NSCalibratedRGBColorSpace", screenColDepth:"8"}, {screenSize:{{width:1920.0, height:1080.0}}, screenResol:{{width:72.0, height:72.0}}, screenIsScreen:true, screenNumber:"458586661", screenColorSpace:"NSCalibratedRGBColorSpace", screenColDepth:"8"}}

on retScreenInfos()
  set sList to (current application’s NSScreen’s screens()) as list
  
  
set dList to {}
  
repeat with i in sList
    set a to i’s deviceDescription()
    
set aSize to a’s NSDeviceSize as list
    
set aResol to a’s NSDeviceResolution as list
    
set aScrn to a’s NSDeviceIsScreen as boolean
    
set aNum to a’s NSScreenNumber as string
    
set aColSpc to a’s NSDeviceColorSpaceName as string
    
set aColDepth to a’s NSDeviceBitsPerSample as string
    
set the end of dList to {screenSize:aSize, screenResol:aResol, screenIsScreen:aScrn, screenNumber:aNum, screenColorSpace:aColSpc, screenColDepth:aColDepth}
  end repeat
  
  
return dList
end retScreenInfos

★Click Here to Open This Script 

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

Lock Screen

Posted on 2月 20, 2018 by Takaaki Naganoya

MacをLock Screenの状態にするAppleScriptです。

Lock Screenの状態では、実行中の他のAppleScriptはそのまま動作し続けます。音声出力はオフになります。

ただし、Lock Screen表示はそのまま表示され続けるため、画面表示をオフにしたいだけという用途には合っていません。

AppleScript名:ASOCでLock Screen
— Created 2015-09-11 by Takaaki Naganoya
— 2015 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set aTask to current application’s NSTask’s alloc()’s init()
aTask’s setLaunchPath:"/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/CGSession"
aTask’s setArguments:(current application’s NSArray’s arrayWithObject:"-suspend")
aTask’s |launch|()

★Click Here to Open This Script 

Posted in System | Tagged 10.11savvy 10.12savvy 10.13savvy | 1 Comment

画面情報を取得する

Posted on 2月 20, 2018 by Takaaki Naganoya
AppleScript名:画面情報を取得する
use AppleScript version "2.4" — Yosemite (10.10) or later
use framework "Foundation"
use framework "AppKit"
use scripting additions

set allInfo to {}
set theScreens to current application’s NSScreen’s screens()
repeat with aScreen in theScreens
  set theInfo to aScreen’s deviceDescription() as record
  
set theInfo to theInfo & aScreen’s frame() as record
  
set end of allInfo to theInfo
end repeat
return allInfo
–> {{NSDeviceResolution:{width:144.0, height:144.0}, NSDeviceSize:{width:1920.0, height:1200.0}, NSDeviceIsScreen:"YES", NSScreenNumber:2.077752445E+9, NSDeviceColorSpaceName:"NSCalibratedRGBColorSpace", NSDeviceBitsPerSample:8, origin:{x:0.0, y:0.0}, |size|:{width:1920.0, height:1200.0}}}

–> {{NSDeviceResolution:{width:144.0, height:144.0}, NSDeviceSize:{width:1920.0, height:1200.0}, NSDeviceIsScreen:"YES", NSScreenNumber:69731202, NSDeviceColorSpaceName:"NSCalibratedRGBColorSpace", NSDeviceBitsPerSample:8, origin:{x:0.0, y:0.0}, |size|:{width:1920.0, height:1200.0}}, {NSDeviceResolution:{width:72.0, height:72.0}, NSDeviceSize:{width:1920.0, height:1080.0}, NSDeviceIsScreen:"YES", NSScreenNumber:458586661, NSDeviceColorSpaceName:"NSCalibratedRGBColorSpace", NSDeviceBitsPerSample:8, origin:{x:1920.0, y:216.0}, |size|:{width:1920.0, height:1080.0}}}

★Click Here to Open This Script 

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

使用メモリーの状況を取得

Posted on 2月 20, 2018 by Takaaki Naganoya
AppleScript名:使用メモリーの状況を取得
— Created 2017-12-17 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set mRes to retMemoryUsage() of me
–> {usedMem:7891, wiredMem:2220, unusedMem:293}

on retMemoryUsage()
  set memRes to do shell script "top -l 1 | head -10 | grep ’PhysMem’"
  
set aRes to (parseStrFromTo(memRes, " ", "M") of me)
  
  
set bList to {}
  
repeat with i in aRes
    set mRes to returnNumberOnly(i) of me
    
set the end of bList to mRes
  end repeat
  
  
set usedNum to contents of first item of bList
  
set wiredNum to contents of second item of bList
  
set unusedNum to contents of third item of bList
  
return {usedMem:usedNum as integer, wiredMem:wiredNum as integer, unusedMem:unusedNum as integer}
end retMemoryUsage

on parseStrFromTo(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)
    — terminate check, return the result (aDict) to caller
    
set {theResult, theKey} to theScanner’s scanUpToString:fromStr intoString:(reference)
    
    
— skip over separator
    
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 "" –>追加
    
    
— skip over separator
    
theScanner’s scanString:toStr intoString:(missing value)
    
    
anArray’s addObject:theValue
  end repeat
  
  
return anArray as list
end parseStrFromTo

on returnNumberOnly(aStr)
  set anNSString to current application’s NSString’s stringWithString:aStr
  
set anNSString to anNSString’s stringByReplacingOccurrencesOfString:"[^0-9]" withString:"" options:(current application’s NSRegularExpressionSearch) range:{0, anNSString’s |length|()}
  
return anNSString as text
end returnNumberOnly

★Click Here to Open This Script 

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

電池容量(SPEC)を取得

Posted on 2月 20, 2018 by Takaaki Naganoya
AppleScript名:電池容量(SPEC)を取得
–バッテリー容量(Design Capacity)
do shell script "ioreg -l | grep DesignCapacity | sed ’s/^.*DesignCapacity\" = \\([0-9]*\\)$/\\1/g’"

★Click Here to Open This Script 

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

バッテリ充放電の回数を取得する

Posted on 2月 20, 2018 by Takaaki Naganoya
AppleScript名:バッテリ充放電の回数を取得する
–バッテリ充放電回数
set cycle to (do shell script "ioreg -l | grep ’\"CycleCount\"’ | sed ’s/^.*CycleCount. = \\([0-9]*\\)$/\\1/g’")

★Click Here to Open This Script 

macOS 10.14.6上で数値だけが返ってくるわけではなかったので、泥縄式にこんな風に書き換えて回数の数値だけえられるようにしてみました。

AppleScript名:バッテリの充放電回数を取得する v2
–バッテリ充放電回数
try
  set cycle to (do shell script "ioreg -l | grep ’\"CycleCount\"’ | sed ’s/^.*CycleCount. = \\([0-9]*\\)$/\\1/g’")
  
set cRes to first item of (paragraphs of cycle) as number
  
return cRes
on error
  return false
end try

★Click Here to Open This Script 

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

バッテリの容量を取得する

Posted on 2月 20, 2018 by Takaaki Naganoya
AppleScript名:バッテリの容量を取得する
–バッテリ容量
set cap to (do shell script "ioreg -l | grep MaxCapacity | sed ’s/^.*MaxCapacity\" = \\([0-9]*\\)$/\\1/g’") as {number, anything}

★Click Here to Open This Script 

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

ACで動いているかDCで動いているかを取得する

Posted on 2月 20, 2018 by Takaaki Naganoya
AppleScript名:ACで動いているかDCで動いているかを取得する
set curPowerStat to retACDC() of me

–ACで動作中かDCで動作中かを返す
on retACDC()
  return word -2 of paragraph 1 of (do shell script "pmset -g cap")
end retACDC

★Click Here to Open This Script 

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

ドライブマウント検出

Posted on 2月 20, 2018 by Takaaki Naganoya

ドライブのマウントを検出してsayコマンドで通知するAppleScriptです。

AppleScript名:ドライブマウント検出
— Created 2016-10-27 by Takaaki Naganoya
— 2016 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"

on run
  current application’s NSWorkspace’s sharedWorkspace()’s notificationCenter()’s addObserver:me selector:"onVolumeMount:" |name|:"NSWorkspaceDidMountNotification" object:(missing value)
  
  
current application’s NSWorkspace’s sharedWorkspace()’s notificationCenter()’s addObserver:me selector:"onVolumeUnmount:" |name|:"NSWorkspaceDidUnmountNotification" object:(missing value)
end run

on onVolumeMount:aNotif
  say "マウントしました" using "Kyoko" –Mount Message In Japanese
end onVolumeMount:

on onVolumeUnmount:aNotif
  say "アンマウントしました" using "Kyoko" –Unmount Message In Japanese
end onVolumeUnmount:

★Click Here to Open This Script 

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

TouchBarの検出

Posted on 2月 20, 2018 by Takaaki Naganoya
AppleScript名:TouchBarの検出
set aRes to detectTouchBar() of me
–> true/false

on detectTouchBar()
  tell application "System Events"
    set frontApp to first application process whose frontmost is true
    
try
      set touchBar to first UI element of frontApp whose role is "AXFunctionRowTopLevelElement"
    on error errMsg number errNum
      return false
    end try
    
    
set touchBarItems to value of attribute "AXChildren" of touchBar
    
return (touchBarItems is not equal to {})
  end tell
end detectTouchBar

★Click Here to Open This Script 

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

USBに接続されたUSBメモリの情報を取得する v2

Posted on 2月 20, 2018 by Takaaki Naganoya
AppleScript名:USBに接続されたUSBメモリの情報を取得する v2

set tmpPath to POSIX path of (path to temporary items from system domain)
set aFileName to (do shell script "/usr/bin/uuidgen")
set outPath to tmpPath & aFileName & ".plist"
do shell script "/usr/sbin/system_profiler -xml SPUSBDataType > " & outPath

tell application "System Events"
  set vRec to value of property list file (outPath as string)
  
set v1Rec to _items of (first item of vRec)
  
  
set dList to {}
  
set sList to {}
  
repeat with i in v1Rec
    set hitF to false
    
try
      set j to _items of i
      
set hitF to true
    end try
    
    
if hitF = true then
      repeat with jj in j
        try
          set jjj to volumes of jj
          
set sNum to d_serial_num of jj
          
set vStr to b_vendor_id of jj
          
          
repeat with ii in jjj
            set the end of dList to {serialNum:sNum, venderName:vStr, dData:contents of ii}
          end repeat
          
        end try
      end repeat
    end if
  end repeat
end tell

dList

–> {{serialNum:"7f12db856195ef", venderName:"0x056e (Elecom Co., Ltd.)", dData:{mount_point:"/Volumes/NO NAME", _name:"NO NAME", writable:"yes", bsd_name:"disk2s1", free_space:"3.75 GB", file_system:"MS-DOS FAT32", |size|:"3.77 GB"}}, {serialNum:"M004101800001", venderName:"0x4146", dData:{mount_point:"/Volumes/ぴよまる", _name:"ぴよまる", writable:"yes", bsd_name:"disk1s9", free_space:"56 MB", file_system:"HFS+", |size|:"123.1 MB"}}}

★Click Here to Open This Script 

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

使用中のMacの製品呼称を取得する v3

Posted on 2月 20, 2018 by Takaaki Naganoya
AppleScript名:使用中のMacの製品呼称を取得する v3
use AppleScript version "2.5"
use scripting additions
use framework "Foundation"

set mRes to retModelInfo() of me
–>  "MacBook Pro with Retina display, Intel Core i7, 15\" (Mid 2012)"

on retModelInfo()
  set pListPath to "/System/Library/PrivateFrameworks/ServerInformation.framework/" & "Versions/A/Resources/English.lproj/SIMachineAttributes.plist"
  
set aRec to retDictFromPlist(pListPath) of me
  
  
set hwName to (do shell script "sysctl -n hw.model")
  
–>  "MacBookPro10,1"
  
  
set aMachineRec to retRecordByLabel(aRec, hwName)
  
  
set aMachineRec2 to contents of first item of aMachineRec
  
return (marketingModel of _LOCALIZABLE_ of aMachineRec2)
end retModelInfo

–Read plist as record
on retDictFromPlist(aPath)
  set thePath to current application’s NSString’s stringWithString:aPath
  
set thePath to thePath’s stringByExpandingTildeInPath()
  
set theDict to current application’s NSDictionary’s dictionaryWithContentsOfFile:thePath
  
return theDict as record
end retDictFromPlist

–リストに入れたレコードを、指定の属性ラベルの値で抽出
on filterRecListByLabel(aRecList as list, aPredicate as string)
  –ListからNSArrayへの型変換
  
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
  
  
–NSArrayからListに型変換して返す
  
return filteredArray as list
end filterRecListByLabel

–指定レコードの指定ラベルの値を取得する
on retRecordByLabel(aRec as record, aKey as string)
  set aDic to current application’s NSDictionary’s dictionaryWithDictionary:aRec
  
set aVal to aDic’s valueForKey:aKey
  
return aVal as list
end retRecordByLabel

–指定レコードの指定ラベルの値を取得する
on retRecordByKeyPath(aRec as record, aKey as string)
  set aDic to current application’s NSDictionary’s dictionaryWithDictionary:aRec
  
set aVal to aDic’s valueForKeyPath:aKey
  
return aVal
end retRecordByKeyPath

★Click Here to Open This Script 

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

CPUのBrand Nameとバス速度を表示

Posted on 2月 20, 2018 by Takaaki Naganoya
AppleScript名:CPUのBrand Nameとバス速度を表示
set aTargLabel to "machdep.cpu.brand_string:"
set aRes to retFilteredSysctrlValue(aTargLabel) of me
–> "Intel(R) Core(TM) i7-3720QM CPU @ 2.60GHz"

set bRes to retFilteredSysctrlValue("hw.busfrequency_max") of me
–> " 100000000"

return {aRes, bRes}
–> {"Intel(R) Core(TM) i7-3720QM CPU @ 2.60GHz", " 100000000"}

on retFilteredSysctrlValue(aTargLabel)
  set aRes to do shell script "sysctl -a | grep " & aTargLabel
  
set aLen to length of aTargLabel
  
set bRes to text (aLen + 2) thru -1 of aRes
  
return bRes
end retFilteredSysctrlValue

★Click Here to Open This Script 

Posted in System | Tagged 10.11savvy 10.12savvy 10.13savvy | 1 Comment

使用CPUの状況を取得

Posted on 2月 20, 2018 by Takaaki Naganoya
AppleScript名:使用CPUの状況を取得
— Created 2017-12-17 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set aDict to retCpuUsage() of me
–> {userCPU:3.2, sysCPU:12.29, idleCPU:84.49}

on retCpuUsage()
  set cpuUseRes to do shell script "top -l 1 | head -10 | grep ’CPU usage’"
  
set aRes to (parseStrFromTo(cpuUseRes, " ", "%") of me)
  
set userUsage to (last item of (words of item 1 of aRes)) as real
  
set sysUsage to (item 2 of aRes) as real
  
set idleUsage to (item -2 of aRes) as real
  
return {userCPU:userUsage, sysCPU:sysUsage, idleCPU:idleUsage}
end retCpuUsage

on parseStrFromTo(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)
    — terminate check, return the result (aDict) to caller
    
set {theResult, theKey} to theScanner’s scanUpToString:fromStr intoString:(reference)
    
    
— skip over separator
    
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 "" –>追加
    
    
— skip over separator
    
theScanner’s scanString:toStr intoString:(missing value)
    
    
anArray’s addObject:theValue
  end repeat
  
  
return anArray as list
end parseStrFromTo

★Click Here to Open This Script 

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

指定ファイルのFinder Tagを取得

Posted on 2月 19, 2018 by Takaaki Naganoya

AppleScript名:指定ファイルのFinder Tagを取得
— Created 2014-12-21 by Takaaki Naganoya
— 2014 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set a to choose file
set aResList to getFinderTagList(a) of me
–> {"ブルー", "レッド"}

on getFinderTagList(anAlias)
  –aliasをNSURLに変換  
  
set aPOSIX to POSIX path of anAlias
  
set aURL to current application’s |NSURL|’s fileURLWithPath:aPOSIX
  
  
–指定URLから指定の属性(NSURLTagNamesKey)を取得
  
try
    set aTargAttr to {current application’s NSURLTagNamesKey}
    
set {attsNSDictionary, theError} to aURL’s resourceValuesForKeys:aTargAttr |error|:(reference)
    
if attsNSDictionary is missing value then
      error (theError’s localizedDescription() as text)
    end if
    
    
–NSURLTagNamesKeyのリストを返す
    
set aList to NSURLTagNamesKey of (attsNSDictionary as list of string or string)
    
return aList as list
    
  on error
    return {}
  end try
end getFinderTagList

★Click Here to Open This Script 

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

FBEncryptorで文字列の暗号化、復号化

Posted on 2月 19, 2018 by Takaaki Naganoya

–> FBEncryptorKit.framework

AppleScript名:FBEncryptorで文字列の暗号化、復号化
— Created 2016-02-16 by Takaaki Naganoya
— 2016 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "FBEncryptorKit" –https://github.com/dev5tec/FBEncryptor

set aStr to "ABCDEFあいうえお
かきくけこGHIJKLMN"

set aKey to "piyomaru"

–Encryption
set aEnc to (current application’s FBEncryptorAES’s encryptBase64String:aStr keyString:aKey separateLines:true) as string
–>  "N0/E5FB97DY+qOFtfKK9CCsAMKznyej94Ons1lC90V/9vMJIaBw5R+mbaxaTm711"

–Decription
set aDec to (current application’s FBEncryptorAES’s decryptBase64String:aEnc keyString:aKey) as string
(*
"ABCDEFあいうえお
かきくけこGHIJKLMN"
*)

★Click Here to Open This Script 

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

ファイルのMD5、SHA1、SHA512のハッシュ値を求める

Posted on 2月 19, 2018 by Takaaki Naganoya

–> md5Lib.framework

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"

★Click Here to Open This Script 

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

NSStringからSHA-3のハッシュ値を求める

Posted on 2月 19, 2018 by Takaaki Naganoya

–> SHA3Kit.framework

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 

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

NSDataからMD5値を計算する

Posted on 2月 19, 2018 by Takaaki Naganoya

–> md5FromDataKit.framework

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 Text | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

ZipZap frameworkを使ってZipアーカイブ内の情報を取得

Posted on 2月 19, 2018 by Takaaki Naganoya

–> ZipZap.framework

AppleScript名:ZipZap frameworkを使ってZipアーカイブ内の情報を取得
— Created 2015-10-11 by Takaaki Naganoya
— 2015 Piyomaru Software
use AppleScript version "2.5"
use scripting additions
use framework "Foundation"
use framework "ZipZap" –https://github.com/pixelglow/zipzap

set aPath to POSIX path of (choose file of type {"public.zip-archive"})
set oldArchive to current application’s ZZArchive’s archiveWithURL:(current application’s |NSURL|’s fileURLWithPath:aPath) |error|:(missing value)
–>  (ZZArchive) <ZZArchive: 0x7fe59aa932d0>

set entryCount to oldArchive’s entries()’s |count|()
–>  180 –this zip archive includes 180 file or folders inside

set firstArchEntry to oldArchive’s entries()’s firstObject()
–>  (ZZOldArchiveEntry) <ZZOldArchiveEntry: 0x7fe593fa4dc0>

set aList to oldArchive’s entries() as list

repeat with i in aList
  set uSize to i’s uncompressedSize() as real
  
set cSize to i’s compressedSize() as real
  
set comF to i’s compressed() as boolean
  
set encF to i’s encrypted() as boolean
  
set modD to i’s lastModified() as date
  
set chkSum to i’s crc32() as text –The CRC32 code of the entry file: 0 for new entries.
  
set aFileMode to i’s fileMode() as text — The UNIX file mode for the entry: 0 for new or non-UNIX entries. This includes the file type bits.
  
set aFileName to i’s fileName() as text
  
  
log {aFileName, aFileMode, chkSum, modD, encF, comF, cSize, uSize}
  
–> 21:28:01.817 (* {"ZXingObjC.framework/", "16877d", "0", date "2015年10月10日土曜日 10:07:16", false, false, 0.0, 0.0} *)
  
–> 21:28:01.818 (* {"ZXingObjC.framework/Headers", "41453d", "2.393740531E+9", date "2015年10月10日土曜日 10:07:10", false, false, 24.0, 24.0} *)
  
–> 21:28:01.820 (* {"ZXingObjC.framework/Versions/", "16877d", "0", date "2015年10月10日土曜日 10:07:10", false, false, 0.0, 0.0} *)
  
–> 21:28:01.821 (* {"ZXingObjC.framework/Versions/3.1.0/", "16877d", "0", date "2015年10月10日土曜日 10:07:16", false, false, 0.0, 0.0} *)
  
–> 21:28:01.822 (* {"ZXingObjC.framework/Versions/3.1.0/Headers/", "16877d", "0", date "2015年10月10日土曜日 10:07:16", false, false, 0.0, 0.0} *)
  
  
–set aData to (i’s newDataWithError:false)–Uncompressed raw data
  
–log aData
end repeat

★Click Here to Open This Script 

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

Post navigation

  • Older posts
  • Newer posts

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

Google Search

Popular posts

  • 開発機としてM2 Mac miniが来たのでガチレビュー
  • Numbersで選択範囲のセルの前後の空白を削除
  • メキシカンハットの描画
  • Pixelmator Pro v3.6.4でAppleScriptからの操作時の挙動に違和感が
  • macOS 15でも変化したText to Speech環境
  • AppleScriptによる並列処理
  • Safariで「プロファイル」機能を使うとAppleScriptの処理に影響
  • AppleScript入門③AppleScriptを使った「自動化」とは?
  • デフォルトインストールされたフォント名を取得するAppleScript
  • 【続報】macOS 15.5で特定ファイル名パターンのfileをaliasにcastすると100%クラッシュするバグ
  • macOS 15 リモートApple Eventsにバグ?
  • Script Debuggerの開発と販売が2025年に終了
  • AppleScript入門① AppleScriptってなんだろう?
  • macOS 14で変更になったOSバージョン取得APIの返り値
  • 2024年に書いた価値あるAppleScript
  • NSObjectのクラス名を取得 v2.1
  • macOS 15:スクリプトエディタのAppleScript用語辞書を確認できない
  • Pixelmator Proがv3.6.8でHDR画像をサポート
  • 有害ではなくなっていたSpaces
  • KagiのWebブラウザ、Orion

Tags

10.11savvy (1101) 10.12savvy (1242) 10.13savvy (1391) 10.14savvy (587) 10.15savvy (438) 11.0savvy (283) 12.0savvy (212) 13.0savvy (199) 14.0savvy (153) 15.0savvy (142) CotEditor (66) Finder (52) Keynote (119) 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) Pixelmator Pro (20) 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
  • process
  • 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年7月
  • 2025年6月
  • 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