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

投稿者: Takaaki Naganoya

与えられた画像ファイルがNSImageでハンドリング可能かを取得 v2

Posted on 2月 11, 2018 by Takaaki Naganoya
AppleScript名:与えられた画像ファイルがNSImageでハンドリング可能かを取得 v2
— Created 2015-08-18 by Shane Stanley
— Modified 2018-02-10 by Takaaki Naganoya
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set oldPath to POSIX path of (choose file)
set aRes to chkHandlingByNSImage(oldPath, "JPEG")
–> {nsImageAcceptable:true, requireConvert:true}

on chkHandlingByNSImage(aPath, targetFormatExt)
  set aRes to chkNSImageAcceptableFormat(aPath, targetFormatExt)
  
set bRes to chkIsThereNeedToConvert(aPath, targetFormatExt)
  
return {nsImageAcceptable:aRes, requireConvert:bRes}
end chkHandlingByNSImage

–与えられた画像ファイルがNSImageでハンドリング可能かを取得
on chkNSImageAcceptableFormat(aPath as text, targetFormatExt as text)
  
  
— check if UTI of file is one NSImage can read
  
set theWorkspace to current application’s NSWorkspace’s sharedWorkspace()
  
set theType to theWorkspace’s typeOfFile:aPath |error|:(missing value) — returns UTI of file
  
–>  (NSString) "public.jpeg"
  
  
set supportedTypes to current application’s NSImage’s imageTypes() — returns supported UTIs
  
–>  (NSArray) {​​​​​"com.adobe.pdf", ​​​​​"com.apple.pict", ​​​​​"com.adobe.encapsulated-postscript", ​​​​​"public.jpeg", ​​​​​"public.png", ​​​​​"com.compuserve.gif", ​​​​​"public.jpeg-2000", ​​​​​"com.canon.tif-raw-image", ​​​​​"com.adobe.raw-image", ​​​​​"com.dxo.raw-image", ​​​​​"com.canon.cr2-raw-image", ​​​​​"com.leafamerica.raw-image", ​​​​​"com.hasselblad.fff-raw-image", ​​​​​"com.hasselblad.3fr-raw-image", ​​​​​"com.nikon.raw-image", ​​​​​"com.nikon.nrw-raw-image", ​​​​​"com.pentax.raw-image", ​​​​​"com.samsung.raw-image", ​​​​​"com.sony.raw-image", ​​​​​"com.sony.sr2-raw-image", ​​​​​"com.sony.arw-raw-image", ​​​​​"com.epson.raw-image", ​​​​​"com.kodak.raw-image", ​​​​​"public.tiff", ​​​​​"com.apple.icns", ​​​​​"com.canon.crw-raw-image", ​​​​​"com.fuji.raw-image", ​​​​​"com.panasonic.raw-image", ​​​​​"com.panasonic.rw2-raw-image", ​​​​​"com.leica.raw-image", ​​​​​"com.leica.rwl-raw-image", ​​​​​"com.konicaminolta.raw-image", ​​​​​"com.olympus.sr-raw-image", ​​​​​"com.olympus.or-raw-image", ​​​​​"com.olympus.raw-image", ​​​​​"com.adobe.photoshop-image", ​​​​​"com.microsoft.ico", ​​​​​"com.microsoft.bmp", ​​​​​"com.microsoft.cur", ​​​​​"com.truevision.tga-image", ​​​​​"com.sgi.sgi-image", ​​​​​"com.apple.macpaint-image", ​​​​​"com.ilm.openexr-image", ​​​​​"public.radiance", ​​​​​"public.mpo-image", ​​​​​"public.pbm", ​​​​​"public.pvr", ​​​​​"com.apple.rjpeg", ​​​​​"com.apple.quicktime-image", ​​​​​"com.kodak.flashpix-image"​​​}
  
  
if (supportedTypes’s containsObject:theType) as boolean is false then
    return "File format is unsupported"
    
— check required type doesn’t already match
  else
    return true
  end if
  
end chkNSImageAcceptableFormat

