AppleScript ScreenSaver

[com.apple.ScreenSaver.Computer-Name]メッセージ設定してからのスクリーンセーバー起動 macOS14対応(修正)


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
# 入力した文言でスクリーンセイバーが開始します
# 初回時のPLISTが無いケースに対応
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "IOKit"
use framework "AppKit"
use scripting additions

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


###選択肢レコード
set recordTimeInterval to {|15分後|:0.25, |30分後|:0.5, |45分後|:0.75, |1時間後|:1, |1時間半後|:1.5, |2時間後|:2} as record
###DICTからallKeyでリストにする
set ocidTimeIntervalDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidTimeIntervalDict's setDictionary:(recordTimeInterval)
set ocidAllKeys to ocidTimeIntervalDict's allKeys()
set ocidSortedArray to ocidAllKeys's sortedArrayUsingSelector:("localizedStandardCompare:")
set listAllKeys to ocidSortedArray as list

##############################
###ダイアログを前面に出す
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 strTitle to "戻る時間" as text
set strPrompt to "『HH時mm分ごろ戻ります』になります" as text
try
  set listResponse to (choose from list listAllKeys with title strTitle with prompt strPrompt default items (item 5 of listAllKeys) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
on error
log "エラーしました"
return "エラーしました"
  error "エラーしました" number -200
end try
if listResponse = {} then
return "何も選択していない"
else if (item 1 of listResponse) is false then
return "キャンセルしました"
else
  set strValue to (ocidTimeIntervalDict's valueForKey:(item 1 of listResponse)) as text
end if
set numValue to strValue as number
set intIntervalSec to ((60 * 60) * numValue) as integer
####ここがメッセージになります
set strResponse to doGetIntervalDate({"離席中HH時mm分ごろ戻ります", intIntervalSec})
#####################################
#####デバイスID取得から処理開始
#####################################

set strDeviceUUID to doGetDeviceUUID() as text

#####################################
######パス
#####################################
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidLibraryDirPathURL to ocidURLsArray's firstObject()
set ocidPlistFilePathURL to ocidLibraryDirPathURL's URLByAppendingPathComponent:("Application Support/com.apple.wallpaper/Store/Index.plist")

#####################################
######plist読み込み
#####################################
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
set listResults to refMe's NSMutableDictionary's dictionaryWithContentsOfURL:(ocidPlistFilePathURL) |error|:(reference)
set ocidPlistDict to item 1 of listResults
###
set ocidDataArray to ocidPlistDict's valueForKeyPath:("AllSpacesAndDisplays.Idle.Content.Choices.Configuration")
set ocidData to (ocidDataArray's firstObject())
#####################################
######バックアップ
#####################################
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDocumentDirPathURL to ocidURLsArray's firstObject()
set ocidSaveDirPathURL to ocidDocumentDirPathURL's URLByAppendingPathComponent:("Apple/com.apple.wallpaper/")
set ocidSaveFilePathURL to ocidDocumentDirPathURL's URLByAppendingPathComponent:("Apple/com.apple.wallpaper/backup.plist")
###保存先ディレクトリ生成
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
# 777-->511 755-->493 700-->448 766-->502
ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
###バックアップ保存
set listDone to ocidData's writeToURL:(ocidSaveFilePathURL) options:(refMe's NSDataWritingAtomic) |error|:(reference)
#####################################
######入れ替えデータ作成
#####################################
set ocidConfigurationDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
set ocidModuleDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
##セットするAppexのURL
set strAppexFilePath to "/System/Library/ExtensionKit/Extensions/Computer Name.appex" as text
set ocidAppexFilePathStr to refMe's NSString's stringWithString:(strAppexFilePath)
set ocidAppexFilePath to ocidAppexFilePathStr's stringByStandardizingPath()
set ocidAppexFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidAppexFilePath) isDirectory:false)
set strAppexFilePathURL to ocidAppexFilePathURL's absoluteString() as text
##値をセット
ocidModuleDict's setValue:(strAppexFilePathURL) forKey:("relative")
##↑のDICTをセット
ocidConfigurationDict's setObject:(ocidModuleDict) forKey:("module")
###XML形式
set ocidBinplist to refMe's NSPropertyListBinaryFormat_v1_0
###PLISTに
set listSetPlistData to refMe's NSPropertyListSerialization's dataWithPropertyList:(ocidConfigurationDict) format:(ocidBinplist) options:0 |error|:(reference)
set ocidSetPlistData to item 1 of listSetPlistData

#####################################
######データセットして保存
#####################################
set ocidAllSpacesAndDisplays to ocidPlistDict's objectForKey:("AllSpacesAndDisplays")
set ocidIdle to ocidAllSpacesAndDisplays's objectForKey:("Idle")
set ocidContent to ocidIdle's objectForKey:("Content")
set ocidChoices to ocidContent's objectForKey:("Choices")
set ocidItem0 to ocidChoices's firstObject()
ocidItem0's setValue:("com.apple.wallpaper.choice.screen-saver") forKey:("Provider")
ocidItem0's setObject:(ocidSetPlistData) forKey:("Configuration")
##
set ocidAllSpacesAndDisplays to ocidPlistDict's objectForKey:("SystemDefault")
set ocidIdle to ocidAllSpacesAndDisplays's objectForKey:("Idle")
set ocidContent to ocidIdle's objectForKey:("Content")
set ocidChoices to ocidContent's objectForKey:("Choices")
set ocidItem0 to ocidChoices's firstObject()
ocidItem0's setValue:("com.apple.wallpaper.choice.screen-saver") forKey:("Provider")
ocidItem0's setObject:(ocidSetPlistData) forKey:("Configuration")
##
set boolDone to ocidPlistDict's writeToURL:(ocidPlistFilePathURL) atomically:true
log boolDone

