Post

Replies

Boosts

Views

Activity

Reply to Shortcuts – how do users install and how to use URL scheme ?
Can that process be automated ? General speaking, you can make standard installer to install AppleScript applets. Though I don't make such a installer with latest version of Xcode. Is there a way of using at the shortcuts URL scheme run the shortcut in place i.e. without opening the shortcuts app ? Or, can the URL scheme be used to call the Shortcuts Event app ? You can execute Shotcuts by using Shortcuts Events.app without launching Shortcuts.app. But....URL event is a kind of Apple's security broker. Apple want to keep them inactive....Some minor macOS update may effect your app due to the security reason or bug.
Apr ’23
Reply to How does one embed/set a ICC profile/color space into an image using apple script?
You can embed profile with "embed this_image with source" command. And..."profile" have to be an actual profile. Your code seems to use undeclared variable "profile". You have to set some ICC profile to other variable such as "myProfile". Then..... embed this_image with source myProfile will be executed. AppleScript's rexical coloring is important function to write AppleScript. Apple's default color setting is nightmare. It can not detect some different rexical elements. This is my rexical coloring in Script Editor. It can detect the difference of each rexical elements. http://piyocast.com/as/wp-content/uploads/2018/02/edf39d5e74f06d49cbe0d21a20cffb75-660x1024.png
Apr ’23
Reply to Apple Script not working on m2 Mac mini with lates osx
Did you set up Safari to execute "do javascript" AppleScript command? tell application "Safari" make new document with properties {URL:"http://piyocast.com/as"} end tell If this script works, AppleScript itself works with Safari. tell application "Safari" set aRes to do JavaScript "var selObj = window.getSelection(); var selStr = (selObj).getRangeAt(0); unescape(selStr);" in front document end tell display dialog aRes If this script does not work, you have to allow Safari to execute "do JavaScript" command. Safari v10 or later exhibit to execute "do JavaScript" command by default. You have to enable "Develop" menu from Safari's preferences setting. And....execute "Allow JavaScript from Apple Events" command from Safari'sDevelop menu (this operation require admin password).
Mar ’23
Reply to AppleScript "Image Events" does no longer get all Metadata
I checked .heic images on my Mac mini M1 (macOS 13.3beta) by using your script. One heic images returns {"samplesPerPixel", "hasAlpha", "dpiHeight", "dpiWidth", "space", "bitsPerSample", "formatOptions", "pixelHeight", "profile", "path", "pixelWidth", "format", "typeIdentifier"} But most of images returns {"samplesPerPixel", "hasAlpha", "dpiHeight", "dpiWidth", "bitsPerSample", "profile", "formatOptions", "ExifColorSpace", "pixelHeight", "path", "creation", "software", "space", "pixelWidth", "format", "make", "model", "typeIdentifier"} So, I don't think Image Events can not read "creation" Exif value. Today macOS has various bugs everywhere. Importer program is doubtful.
Mar ’23
Reply to AppleScript "Image Events" does no longer get all Metadata
The heic image which returns {"samplesPerPixel", "hasAlpha", "dpiHeight", "dpiWidth", "space", "bitsPerSample", "formatOptions", "pixelHeight", "profile", "path", "pixelWidth", "format", "typeIdentifier"} did not return creation date by another AppleScript execution. -- Created 2014-12-14 by Takaaki Naganoya -- 2014 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" use BPlus : script "BridgePlus" --https://www.macosxautomation.com/applescript/apps/BridgePlus.html property NSString : a reference to current application's NSString property NSLocale : a reference to current application's NSLocale property SMSForder : a reference to current application's SMSForder property NSDateFormatter : a reference to current application's NSDateFormatter set aTargFile to choose file of type {"public.image"} set exifRes to readExifDateTimeOriginal(aTargFile) of me --指定ファイルからのExifデータを取得し撮影日付を取得する on readExifDateTimeOriginal(aTargFileAlias) set theMetadata to readMetadataFrom(aTargFileAlias) of me set keysList to theMetadata's allKeys() if "{Exif}" is not in (keysList as list) then return false set exifDate to theMetadata's valueForKeyPath:"{Exif}.DateTimeOriginal" if exifDate = missing value then return false set fullDate to dateFromStringWithDateFormat(exifDate, "yyyy:MM:dd HH:mm:ss") of me return fullDate end readExifDateTimeOriginal --指定ファイルからのメタデータ読み込み on readMetadataFrom(imageFile) load framework set {theRecord, theError} to SMSForder's metadataFromImage:imageFile |error|:(specifier) if theRecord = missing value then -- there was a problem, so extract the error description error (theError's localizedDescription() as text) -- number (theError's code()) else return theRecord end if end readMetadataFrom --日付文字列を形式指定しつつdate objectに変換 on dateFromStringWithDateFormat(dateString, dateFormat) set dStr to NSString's stringWithString:dateString set dateFormatStr to NSString's stringWithString:dateFormat set aDateFormatter to NSDateFormatter's alloc()'s init() aDateFormatter's setDateFormat:dateFormatStr aDateFormatter's setLocale:(NSLocale's alloc()'s initWithLocaleIdentifier:"en_US_POSIX") set aDestDate to (aDateFormatter's dateFromString:dStr) return aDestDate as any end dateFromStringWithDateFormat
Mar ’23
Reply to Error in Apple script for saving password-protected PDF
Your approach seems far from the correct answer. My AppleScript works on macOS 13.3beta now. use AppleScript version "2.8" use scripting additions use framework "Foundation" use framework "PDFKit" property kCGPDFContextOwnerPassword : a reference to current application's kCGPDFContextOwnerPassword property NSDictionary : a reference to current application's NSDictionary property kCGPDFContextUserPassword : a reference to current application's kCGPDFContextUserPassword property |NSURL| : a reference to current application's |NSURL| property PDFDocument : a reference to current application's PDFDocument set userPassword to "12345" set ownerPassword to "01234" set aPath to (choose file of type {"com.adobe.pdf"} with prompt "Select PDF to Encrypt") set newF to choose file name with prompt "Select path & file name of password protected PDF" set aRes to my encryptPDF(aPath, newF, ownerPassword, userPassword) on encryptPDF(aPath, newF, ownerPassword, userPassword) set aURL to |NSURL|'s fileURLWithPath:(POSIX path of aPath) set aPDFdoc to PDFDocument's alloc()'s initWithURL:aURL set anEncF to aPDFdoc's isEncrypted() --Not encrypted if anEncF = false then set newFp to POSIX path of newF if newFp does not end with ".pdf" then set newFp to newFp & ".pdf" end if (* CFStringRef kCGPDFContextAuthor; CFStringRef kCGPDFContextCreator; CFStringRef kCGPDFContextTitle; CFStringRef kCGPDFContextOwnerPassword; CFStringRef kCGPDFContextUserPassword; CFStringRef kCGPDFContextAllowsPrinting;- CFStringRef kCGPDFContextAllowsCopying;--boolean CFStringRef kCGPDFContextOutputIntent;- CFStringRef kCGPDFContextOutputIntents; CFStringRef kCGPDFContextSubject; CFStringRef kCGPDFContextKeywords; CFStringRef kCGPDFContextEncryptionKeyLength; *) set aDic to NSDictionary's dictionaryWithObjects:{ownerPassword, userPassword} forKeys:{kCGPDFContextOwnerPassword, kCGPDFContextUserPassword} set aRes to aPDFdoc's writeToFile:newFp withOptions:aDic return aRes as boolean else --Already Encrypted return false end if end encryptPDF
Mar ’23
Reply to Fix iTunes / Music dead tracks with AppleScript
Hi, How do you get the path data? I got my selected file track on my Music.app by simple AppleScript. tell application "Music" set aList to selection set aTrack to first item of aList location of aTrack end tell This script returns alias type data. AppleScript's native path format is alias. Each file track has "location" property and it is not read only. It is change-able property. http://piyocast.com/as/wp-content/uploads/2023/03/music_dict_part.png So you will be able to select new location to each missing file tracks. One track is a piece of cake. 5,000? Hmm...we have to take other approarch. We can write fixing AppleScript. But it requires remote checking and specification document....I will do that work on condition that I get paid for it.
Mar ’23
Reply to javascript in AppleScript
You can execute JavaScript in AppleScript by using WebKit or JavaScriptCore. use AppleScript version "2.4" use scripting additions use framework "Foundation" use framework "JavaScriptCore" use framework "WebKit" --JavaScript Text set jsText to "let bar = 2; bar += 2; " --Execute JavaScript in WebKit set theWebView to current application's WebView's alloc()'s init() set x to (theWebView's stringByEvaluatingJavaScriptFromString:jsText) as text log {x, "2"} --Execute JavaScript in JavaScript Core set theContext to current application's JSContext's alloc()'s init() set theJSValue to theContext's evaluateScript:jsText log {theJSValue, "3"} You have to execute this AppleScript on Script Editor by Control-Command-R(Run in Main thread).
Mar ’23