–変換元の画像パスと変換対象の拡張子を与え、変換不要(同一ファイル"JPG"–> "JPEG"など)かをチェックする
on chkIsThereNeedToConvert(aPath as text, targetFormatExt as text)
  set theWorkspace to current application’s NSWorkspace’s sharedWorkspace()
  
set theType to theWorkspace’s typeOfFile:aPath |error|:(missing value) — returns UTI of file
  
if (theWorkspace’s filenameExtension:targetFormatExt isValidForType:theType) as boolean then
    return false –"No conversion needed"
  else
    return true
  end if
end chkIsThereNeedToConvert

★Click Here to Open This Script 

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

表示中のYouTubeのムービーをローカルにダウンロードして音声のみ抽出

Posted on 2月 11, 2018 by Takaaki Naganoya

Safariで表示中のYouTubeのムービーをローカルのMoviesフォルダにダウンロードして音声部分のみ抽出するAppleScriptです。

YouTubeからのダウンロードを行う「YouTubeDLLib」およびShane StanleyのAppleScript Libraries「BridgePlus」を~/Libraries/AppleScript Librariesフォルダに、XAttribute.frameworkを~/Libraries/Frameworksフォルダにインストールして実行してください。

–> YouTubeDLLib

YouTubeDLLib内部には「youtube-dl」を含んでおり、これ単体でアップデートが必要な場合もあります。急に動かなくなったような場合には、新バージョンが出ていないかチェックしてみてください。

Script Menuから実行することを前提としています。

AppleScript名:表示中のYouTubeのムービーをローカルにダウンロードして音声のみ抽出
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AVFoundation"
use framework "XAttribute" –https://github.com/rylio/OTMXAttribute
use BridgePlus : script "BridgePlus" –https://www.macosxautomation.com/applescript/apps/BridgePlus.html
use youtubeLib : script "YouTubeDLLib"

set dlFolder to POSIX path of (path to movies folder) –ダウンロード先のフォルダ

set aURL to getPageURLOfFrontmostWindow() of me
set aList to aURL

load framework

–指定URLのYouTubeのムービーをダウンロードする
set aRes to downLoadMovieToFile(aURL, dlFolder) of youtubeLib

–オーディオ部分のみ抽出
set dlFullPath to dlFolder & aRes

–ダウンロードしたMovieからXattrを削除する
set xRes to removeXAttrFromFile(dlFullPath, "com.apple.quarantine")

my convertMovieAt:dlFullPath ToType:"AVAssetExportPresetAppleM4A" withExtension:"m4a" deleteOriginal:true

on getPageURLOfFrontmostWindow()
  tell application "Safari"
    if (count every window) = 0 then return false
    
tell window 1
      set aProp to properties
    end tell
    
set aDoc to document of aProp
    
set aText to URL of aDoc
  end tell
  
return aText
end getPageURLOfFrontmostWindow

on getPageTitleOfFrontmostWindow()
  tell application "Safari"
    if (count every window) = 0 then return false
    
tell window 1
      set aProp to properties
    end tell
    
set aDoc to document of aProp
    
set aText to name of aDoc
  end tell
  
return aText
end getPageTitleOfFrontmostWindow

–指定のムービーを、指定の書き出しプリセットで、指定のファイル形式で、オリジナルファイルを削除するかどうか指定しつつ書き出し
on convertMovieAt:(posixPath as string) ToType:(assetTypeStr as string) withExtension:(aExt as string) deleteOriginal:(deleteFlag as boolean)
  set theURL to current application’s |NSURL|’s fileURLWithPath:posixPath
  
  
set aPreset to current application’s NSString’s stringWithString:assetTypeStr
  
  
— set destination to use same path, different extension
  
set destURL to theURL’s URLByDeletingPathExtension()’s URLByAppendingPathExtension:aExt
  
set theAsset to current application’s AVAsset’s assetWithURL:theURL
  
  
— check asset can be converted
  
set allowedPresets to current application’s AVAssetExportSession’s exportPresetsCompatibleWithAsset:theAsset
  
if (allowedPresets’s containsObject:aPreset) as boolean is false then
    error "Can’t export this file as an ." & aExt & " file."
  end if
  
  
— set up export session
  
set fileTypeUTIstr to retFileFormatUTI(aExt) of me –ファイル拡張子からFile Type UTIを求める
  