#####################################
######com.apple.ScreenSaver.Computer-Nameのパス
#####################################
set strPlistSubPath to "Containers/com.apple.ScreenSaver.Computer-Name/Data/Library/Preferences/ByHost/com.apple.ScreenSaver.Computer-Name." & strDeviceUUID & ".plist" as text

#####################################
######パス
#####################################
set ocidPathArray to (objFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidUserLibraryPathURL to ocidPathArray's objectAtIndex:0
set ocidFilePathURL to ocidUserLibraryPathURL's URLByAppendingPathComponent:(strPlistSubPath) isDirectory:false
#####################################
######ファイルの有無確認
#####################################
set ocidFilePath to ocidFilePathURL's |path|()
set boolFileExists to appFileManager's fileExistsAtPath:(ocidFilePath) isDirectory:(false)
if boolFileExists = true then
log "Plistは存在するので処理を継続"
else if boolFileExists = false then
log "Plistが存在しないのでエラー新規作成する"
  ##ByHostフォルダをまずは作成
  set ocidContainerDirPathURL to ocidFilePathURL's URLByDeletingLastPathComponent()
  set appFileManager to refMe's NSFileManager's defaultManager()
  set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
  # 777-->511 755-->493 700-->448 766-->502
ocidAttrDict's setValue:(493) forKey:(refMe's NSFilePosixPermissions)
  set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidContainerDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
end if

#####################################
######plist読み込み
#####################################
set listResults to refMe's NSMutableDictionary's dictionaryWithContentsOfURL:ocidFilePathURL |error|:(reference)
set ocidReadDict to item 1 of listResults
#####################################
###### 値の変更 -->スクリーンセーバーのメッセージ
#####################################
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
if (ocidPlistDict = (missing value)) then
log "Plist新規作成"
ocidPlistDict's setValue:strResponse forKey:"MESSAGE"
else
ocidPlistDict's setDictionary:(ocidReadDict)
ocidPlistDict's setValue:strResponse forKey:"MESSAGE"
end if
log ocidPlistDict as record

#####################################
###### 保存
#####################################
###書き込み用にバイナリPLISTデータに変換
set ocidNSbplist to refMe's NSPropertyListBinaryFormat_v1_0
set ocidPlistEditDataArray to refMe's NSPropertyListSerialization's dataWithPropertyList:ocidPlistDict format:ocidNSbplist options:0 |error|:(reference)
set ocidPlistEditData to item 1 of ocidPlistEditDataArray
set boolDone to ocidPlistEditData's writeToURL:ocidFilePathURL options:0 |error|:(reference)

#####CFPreferencesを再起動させて変更後の値をロードさせる
set strCommandText to "/usr/bin/killall cfprefsd" as text
do shell script strCommandText
#####反映待ち
delay 2
#####################################
### スクリーンセーバースタート macOS14対応
#####################################
try
  tell application id "com.apple.ScreenSaver.Engine"
    ## launch
activate
  end tell
on error
  #####コマンド実行
  try
    set strCommandText to "/usr/bin/open \"/System/Library/CoreServices/ScreenSaverEngine.app\"" as text
do shell script strCommandText
  on error
    ###
    set aliasScreenSaverEngine to POSIX file "/System/Library/CoreServices/ScreenSaverEngine.app" as alias
    tell application "Finder"
open aliasScreenSaverEngine
    end tell
  end try
end try




#####################################
######ファイル名の日付
#####################################
to doGetDateNo(strDateFormat)
  ####日付情報の取得
  set ocidDate to refMe's NSDate's |date|()
  ###日付のフォーマットを定義
  set ocidNSDateFormatter to refMe's NSDateFormatter's alloc()'s init()
ocidNSDateFormatter's setLocale:(refMe's NSLocale's localeWithLocaleIdentifier:"en_US")
ocidNSDateFormatter's setDateFormat:strDateFormat
  set ocidDateAndTime to ocidNSDateFormatter's stringFromDate:ocidDate
  set strDateAndTime to ocidDateAndTime as text
return strDateAndTime
end doGetDateNo


#####################################
###### デバイスUUID 取得
#####################################

to doGetDeviceUUID()
  
  set objFileManager to refMe's NSFileManager's defaultManager()
  
  #####################################
  ######テンポラリフォルダ生成
  #####################################
  set ocidTemporaryDirectoryURL to objFileManager's temporaryDirectory()
  set ocidCleanupAtStartupURL to ocidTemporaryDirectoryURL's URLByAppendingPathComponent:"Cleanup At Startup" isDirectory:true
  ####アクセス権777で作成
  set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
objFileManager's createDirectoryAtURL:ocidCleanupAtStartupURL withIntermediateDirectories:true attributes:ocidAttrDict |error|:(reference)
  #####################################
  ######Plist File Path
  #####################################
  set strDateNo to doGetDateNo("yyyyMMddhhmmss")
  set strFileName to strDateNo & ".plist"
  set ocidFilePathURL to ocidCleanupAtStartupURL's URLByAppendingPathComponent:strFileName
  set strFilePath to ocidFilePathURL's |path|() as text
  
  #####################################
  ######コマンド実行
  #####################################
  set strCommandText to "/usr/sbin/ioreg -c IOPlatformExpertDevice -a >> \"" & strFilePath & "\"" as text