set theSession to current application’s AVAssetExportSession’s exportSessionWithAsset:theAsset presetName:aPreset
  
theSession’s setOutputFileType:fileTypeUTIstr
  
theSession’s setOutputURL:destURL
  
  
— begin export and poll for completion
  
theSession’s exportAsynchronouslyWithCompletionHandler:(missing value)
  
repeat
    set theStatus to theSession’s status() as integer
    
if theStatus < 3 then
      delay 0.2
    else
      exit repeat
    end if
  end repeat
  
  
— throw error if it failed
  
if theStatus = (current application’s AVAssetExportSessionStatusFailed) as integer then
    error (theSession’s |error|()’s localizedDescription() as text)
  end if
  
  
— delete original if required
  
if deleteFlag then
    current application’s NSFileManager’s defaultManager()’s removeItemAtURL:theURL |error|:(missing value)
  end if
end convertMovieAt:ToType:withExtension:deleteOriginal:

on retFileFormatUTI(aExt as string)
  return (current application’s SMSForder’s UTIForExtension:aExt)
end retFileFormatUTI

on removeXAttrFromFile(aFile, anXattr)
  –Get Xattr String
  
set anAttribute to (current application’s OTMXAttribute’s stringAttributeAtPath:aFile |name|:anXattr |error|:(missing value))
  
if anAttribute = missing value then return true –There is no use to remove xattr
  
  
–Remove Xattr
  
set xRes to (current application’s OTMXAttribute’s removeAttributeAtPath:aFile |name|:anXattr |error|:(missing value))
  
if xRes = missing value then return false
  
return (xRes as boolean)
end removeXAttrFromFile

★Click Here to Open This Script 

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

表示中のYouTubeのムービーをローカルにダウンロード v2

Posted on 2月 11, 2018 by Takaaki Naganoya

Safariで表示中のYouTubeのムービーをローカルのMoviesフォルダにダウンロードするAppleScriptです。

YouTubeからのダウンロードを行う「YouTubeDLLib」を~/Library/Script Librariesフォルダ(初期状態では存在しないので、ない場合には手動で作成)にインストールして実行してください。

–> Download YouTubeDLLib (To ~/Library/Script Libraries)

YouTubeDLLib内部には「youtube-dl」を含んでおり、これ単体でアップデートが必要な場合もあります(半年に1回ぐらいアップデートしています)。

Script Menuから実行することを前提としています。

AppleScript名:表示中のYouTubeのムービーをローカルにダウンロード v2
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use youtubeLib : script "YouTubeDLLib"

set dlFolder to POSIX path of (path to movies folder) –ダウンロード先のフォルダ

set aURL to getPageURLOfFrontmostWindow() of me
set aList to {aURL}

set erList to {}
–set aList to paragraphs of a
repeat with i in aList
  set j to contents of i
  
  
–指定URLのYouTubeのムービーをダウンロードする
  
dlMovieSub(aURL, dlFolder) of youtubeLib
end repeat

return erList –ダウンロード結果

on getPageURLOfFrontmostWindow()
  tell application "Safari"
    if (count every window) = 0 then return false
    
tell window 1
      set aProp to properties
    end tell
    
set aDoc to document of aProp
    
set aText to URL of aDoc
  end tell
  
return aText
end getPageURLOfFrontmostWindow

★Click Here to Open This Script 

Posted in file Network | Tagged 10.11savvy 10.12savvy 10.13savvy Safari | 1 Comment

郵便専門ネットでXML-RPC経由で郵便番号を6桁(チェックデジット付き)の全国地方公共団体コード/JISコード/市町村コードに変換

Posted on 2月 11, 2018 by Takaaki Naganoya
AppleScript名:郵便専門ネットでXML-RPC経由で郵便番号を6桁(チェックデジット付き)の全国地方公共団体コード/JISコード/市町村コードに変換
tell application "http://yubin.senmon.net/service/xmlrpc/"
  call xmlrpc {method name:"yubin.postcodeToJiscode6", parameters:{"1760024"}}
end tell

–> "131202"

★Click Here to Open This Script 

Posted in Network XML-RPC | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