do shell script strCommandText
  
  #####################################
  ######plist読み込み
  #####################################
  set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
  set ocidReadPlistData to refMe's NSMutableDictionary's dictionaryWithContentsOfURL:ocidFilePathURL |error|:(reference)
  set ocidPlistDict to item 1 of ocidReadPlistData
  
  #####################################
  ###### デバイスUUID 取得
  #####################################
  set ocidDeviceUUID to (ocidPlistDict's valueForKeyPath:"IORegistryEntryChildren.IOPlatformUUID")
  
  
  #####################################
  ###### シリアル番号取得
  #####################################
  set ocidSerialNumber to (ocidPlistDict's valueForKeyPath:"IORegistryEntryChildren.IOPlatformSerialNumber")
  
  
  #####################################
  ###### モデル番号
  #####################################
  set ocidEntryName to (ocidPlistDict's valueForKeyPath:"IORegistryEntryChildren.IORegistryEntryName")
  
return ocidDeviceUUID
  
end doGetDeviceUUID







################################
#### X秒後= argIntervalSec の時間
################################
to doGetIntervalDate({argDateFormat, argIntervalSec})
  set strDateFormat to argDateFormat as text
  set intIntervalSec to argIntervalSec as integer
  ####日付情報の取得
  set ocidDate to current application's NSDate's |date|()
  ####インターバル指定
  set ocidIntervalDate to ocidDate's dateByAddingTimeInterval:(intIntervalSec)
  ###日付のフォーマットを定義
  set ocidFormatterJP to current application's NSDateFormatter's alloc()'s init()
  ###日本のカレンダー
  set ocidCalendarJP to current application's NSCalendar's alloc()'s initWithCalendarIdentifier:(current application's NSCalendarIdentifierJapanese)
  ###東京タイムゾーン
  set ocidTimezoneJP to current application's NSTimeZone's alloc()'s initWithName:("Asia/Tokyo")
  ###日本語
  set ocidLocaleJP to current application's NSLocale's alloc()'s initWithLocaleIdentifier:("ja_JP_POSIX")
ocidFormatterJP's setTimeZone:(ocidTimezoneJP)
ocidFormatterJP's setLocale:(ocidLocaleJP)
ocidFormatterJP's setCalendar:(ocidCalendarJP)
ocidFormatterJP's setDateFormat:("Gyy")
ocidFormatterJP's setDateFormat:(strDateFormat)
  set ocidDateAndTime to ocidFormatterJP's stringFromDate:(ocidIntervalDate)
  set strDateAndTime to ocidDateAndTime as text
return strDateAndTime
end doGetIntervalDate

|

[com.apple.wallpaper]格納されているDATAをPLISTに書き出し

Screen-20231112-100817
この部分を書き出します

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

#!/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 NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidLibraryDirPathURL to ocidURLsArray's firstObject()
set ocidPlistFilePathURL to ocidLibraryDirPathURL's URLByAppendingPathComponent:("Application Support/com.apple.wallpaper/Store/Index.plist")
#####################################
######plist読み込み
#####################################
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
set listResults to refMe's NSMutableDictionary's dictionaryWithContentsOfURL:(ocidPlistFilePathURL) |error|:(reference)
set ocidPlistDict to item 1 of listResults
###PLIST取得
set ocidDataArray to ocidPlistDict's valueForKeyPath:("AllSpacesAndDisplays.Idle.Content.Choices.Configuration")
set ocidDataAllSpacesAndDisplays to (ocidDataArray's firstObject())
##書き出しパス
set strFilePath to "~/Desktop/AllSpacesAndDisplays.plist" as text
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 listDone to ocidDataAllSpacesAndDisplays's writeToFile:(ocidFilePath) options:(refMe's NSDataWritingAtomic) |error|:(reference)

###PLIST取得
set ocidDataArray to ocidPlistDict's valueForKeyPath:("SystemDefault.Idle.Content.Choices.Configuration")
set ocidDataSystemDefault to (ocidDataArray's firstObject())
##書き出しパス
set strFilePath to "~/Desktop/SystemDefault.plist" as text
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 listDone to ocidDataAllSpacesAndDisplays's writeToFile:(ocidFilePath) options:(refMe's NSDataWritingAtomic) |error|:(reference)

|

[ScreenSaverEngine]メッセージ設定してからのスクリーンセーバー起動 macOS14対応


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

#!/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 "IOKit"
use scripting additions

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


set aliasIconPath to POSIX file "/System/Library/CoreServices/ScreenSaverEngine.app/Contents/Resources/AppIcon.icns" as alias
set strDefaultAnswer to "離席中です<<すぐ戻ります" as text
try
  set recordResponse to (display dialog "スクリーンセイバーに表示する文字列" with title "入力してください" default answer strDefaultAnswer buttons {"OK", "キャンセル"} default button "OK" cancel button "キャンセル" with icon aliasIconPath giving up after 30 without hidden answer)
  
on error
  log "エラーしました"
return "エラーしました"
  error number -128
end try
if true is equal to (gave up of recordResponse) then
return "時間切れですやりなおしてください"
  error number -128
end if
if "OK" is equal to (button returned of recordResponse) then
  set strResponse to (text returned of recordResponse) as text
else
  log "エラーしました"
return "エラーしました"
  error number -128
end if

#####################################
#####デバイスID取得から処理開始
#####################################
set strDeviceUUID to doGetDeviceUUID() as text

#####################################
######パス
#####################################
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidLibraryDirPathURL to ocidURLsArray's firstObject()
set ocidPlistFilePathURL to ocidLibraryDirPathURL's URLByAppendingPathComponent:("Application Support/com.apple.wallpaper/Store/Index.plist")

#####################################
######plist読み込み
#####################################
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
set listResults to refMe's NSMutableDictionary's dictionaryWithContentsOfURL:(ocidPlistFilePathURL) |error|:(reference)
set ocidPlistDict to item 1 of listResults
###
set ocidDataArray to ocidPlistDict's valueForKeyPath:("AllSpacesAndDisplays.Idle.Content.Choices.Configuration")
set ocidData to (ocidDataArray's firstObject())
#####################################
######バックアップ
#####################################
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDocumentDirPathURL to ocidURLsArray's firstObject()
set ocidSaveDirPathURL to ocidDocumentDirPathURL's URLByAppendingPathComponent:("Apple/com.apple.wallpaper/")
set ocidSaveFilePathURL to ocidDocumentDirPathURL's URLByAppendingPathComponent:("Apple/com.apple.wallpaper/backup.plist")
###保存先ディレクトリ生成
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
# 777-->511 755-->493 700-->448 766-->502
ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
###バックアップ保存
set listDone to ocidData's writeToURL:(ocidSaveFilePathURL) options:(refMe's NSDataWritingAtomic) |error|:(reference)
#####################################
######入れ替えデータ作成
#####################################
set ocidConfigurationDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
set ocidModuleDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
##セットするAppexのURL
set strAppexFilePath to "/System/Library/ExtensionKit/Extensions/Computer Name.appex" as text
set ocidAppexFilePathStr to refMe's NSString's stringWithString:(strAppexFilePath)
set ocidAppexFilePath to ocidAppexFilePathStr's stringByStandardizingPath()
set ocidAppexFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidAppexFilePath) isDirectory:false)
set strAppexFilePathURL to ocidAppexFilePathURL's absoluteString() as text
##値をセット
ocidModuleDict's setValue:(strAppexFilePathURL) forKey:("relative")
##↑のDICTをセット
ocidConfigurationDict's setObject:(ocidModuleDict) forKey:("module")
###XML形式
set ocidBinplist to refMe's NSPropertyListBinaryFormat_v1_0
###PLISTに
set listSetPlistData to refMe's NSPropertyListSerialization's dataWithPropertyList:(ocidConfigurationDict) format:(ocidBinplist) options:0 |error|:(reference)
set ocidSetPlistData to item 1 of listSetPlistData

#####################################
######データセットして保存
#####################################
set ocidAllSpacesAndDisplays to ocidPlistDict's objectForKey:("AllSpacesAndDisplays")
set ocidIdle to ocidAllSpacesAndDisplays's objectForKey:("Idle")
set ocidContent to ocidIdle's objectForKey:("Content")
set ocidChoices to ocidContent's objectForKey:("Choices")
set ocidItem0 to ocidChoices's firstObject()
ocidItem0's setValue:("com.apple.wallpaper.choice.screen-saver") forKey:("Provider")
ocidItem0's setObject:(ocidSetPlistData) forKey:("Configuration")
##
set ocidAllSpacesAndDisplays to ocidPlistDict's objectForKey:("SystemDefault")
set ocidIdle to ocidAllSpacesAndDisplays's objectForKey:("Idle")
set ocidContent to ocidIdle's objectForKey:("Content")
set ocidChoices to ocidContent's objectForKey:("Choices")
set ocidItem0 to ocidChoices's firstObject()
ocidItem0's setValue:("com.apple.wallpaper.choice.screen-saver") forKey:("Provider")
ocidItem0's setObject:(ocidSetPlistData) forKey:("Configuration")
##
set boolDone to ocidPlistDict's writeToURL:(ocidPlistFilePathURL) atomically:true
log boolDone

#####################################
######メッセージの変更
#####################################
set strPlistSubPath to "Containers/com.apple.ScreenSaver.Computer-Name/Data/Library/Preferences/ByHost/com.apple.ScreenSaver.Computer-Name." & strDeviceUUID & ".plist" as text