郵便専門ネットでXML-RPC経由で引数に都道府県のJISコード(JISコードの先頭2文字)を渡すと、その都道府県に属しているJISコードを取得

Posted on 2月 11, 2018 by Takaaki Naganoya
AppleScript名:郵便専門ネットでXML-RPC経由で引数に都道府県のJISコード(JISコードの先頭2文字)を渡すと、その都道府県に属しているJISコードを取得
tell application "http://yubin.senmon.net/service/xmlrpc/"
  call xmlrpc {method name:"yubin.jiscodeFromPrefcode", parameters:{"13"}}
end tell

–> {"13101", "13102", "13103", "13104", "13105", "13106", "13107", "13108", "13109", "13110", "13111", "13112", "13113", "13114", "13115", "13116", "13117", "13118", "13119", "13120", "13121", "13122", "13123", "13201", "13202", "13203", "13204", "13205", "13206", "13207", "13208", "13209", "13210", "13211", "13212", "13213", "13214", "13215", "13218", "13219", "13220", "13221", "13222", "13223", "13224", "13225", "13227", "13228", "13229", "13303", "13305", "13307", "13308", "13361", "13362", "13363", "13364", "13381", "13382", "13401", "13402", "13421"}

★Click Here to Open This Script 

Posted in Network XML-RPC | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

郵便専門ネットで一度に取得できるデータ件数を返す

Posted on 2月 11, 2018 by Takaaki Naganoya
AppleScript名:郵便専門ネットで一度に取得できるデータ件数を返す
tell application "http://yubin.senmon.net/service/xmlrpc/"
  call xmlrpc {method name:"yubin.getMaxFetchCount", parameters:{}}
end tell
–> 100

★Click Here to Open This Script 

Posted in Network XML-RPC | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

郵便専門ネットで郵便番号を5桁の全国地方公共団体コード/JISコード/市町村コードに変換

Posted on 2月 11, 2018 by Takaaki Naganoya
AppleScript名:郵便専門ネットで郵便番号を5桁の全国地方公共団体コード/JISコード/市町村コードに変換
tell application "http://yubin.senmon.net/service/xmlrpc/"
  call xmlrpc {method name:"yubin.postcodeExists", parameters:{"1760024"}}
end tell
–> true

★Click Here to Open This Script 

Posted in Network XML-RPC | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

郵便専門ネットで郵便番号の存在チェック

Posted on 2月 11, 2018 by Takaaki Naganoya
AppleScript名:郵便専門ネットで郵便番号の存在チェック
tell application "http://yubin.senmon.net/service/xmlrpc/"
  call xmlrpc {method name:"yubin.postcodeExists", parameters:{"1760024"}}
end tell
–> true

★Click Here to Open This Script 

Posted in Network XML-RPC | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

郵便専門ネットで道府県のコード(地方公共団体コードの先頭2文字)から都道府県名を返す

Posted on 2月 11, 2018 by Takaaki Naganoya
AppleScript名:郵便専門ネットで道府県のコード(地方公共団体コードの先頭2文字)から都道府県名を返す
tell application "http://yubin.senmon.net/service/xmlrpc/"
  call xmlrpc {method name:"yubin.getPrefName", parameters:{"13"}}
end tell
–> "東京都"

★Click Here to Open This Script 

Posted in Network XML-RPC | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

郵便専門ネットで引数に指定した郵便番号で何件ヒットするのかをint型で返す

Posted on 2月 11, 2018 by Takaaki Naganoya
AppleScript名:郵便専門ネットで引数に指定した郵便番号で何件ヒットするのかをint型で返す
tell application "http://yubin.senmon.net/service/xmlrpc/"
  call xmlrpc {method name:"yubin.getFetchCountByPostcode", parameters:{"1980036"}}
end tell
–> 1

★Click Here to Open This Script 

Posted in Network XML-RPC | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

郵便専門ネットでXML-RPC経由で郵便番号から住所を返す

Posted on 2月 11, 2018 by Takaaki Naganoya
AppleScript名:郵便専門ネットでXML-RPC経由で郵便番号から住所を返す
tell application "http://yubin.senmon.net/service/xmlrpc/"
  call xmlrpc {method name:"yubin.fetchAddressByPostcode", parameters:{"1760022"}}