#####################################
######パス
#####################################
set ocidPathArray to (objFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidUserLibraryPathURL to ocidPathArray's objectAtIndex:0
set ocidFilePathURL to ocidUserLibraryPathURL's URLByAppendingPathComponent:(strPlistSubPath) isDirectory:false

#####################################
######plist読み込み
#####################################
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
set listResults to refMe's NSMutableDictionary's dictionaryWithContentsOfURL:ocidFilePathURL |error|:(reference)
set ocidPlistDict to item 1 of listResults

#####################################
###### 値の変更 -->スクリーンセーバーのメッセージ
#####################################
ocidPlistDict's setValue:strResponse forKeyPath:"MESSAGE"

log ocidPlistDict as record
#####################################
###### 保存
#####################################
###書き込み用にバイナリPLISTデータに変換
set ocidNSbplist to refMe's NSPropertyListBinaryFormat_v1_0
set ocidPlistEditDataArray to refMe's NSPropertyListSerialization's dataWithPropertyList:ocidPlistDict format:ocidNSbplist options:0 |error|:(reference)
set ocidPlistEditData to item 1 of ocidPlistEditDataArray
set boolDone to ocidPlistEditData's writeToURL:ocidFilePathURL options:0 |error|:(reference)

#####CFPreferencesを再起動させて変更後の値をロードさせる
set strCommandText to "/usr/bin/killall cfprefsd" as text
do shell script strCommandText
#####反映待ち
delay 2


#####################################
### スクリーンセーバースタート macOS14対応
#####################################
try
  tell application id "com.apple.ScreenSaver.Engine"
    ## launch
    activate
  end tell
on error
  #####コマンド実行
  try
    set strCommandText to "/usr/bin/open \"/System/Library/CoreServices/ScreenSaverEngine.app\"" as text
    do shell script strCommandText
  on error
    ###
    set aliasScreenSaverEngine to POSIX file "/System/Library/CoreServices/ScreenSaverEngine.app" as alias
    tell application "Finder"
      open aliasScreenSaverEngine
    end tell
  end try
end try



#####################################
######ファイル名の日付
#####################################
to doGetDateNo(strDateFormat)
  ####日付情報の取得
  set ocidDate to refMe's NSDate's |date|()
  ###日付のフォーマットを定義
  set ocidNSDateFormatter to refMe's NSDateFormatter's alloc()'s init()
ocidNSDateFormatter's setLocale:(refMe's NSLocale's localeWithLocaleIdentifier:"en_US")
ocidNSDateFormatter's setDateFormat:strDateFormat
  set ocidDateAndTime to ocidNSDateFormatter's stringFromDate:ocidDate
  set strDateAndTime to ocidDateAndTime as text
return strDateAndTime
end doGetDateNo


#####################################
###### デバイスUUID 取得
#####################################

to doGetDeviceUUID()
  
  set objFileManager to refMe's NSFileManager's defaultManager()
  
  #####################################
  ######テンポラリフォルダ生成
  #####################################
  set ocidTemporaryDirectoryURL to objFileManager's temporaryDirectory()
  set ocidCleanupAtStartupURL to ocidTemporaryDirectoryURL's URLByAppendingPathComponent:"Cleanup At Startup" isDirectory:true
  ####アクセス権777で作成
  set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
objFileManager's createDirectoryAtURL:ocidCleanupAtStartupURL withIntermediateDirectories:true attributes:ocidAttrDict |error|:(reference)
  #####################################
  ######Plist File Path
  #####################################
  set strDateNo to doGetDateNo("yyyyMMddhhmmss")
  set strFileName to strDateNo & ".plist"
  set ocidFilePathURL to ocidCleanupAtStartupURL's URLByAppendingPathComponent:strFileName
  set strFilePath to ocidFilePathURL's |path|() as text
  
  #####################################
  ######コマンド実行
  #####################################
  set strCommandText to "/usr/sbin/ioreg -c IOPlatformExpertDevice -a >> \"" & strFilePath & "\"" as text
  do shell script strCommandText
  
  #####################################
  ######plist読み込み
  #####################################
  set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
  set ocidReadPlistData to refMe's NSMutableDictionary's dictionaryWithContentsOfURL:ocidFilePathURL |error|:(reference)
  set ocidPlistDict to item 1 of ocidReadPlistData
  
  #####################################
  ###### デバイスUUID 取得
  #####################################
  set ocidDeviceUUID to (ocidPlistDict's valueForKeyPath:"IORegistryEntryChildren.IOPlatformUUID")
  
  
  #####################################
  ###### シリアル番号取得
  #####################################
  set ocidSerialNumber to (ocidPlistDict's valueForKeyPath:"IORegistryEntryChildren.IOPlatformSerialNumber")
  
  
  #####################################
  ###### モデル番号
  #####################################
  set ocidEntryName to (ocidPlistDict's valueForKeyPath:"IORegistryEntryChildren.IORegistryEntryName")
  
return ocidDeviceUUID
  
end doGetDeviceUUID

|

[ScreenSaverEngine]X時X分頃戻ります(セット時はXX分後) macOS14対応


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

#!/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 "IOKit"
use framework "AppKit"
use scripting additions

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


###選択肢レコード
set recordTimeInterval to {|15分後|:0.25, |30分後|:0.5, |45分後|:0.75, |1時間後|:1, |1時間半後|:1.5, |2時間後|:2} as record
###DICTからallKeyでリストにする
set ocidTimeIntervalDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidTimeIntervalDict's setDictionary:(recordTimeInterval)
set ocidAllKeys to ocidTimeIntervalDict's allKeys()
set ocidSortedArray to ocidAllKeys's sortedArrayUsingSelector:("localizedStandardCompare:")
set listAllKeys to ocidSortedArray as list

##############################
###ダイアログを前面に出す
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 strTitle to "戻る時間" as text
set strPrompt to "『HH時mm分ごろ戻ります』になります" as text
try
  set listResponse to (choose from list listAllKeys with title strTitle with prompt strPrompt default items (item 5 of listAllKeys) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
on error
  log "エラーしました"
return "エラーしました"
  error "エラーしました" number -200
end try
if listResponse = {} then
return "何も選択していない"
else if (item 1 of listResponse) is false then
return "キャンセルしました"
else
  set strValue to (ocidTimeIntervalDict's valueForKey:(item 1 of listResponse)) as text
end if
set numValue to strValue as number
set intIntervalSec to ((60 * 60) * numValue) as integer
####ここがメッセージになります
set strResponse to doGetIntervalDate({"離席中HH時mm分ごろ戻ります", intIntervalSec})
#####################################
#####デバイスID取得から処理開始
#####################################

set strDeviceUUID to doGetDeviceUUID() as text

#####################################
######パス
#####################################
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidLibraryDirPathURL to ocidURLsArray's firstObject()
set ocidPlistFilePathURL to ocidLibraryDirPathURL's URLByAppendingPathComponent:("Application Support/com.apple.wallpaper/Store/Index.plist")

#####################################
######plist読み込み
#####################################
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
set listResults to refMe's NSMutableDictionary's dictionaryWithContentsOfURL:(ocidPlistFilePathURL) |error|:(reference)
set ocidPlistDict to item 1 of listResults
###
set ocidDataArray to ocidPlistDict's valueForKeyPath:("AllSpacesAndDisplays.Idle.Content.Choices.Configuration")
set ocidData to (ocidDataArray's firstObject())
#####################################
######バックアップ
#####################################
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDocumentDirPathURL to ocidURLsArray's firstObject()
set ocidSaveDirPathURL to ocidDocumentDirPathURL's URLByAppendingPathComponent:("Apple/com.apple.wallpaper/")
set ocidSaveFilePathURL to ocidDocumentDirPathURL's URLByAppendingPathComponent:("Apple/com.apple.wallpaper/backup.plist")
###保存先ディレクトリ生成
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
# 777-->511 755-->493 700-->448 766-->502
ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
###バックアップ保存
set listDone to ocidData's writeToURL:(ocidSaveFilePathURL) options:(refMe's NSDataWritingAtomic) |error|:(reference)
#####################################
######入れ替えデータ作成
#####################################
set ocidConfigurationDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
set ocidModuleDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
##セットするAppexのURL
set strAppexFilePath to "/System/Library/ExtensionKit/Extensions/Computer Name.appex" as text
set ocidAppexFilePathStr to refMe's NSString's stringWithString:(strAppexFilePath)
set ocidAppexFilePath to ocidAppexFilePathStr's stringByStandardizingPath()
set ocidAppexFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidAppexFilePath) isDirectory:false)
set strAppexFilePathURL to ocidAppexFilePathURL's absoluteString() as text
##値をセット
ocidModuleDict's setValue:(strAppexFilePathURL) forKey:("relative")
##↑のDICTをセット
ocidConfigurationDict's setObject:(ocidModuleDict) forKey:("module")
###XML形式
set ocidBinplist to refMe's NSPropertyListBinaryFormat_v1_0
###PLISTに
set listSetPlistData to refMe's NSPropertyListSerialization's dataWithPropertyList:(ocidConfigurationDict) format:(ocidBinplist) options:0 |error|:(reference)
set ocidSetPlistData to item 1 of listSetPlistData

#####################################
######データセットして保存
#####################################
set ocidAllSpacesAndDisplays to ocidPlistDict's objectForKey:("AllSpacesAndDisplays")
set ocidIdle to ocidAllSpacesAndDisplays's objectForKey:("Idle")
set ocidContent to ocidIdle's objectForKey:("Content")
set ocidChoices to ocidContent's objectForKey:("Choices")
set ocidItem0 to ocidChoices's firstObject()
ocidItem0's setValue:("com.apple.wallpaper.choice.screen-saver") forKey:("Provider")
ocidItem0's setObject:(ocidSetPlistData) forKey:("Configuration")
##
set ocidAllSpacesAndDisplays to ocidPlistDict's objectForKey:("SystemDefault")
set ocidIdle to ocidAllSpacesAndDisplays's objectForKey:("Idle")
set ocidContent to ocidIdle's objectForKey:("Content")
set ocidChoices to ocidContent's objectForKey:("Choices")
set ocidItem0 to ocidChoices's firstObject()
ocidItem0's setValue:("com.apple.wallpaper.choice.screen-saver") forKey:("Provider")
ocidItem0's setObject:(ocidSetPlistData) forKey:("Configuration")
##
set boolDone to ocidPlistDict's writeToURL:(ocidPlistFilePathURL) atomically:true
log boolDone

#####################################
######メッセージの変更
#####################################
set strPlistSubPath to "Containers/com.apple.ScreenSaver.Computer-Name/Data/Library/Preferences/ByHost/com.apple.ScreenSaver.Computer-Name." & strDeviceUUID & ".plist" as text

#####################################
######パス
#####################################
set ocidPathArray to (objFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidUserLibraryPathURL to ocidPathArray's objectAtIndex:0
set ocidFilePathURL to ocidUserLibraryPathURL's URLByAppendingPathComponent:(strPlistSubPath) isDirectory:false

#####################################
######plist読み込み
#####################################
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
set listResults to refMe's NSMutableDictionary's dictionaryWithContentsOfURL:ocidFilePathURL |error|:(reference)
set ocidPlistDict to item 1 of listResults

#####################################
###### 値の変更 -->スクリーンセーバーのメッセージ
#####################################
ocidPlistDict's setValue:strResponse forKeyPath:"MESSAGE"

log ocidPlistDict as record
#####################################
###### 保存
#####################################
###書き込み用にバイナリPLISTデータに変換
set ocidNSbplist to refMe's NSPropertyListBinaryFormat_v1_0
set ocidPlistEditDataArray to refMe's NSPropertyListSerialization's dataWithPropertyList:ocidPlistDict format:ocidNSbplist options:0 |error|:(reference)
set ocidPlistEditData to item 1 of ocidPlistEditDataArray
set boolDone to ocidPlistEditData's writeToURL:ocidFilePathURL options:0 |error|:(reference)

#####CFPreferencesを再起動させて変更後の値をロードさせる
set strCommandText to "/usr/bin/killall cfprefsd" as text
do shell script strCommandText
#####反映待ち
delay 2
#####################################
### スクリーンセーバースタート macOS14対応
#####################################
try
  tell application id "com.apple.ScreenSaver.Engine"
    ## launch
    activate
  end tell
on error
  #####コマンド実行
  try
    set strCommandText to "/usr/bin/open \"/System/Library/CoreServices/ScreenSaverEngine.app\"" as text
    do shell script strCommandText
  on error
    ###
    set aliasScreenSaverEngine to POSIX file "/System/Library/CoreServices/ScreenSaverEngine.app" as alias
    tell application "Finder"
      open aliasScreenSaverEngine
    end tell
  end try
end try




#####################################
######ファイル名の日付
#####################################
to doGetDateNo(strDateFormat)
  ####日付情報の取得
  set ocidDate to refMe's NSDate's |date|()
  ###日付のフォーマットを定義
  set ocidNSDateFormatter to refMe's NSDateFormatter's alloc()'s init()
ocidNSDateFormatter's setLocale:(refMe's NSLocale's localeWithLocaleIdentifier:"en_US")
ocidNSDateFormatter's setDateFormat:strDateFormat
  set ocidDateAndTime to ocidNSDateFormatter's stringFromDate:ocidDate
  set strDateAndTime to ocidDateAndTime as text
return strDateAndTime
end doGetDateNo


#####################################
###### デバイスUUID 取得
#####################################

to doGetDeviceUUID()
  
  set objFileManager to refMe's NSFileManager's defaultManager()
  
  #####################################
  ######テンポラリフォルダ生成
  #####################################
  set ocidTemporaryDirectoryURL to objFileManager's temporaryDirectory()
  set ocidCleanupAtStartupURL to ocidTemporaryDirectoryURL's URLByAppendingPathComponent:"Cleanup At Startup" isDirectory:true
  ####アクセス権777で作成
  set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
objFileManager's createDirectoryAtURL:ocidCleanupAtStartupURL withIntermediateDirectories:true attributes:ocidAttrDict |error|:(reference)
  #####################################
  ######Plist File Path
  #####################################
  set strDateNo to doGetDateNo("yyyyMMddhhmmss")
  set strFileName to strDateNo & ".plist"
  set ocidFilePathURL to ocidCleanupAtStartupURL's URLByAppendingPathComponent:strFileName
  set strFilePath to ocidFilePathURL's |path|() as text
  
  #####################################
  ######コマンド実行
  #####################################
  set strCommandText to "/usr/sbin/ioreg -c IOPlatformExpertDevice -a >> \"" & strFilePath & "\"" as text
  do shell script strCommandText
  
  #####################################
  ######plist読み込み
  #####################################
  set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
  set ocidReadPlistData to refMe's NSMutableDictionary's dictionaryWithContentsOfURL:ocidFilePathURL |error|:(reference)
  set ocidPlistDict to item 1 of ocidReadPlistData
  
  #####################################
  ###### デバイスUUID 取得
  #####################################
  set ocidDeviceUUID to (ocidPlistDict's valueForKeyPath:"IORegistryEntryChildren.IOPlatformUUID")
  
  
  #####################################
  ###### シリアル番号取得
  #####################################
  set ocidSerialNumber to (ocidPlistDict's valueForKeyPath:"IORegistryEntryChildren.IOPlatformSerialNumber")
  
  
  #####################################
  ###### モデル番号
  #####################################
  set ocidEntryName to (ocidPlistDict's valueForKeyPath:"IORegistryEntryChildren.IORegistryEntryName")
  
return ocidDeviceUUID
  
end doGetDeviceUUID







################################
#### X秒後= argIntervalSec の時間
################################
to doGetIntervalDate({argDateFormat, argIntervalSec})
  set strDateFormat to argDateFormat as text
  set intIntervalSec to argIntervalSec as integer
  ####日付情報の取得
  set ocidDate to current application's NSDate's |date|()
  ####インターバル指定
  set ocidIntervalDate to ocidDate's dateByAddingTimeInterval:(intIntervalSec)
  ###日付のフォーマットを定義
  set ocidFormatterJP to current application's NSDateFormatter's alloc()'s init()
  ###日本のカレンダー
  set ocidCalendarJP to current application's NSCalendar's alloc()'s initWithCalendarIdentifier:(current application's NSCalendarIdentifierJapanese)
  ###東京タイムゾーン
  set ocidTimezoneJP to current application's NSTimeZone's alloc()'s initWithName:("Asia/Tokyo")
  ###日本語
  set ocidLocaleJP to current application's NSLocale's alloc()'s initWithLocaleIdentifier:("ja_JP_POSIX")
ocidFormatterJP's setTimeZone:(ocidTimezoneJP)
ocidFormatterJP's setLocale:(ocidLocaleJP)
ocidFormatterJP's setCalendar:(ocidCalendarJP)
ocidFormatterJP's setDateFormat:("Gyy")
ocidFormatterJP's setDateFormat:(strDateFormat)
  set ocidDateAndTime to ocidFormatterJP's stringFromDate:(ocidIntervalDate)
  set strDateAndTime to ocidDateAndTime as text
return strDateAndTime
end doGetIntervalDate

|

[ScreenSaver]メッセージを変更してからスクリーンセーバーをスタートさせる(離席用)

ダウンロード - screensaverengine.zip






#!/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 "IOKit"
use scripting additions

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


set aliasIconPath to POSIX file "/System/Library/CoreServices/ScreenSaverEngine.app/Contents/Resources/ScreenSaverEngine.icns" as alias
set strDefaultAnswer to "離席中です" as text
try
    set recordResponse to (display dialog "スクリーンセイバーに表示する文字列" with title "入力してください" default answer strDefaultAnswer buttons {"OK", "キャンセル"} default button "OK" cancel button "キャンセル" with icon aliasIconPath giving up after 30 without hidden answer)
    
on error
    log "エラーしました"
    return "エラーしました"
    error number -128
end try
if true is equal to (gave up of recordResponse) then
    return "時間切れですやりなおしてください"
    error number -128
end if
if "OK" is equal to (button returned of recordResponse) then
    set strResponse to (text returned of recordResponse) as text
else
    log "エラーしました"
    return "エラーしました"
    error number -128
end if

#####################################
#####デバイスID取得から処理開始
#####################################

set strDeviceUUID to doGetDeviceUUID() as text

#####################################
######設定の変更
#####################################
set strPlistSubPath to "Preferences/ByHost/com.apple.screensaver." & strDeviceUUID & ".plist" as text

#####################################
######パス
#####################################
set ocidPathArray to (objFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidUserLibraryPathURL to ocidPathArray's objectAtIndex:0
set ocidFilePathURL to ocidUserLibraryPathURL's URLByAppendingPathComponent:(strPlistSubPath) isDirectory:false

#####################################
######plist読み込み
#####################################
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
set listResults to refMe's NSMutableDictionary's dictionaryWithContentsOfURL:ocidFilePathURL |error|:(reference)
set ocidPlistDict to item 1 of listResults

set strModuleName to (ocidPlistDict's valueForKeyPath:"moduleDict.moduleName") as text

if strModuleName is not "Computer Name" then
    #####################################
    ###### 値を変更して
    #####################################
    ocidPlistDict's setValue:"Computer Name" forKeyPath:"moduleDict.moduleName"
    ocidPlistDict's setValue:"/System/Library/Frameworks/ScreenSaver.framework/PlugIns/Computer Name.appex" forKeyPath:"moduleDict.path"
    ocidPlistDict's setValue:0 forKeyPath:"moduleDict.type"
    #####################################
    ###### 保存
    #####################################
    ###書き込み用にバイナリPLISTデータに変換
    set ocidNSbplist to refMe's NSPropertyListBinaryFormat_v1_0
    set ocidPlistEditDataArray to refMe's NSPropertyListSerialization's dataWithPropertyList:ocidPlistDict format:ocidNSbplist options:0 |error|:(reference)
    set ocidPlistEditData to item 1 of ocidPlistEditDataArray
    set boolDone to ocidPlistEditData's writeToURL:ocidFilePathURL options:0 |error|:(reference)
end if

set ocidPlistDict to ""

#####################################
######メッセージの変更
#####################################
set strPlistSubPath to "Containers/com.apple.ScreenSaver.Computer-Name/Data/Library/Preferences/ByHost/com.apple.ScreenSaver.Computer-Name." & strDeviceUUID & ".plist" as text

#####################################
######パス
#####################################
set ocidPathArray to (objFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidUserLibraryPathURL to ocidPathArray's objectAtIndex:0
set ocidFilePathURL to ocidUserLibraryPathURL's URLByAppendingPathComponent:(strPlistSubPath) isDirectory:false

#####################################
######plist読み込み
#####################################
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
set listResults to refMe's NSMutableDictionary's dictionaryWithContentsOfURL:ocidFilePathURL |error|:(reference)
set ocidPlistDict to item 1 of listResults

#####################################
###### 値の変更 -->スクリーンセーバーのメッセージ
#####################################
ocidPlistDict's setValue:strResponse forKeyPath:"MESSAGE"

log ocidPlistDict as record
#####################################
###### 保存
#####################################
###書き込み用にバイナリPLISTデータに変換
set ocidNSbplist to refMe's NSPropertyListBinaryFormat_v1_0
set ocidPlistEditDataArray to refMe's NSPropertyListSerialization's dataWithPropertyList:ocidPlistDict format:ocidNSbplist options:0 |error|:(reference)
set ocidPlistEditData to item 1 of ocidPlistEditDataArray
set boolDone to ocidPlistEditData's writeToURL:ocidFilePathURL options:0 |error|:(reference)


#####CFPreferencesを再起動させて変更後の値をロードさせる
set strCommandText to "/usr/bin/killall cfprefsd" as text
do shell script strCommandText

delay 2


set strCommandText to "/System/Library/CoreServices/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine" as text
do shell script strCommandText



return

set aliasScreenSaverEngine to POSIX file "/System/Library/CoreServices/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine" as alias

tell application "Finder"
    open aliasScreenSaverEngine
end tell





set strCommandText to "open /System/Library/CoreServices/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine" as text
do shell script strCommandText





#####################################
######ファイル名の日付
#####################################
to doGetDateNo(strDateFormat)
    ####日付情報の取得
    set ocidDate to refMe's NSDate's |date|()
    ###日付のフォーマットを定義
    set ocidNSDateFormatter to refMe's NSDateFormatter's alloc()'s init()
    ocidNSDateFormatter's setLocale:(refMe's NSLocale's localeWithLocaleIdentifier:"en_US")
    ocidNSDateFormatter's setDateFormat:strDateFormat
    set ocidDateAndTime to ocidNSDateFormatter's stringFromDate:ocidDate
    set strDateAndTime to ocidDateAndTime as text
    return strDateAndTime
end doGetDateNo


#####################################
###### デバイスUUID 取得
#####################################

to doGetDeviceUUID()
    
    set objFileManager to refMe's NSFileManager's defaultManager()
    
    #####################################
    ######テンポラリフォルダ生成
    #####################################
    set ocidTemporaryDirectoryURL to objFileManager's temporaryDirectory()
    set ocidCleanupAtStartupURL to ocidTemporaryDirectoryURL's URLByAppendingPathComponent:"Cleanup At Startup" isDirectory:true
    ####アクセス権777で作成
    set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
    ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
    objFileManager's createDirectoryAtURL:ocidCleanupAtStartupURL withIntermediateDirectories:true attributes:ocidAttrDict |error|:(reference)
    #####################################
    ######Plist File Path
    #####################################
    set strDateNo to doGetDateNo("yyyyMMddhhmmss")
    set strFileName to strDateNo & ".plist"
    set ocidFilePathURL to ocidCleanupAtStartupURL's URLByAppendingPathComponent:strFileName
    set strFilePath to ocidFilePathURL's |path|() as text
    
    #####################################
    ######コマンド実行
    #####################################
    set strCommandText to "/usr/sbin/ioreg -c IOPlatformExpertDevice -a >> \"" & strFilePath & "\"" as text
    do shell script strCommandText
    
    #####################################
    ######plist読み込み
    #####################################
    set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
    set ocidReadPlistData to refMe's NSMutableDictionary's dictionaryWithContentsOfURL:ocidFilePathURL |error|:(reference)
    set ocidPlistDict to item 1 of ocidReadPlistData
    
    #####################################
    ###### デバイスUUID 取得
    #####################################
    set ocidDeviceUUID to (ocidPlistDict's valueForKeyPath:"IORegistryEntryChildren.IOPlatformUUID")
    
    
    #####################################
    ###### シリアル番号取得
    #####################################
    set ocidSerialNumber to (ocidPlistDict's valueForKeyPath:"IORegistryEntryChildren.IOPlatformSerialNumber")
    
    
    #####################################
    ###### モデル番号
    #####################################
    set ocidEntryName to (ocidPlistDict's valueForKeyPath:"IORegistryEntryChildren.IORegistryEntryName")
    
    return ocidDeviceUUID
    
end doGetDeviceUUID

|

その他のカテゴリー

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