end tell

–> {{other:application "http://yubin.senmon.net/service/xmlrpc/", addr_name:application "http://yubin.senmon.net/service/xmlrpc/", yid:176002201, postcode:"1760022", data_type:"p", addr_name_kana:application "http://yubin.senmon.net/service/xmlrpc/", city_kana:"ねりまく", jiscode:"13120", town:"向山", town_kana:"こうやま", city:"練馬区", pref:"東京都", pref_kana:"とうきょうと"}}

★Click Here to Open This Script 

Posted in Network XML-RPC | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

郵便専門ネットでXML-RPC経由で郵便番号に対応する世界測地系(WGS84)の緯度経度コード(Geocode)を返す

Posted on 2月 11, 2018 by Takaaki Naganoya
AppleScript名:郵便専門ネットでXML-RPC経由で郵便番号に対応する世界測地系(WGS84)の緯度経度コード(Geocode)を返す
tell application "http://yubin.senmon.net/service/xmlrpc/"
  call xmlrpc {method name:"yubin.postcodeToGeocode", parameters:{"1760024"}}
end tell
–> {35.0345563, 135.7476776}

★Click Here to Open This Script 

Posted in Network XML-RPC | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

郵便専門ネットでXML-RPC経由でJISコード(5桁、6桁どちらでも)から、その市区町村に属している郵便番号のリストを取得

Posted on 2月 11, 2018 by Takaaki Naganoya
AppleScript名:郵便専門ネットでXML-RPC経由でJISコード(5桁、6桁どちらでも)から、その市区町村に属している郵便番号のリストを取得
tell application "http://yubin.senmon.net/service/xmlrpc/"
  call xmlrpc {method name:"yubin.postcodeFromJiscode", parameters:{"011037"}}
end tell

–> {"0070001", "0070002", "0070003", "0070004", "0070005", "0070006", "0070011", "0070030", "0070031", "0070032", "0070033", "0070034", "0070801", "0070802", "0070803", "0070804", "0070805", "0070806", "0070807", "0070808", "0070809", "0070810", "0070811", "0070812", "0070813", "0070814", "0070815", "0070819", "0070820", "0070821", "0070822", "0070823", "0070824", "0070825", "0070826", "0070827", "0070828", "0070829", "0070834", "0070835", "0070836", "0070837", "0070838", "0070839", "0070840", "0070841", "0070842", "0070843", "0070844", "0070845", "0070846", "0070847", "0070848", "0070849", "0070850", "0070851", "0070852", "0070861", "0070862", "0070863", "0070864", "0070865", "0070866", "0070867", "0070868", "0070869", "0070870", "0070871", "0070872", "0070873", "0070874", "0070880", "0070881", "0070882", "0070883", "0070884", "0070885", "0070886", "0070890", "0070891", "0070892", "0070893", "0070894", "0070895", "0078501", "0078503", "0078505", "0078507", "0078508", "0078553", "0078585", "0078632", "0600905", "0600906", "0600907", "0600908", "0600909", "0608569", "0608576", "0608582", "0650000", "0650004", "0650005", "0650006", "0650007", "0650008", "0650009", "0650010", "0650011", "0650012", "0650013", "0650014", "0650015", "0650016", "0650017", "0650018", "0650019", "0650020", "0650021", "0650022", "0650023", "0650024", "0650025", "0650026", "0650027", "0650028", "0650030", "0650031", "0650032", "0650033", "0650041", "0650042", "0650043", "0658501", "0658508", "0658510", "0658511", "0658518", "0658522", "0658533", "0658543", "0658550", "0658555", "0658558", "0658567", "0658578", "0658601", "0658609", "0658610", "0658611", "0658612", "0658633", "0658639"}

★Click Here to Open This Script 

Posted in Network XML-RPC | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

郵便専門ネットでバージョン番号を取得

Posted on 2月 11, 2018 by Takaaki Naganoya
AppleScript名:郵便専門ネットでバージョン番号を取得
–http://yubin.senmon.net/service/xmlrpc/
tell application "http://yubin.senmon.net/service/xmlrpc/"
  call xmlrpc {method name:"yubin.getVersion", parameters:{}}
end tell
–>"18.01a"

★Click Here to Open This Script 

Posted in Network XML-RPC | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

ドメイン名からIPアドレスを取得

Posted on 2月 11, 2018 by Takaaki Naganoya
AppleScript名:ドメイン名からIPアドレスを取得
— Created 2016-04-03 by Takaaki Naganoya
— 2016 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set anIP to ((current application’s NSHost’s hostWithName:"www.google.com")’s address()) as string
–>  "216.58.200.196"

★Click Here to Open This Script 

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

インターネット接続確認

Posted on 2月 11, 2018 by Takaaki Naganoya
AppleScript名:インターネット接続確認
— Created 2015-12-16 by Takaaki Naganoya
— 2015 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set aRes to hasInternetConnection() of me
–>  true

on hasInternetConnection()
  set aURL to current application’s |NSURL|’s alloc()’s initWithString:"http://www.google.com"
  
set aReq to current application’s NSURLRequest’s alloc()’s initWithURL:aURL cachePolicy:(current application’s NSURLRequestReloadIgnoringLocalCacheData) timeoutInterval:5.0
  
set urlRes to (current application’s NSURLConnection’s sendSynchronousRequest:aReq returningResponse:(missing value) |error|:(missing value))
  
if urlRes = missing value then
    return false
  else
    return true
  end if
end hasInternetConnection

★Click Here to Open This Script 

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

Twitter投稿

Posted on 2月 11, 2018 by Takaaki Naganoya

macOS 10.13まではTwitter投稿やFacebook連携などもOSに組み込まれていたので、手軽にこうした機能を利用でき、macOS 10.13までの環境ではこのように呼び出せるようになっていました。

macOS 10.14から方針が変わり、これらの機能はOSに組み込まれなくなりました。いまだと、REST API経由で投稿を行うことになるでしょうか。

AppleScript名:Twitter投稿
— Created 2015-01-24 by Takaaki Naganoya
— 2015 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"

set aString to "ぴよ〜"

set twService to current application’s NSSharingService’s sharingServiceNamed:(current application’s NSSharingServiceNamePostOnTwitter)
set twService’s delegate to me

set shareItems to current application’s NSMutableArray’s alloc()’s initWithObjects:aString
tell twService to performWithItems:shareItems

★Click Here to Open This Script 

Posted in Network System | Tagged 10.11savvy 10.12savvy 10.13savvy Twitter

AirDropでファイルを送信する

Posted on 2月 11, 2018 by Takaaki Naganoya

Sharing Utilitiesを用いてAirDrop経由のファイル送信を行うAppleScriptです。

さすがに、Sharing Utilitiesは仕様も古いので、最新の環境に合わせて書き換えた「AirSharingLib Script Library」を配布、そちらを用いて同様の機能を実現するAppleScriptも掲載しています。

AppleScript名:AirDropでファイルを送信する
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use shareLib : script "Sharing Utilities" –https://macosxautomation.com/mavericks/libraries/examples.html

set anItem to choose file with prompt "Select File to send via AirDrop"
set aaList to {anItem}
begin AirDrop with aaList

★Click Here to Open This Script 

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

LAN上のHDDをマウントする v2

Posted on 2月 11, 2018 by Takaaki Naganoya
AppleScript名:LAN上のHDDをマウントする v2
–SMB経由でマウント
set userAccount to "maro" –ユーザー名(環境に応じて書き換え)
set userPass to "xxxxxx" –パスワード(環境に応じて書き換え)
set aMachine to "smb://MBA11._smb._tcp.local/Macintosh HD" –11インチMacBook Air (10.9.2)でSMBのみ有効にしてテスト
mountVolume(aMachine, userAccount, userPass) of me –通常実行

–AFP経由でマウント
set userAccount to "maro" –ユーザー名(環境に応じて書き換え)
set userPass to "xxxxxx" –パスワード(環境に応じて書き換え)
set aMachine to "afp://MBA13._afpovertcp._tcp.local/Macintosh SSD" –13インチMacBook Air (10.7.5)でAFPとSMBの両方を有効にしてテスト
mountVolumeAsync(aMachine, userAccount, userPass) of me –非同期実行

–指定のネットワーク上のディスクをマウントする
on mountVolume(aMachine, userAccount, userPass)
  
  
try
    with timeout of 100 seconds
      mount volume aMachine as user name userAccount with password userPass
    end timeout
  on error
    return false
  end try
  
  
return true
  
end mountVolume

–指定のネットワーク上のディスクをマウントする(非同期実行)
on mountVolumeAsync(aMachine, userAccount, userPass)
  
  
try
    ignoring application responses
      mount volume aMachine as user name userAccount with password userPass
    end ignoring
  on error
    —
  end try
  
end mountVolumeAsync

★Click Here to Open This Script 

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

無線LANデバイスのMACアドレスを取得する

Posted on 2月 11, 2018 by Takaaki Naganoya
AppleScript名:無線LANデバイスのMACアドレスを取得する
— Created 2015-08-18 by Takaaki Naganoya
— Created 2015-08-18 by Shane Stanley
— 2015 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "CoreWLAN"

set aRes to retWiFiMACaddress()
–>  "XX:XX:XX:XX:XX:XX"

–WiFi DeviceのMAC ADDRESSを返す
on retWiFiMACaddress()
  
  
–Get WLAN Device Name
  
set allNames to current application’s CWInterface’s interfaceNames()’s allObjects()
  
–>  (NSArray) {​​​​​"en0"​​​} –@MacBook Pro Retina 2012
  
  
set hitF to false
  
repeat with i from 1 to allNames’s |count|()
    set aInterface to (current application’s CWInterface’s interfaceWithName:(allNames’s objectAtIndex:(i – 1)))
    
if aInterface’s serviceActive() as boolean then
      set hitF to true
      
exit repeat
    end if
  end repeat
  
if hitF = false then return false –There is No WiFi Device (Broken or illigal configuration or Hackintosh)
  
  
set aHWAddress to aInterface’s hardwareAddress() as text
  
–>  "b8:xx:xx:xx:xx:xx"–MAC Address
  
  
return aHWAddress
  
end retWiFiMACaddress

★Click Here to Open This Script 

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

Post navigation

  • Older posts
  • Newer posts

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

Google Search

Popular posts

  • Numbersで選択範囲のセルの前後の空白を削除
  • macOS 26, Tahoe
  • macOS 15でも変化したText to Speech環境
  • KagiのWebブラウザ、Orion
  • Script Debuggerの開発と販売が2025年に終了
  • 【続報】macOS 15.5で特定ファイル名パターンのfileをaliasにcastすると100%クラッシュするバグ
  • macOS 15 リモートApple Eventsにバグ?
  • NSObjectのクラス名を取得 v2.1
  • 2024年に書いた価値あるAppleScript
  • 有害ではなくなっていたSpaces
  • macOS 15:スクリプトエディタのAppleScript用語辞書を確認できない
  • (確認中)AppleScript Dropletのバグっぽい動作が解消?
  • Xcode上のAppleScriptObjCのプログラムから、Xcodeのログ欄へのメッセージ出力を実行
  • AVSpeechSynthesizerで読み上げテスト
  • AppleScript Dropletのバグっぽい動作が「復活」(macOS 15.5β)
  • Apple、macOS標準搭載アプリ「写真」のバージョン表記を間違える
  • 指定フォルダ以下の画像のMD5チェックサムを求めて、重複しているものをピックアップ
  • macOS 26, 15.5でShortcuts.app「AppleScriptを実行」アクションのバグが修正される
  • Script Debuggerがフリーダウンロードで提供されることに
  • Numbersで選択中の2列のセルを比較して並べ直して書き戻す v2

Tags

10.11savvy (1101) 10.12savvy (1242) 10.13savvy (1391) 10.14savvy (587) 10.15savvy (438) 11.0savvy (283) 12.0savvy (212) 13.0savvy (204) 14.0savvy (159) 15.0savvy (157) 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 (56) 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
  • Newt On Project
  • 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
  • Scripting Additions
  • 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年11月
  • 2025年10月
  • 2025年9月
  • 2025年8月
  • 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