AppleScript NSUUID

[ダイアログ]UUIDを生成する


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

#!/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 ocidUUID to refMe's NSUUID's alloc()'s init()
set strUUID to ocidUUID's UUIDString as text

################################
######ダイアログ
################################
set aliasIconPath to POSIX file "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/FinderIcon.icns" as alias
try
  set recordResponse to (display dialog "UUIDを生成します" with title "UUIDを生成します" default answer strUUID buttons {"クリップボードにコピー", "OK", "キャンセル"} default button "OK" cancel button "キャンセル" with icon aliasIconPath giving up after 20 without hidden answer)
  
on error
  log "エラーしました"
return "エラーしました"
end try
if true is equal to (gave up of recordResponse) then
return "時間切れですやりなおしてください"
end if
if "OK" is equal to (button returned of recordResponse) then
  set strResponse to (text returned of recordResponse) as text
else if button returned of recordResponse is "クリップボードにコピー" then
  set strText to text returned of recordResponse as text
  ####ペーストボード宣言
  set appPasteboard to refMe's NSPasteboard's generalPasteboard()
  ##結果をペーストボードにテキストで入れる
  set ocidText to (refMe's NSString's stringWithString:(strText))
appPasteboard's clearContents()
appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
return
else
  log "キャンセルしました"
return "キャンセルしました"
end if



|

[NSUUID] doUUIDgen()

#!/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 strUUID to doUUIDgen()

log strUUID


set ocidUUID to doUUIDgenOCID()

log ocidUUID as text


###################################

##### UUID生成 TEXT

###################################

to doUUIDgen()

  set ocidConcreteUUID to refMe's NSUUID's UUID()

  set ocidUUIDString to ocidConcreteUUID's UUIDString()

  set strUUIDString to ocidUUIDString as text

  return strUUIDString

end doUUIDgen



###################################

##### UUID生成 ocid

###################################

to doUUIDgenOCID()

  set ocidConcreteUUID to refMe's NSUUID's UUID()

  set ocidUUIDString to ocidConcreteUUID's UUIDString()

  return ocidUUIDString

end doUUIDgenOCID





|

[NSUUID] doUUIDgen()

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


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


log doUUIDgen() as text
-->テキスト形式のUUIDを返します


to doUUIDgen()
set ocidConcreteUUID to refMe's NSUUID's UUID()
set ocidUUIDString to ocidConcreteUUID's UUIDString()
set strUUIDString to ocidUUIDString as text
return strUUIDString
end doUUIDgen

|

[ NSUUID]UUID比較 compare

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


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


set ocidInitUUID to refMe's NSUUID's alloc()'s init()
log ocidInitUUID
log className() of ocidInitUUID as text
-->(*__NSConcreteUUID*)

##8-4-4-4-12
set ocidUUIDNSString to refNSString's stringWithString:"12345678-1234-1234-1234-1234567890aB"
set ocidInitUUIDString to refMe's NSUUID's alloc()'s initWithUUIDString:ocidUUIDNSString
log (ocidInitUUIDString's UUIDString()) as text
-->(*12345678-1234-1234-1234-1234567890AB*)
log className() of ocidInitUUIDString as text
-->(*__NSConcreteUUID*)

set ocidConcreteUUID to refMe's NSUUID's UUID()
log ocidConcreteUUID
log className() of ocidConcreteUUID as text
-->(*__NSConcreteUUID*)

set ocidUUIDString to ocidConcreteUUID's UUIDString()
log ocidUUIDString as text
log className() of ocidUUIDString as text
-->(*__NSCFString*)
set strUUIDString to ocidUUIDString as text


set ocidUUIDcompare to ocidInitUUID's compare:ocidConcreteUUID
-->1
(*
NSComparisonResult
NSOrderedSame:0
NSOrderedAscending:-
NSOrderedDescending+
*)

|

[ NSUUID]UUID生成 init

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


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


set ocidInitUUID to refMe's NSUUID's alloc()'s init()
log ocidInitUUID
log className() of ocidInitUUID as text
-->(*__NSConcreteUUID*)

##8-4-4-4-12
set ocidUUIDNSString to refNSString's stringWithString:"12345678-1234-1234-1234-1234567890aB"
set ocidInitUUIDString to refMe's NSUUID's alloc()'s initWithUUIDString:ocidUUIDNSString
log (ocidInitUUIDString's UUIDString()) as text
-->(*12345678-1234-1234-1234-1234567890AB*)
log className() of ocidInitUUIDString as text
-->(*__NSConcreteUUID*)

set ocidConcreteUUID to refMe's NSUUID's UUID()
log ocidConcreteUUID
log className() of ocidConcreteUUID as text
-->(*__NSConcreteUUID*)

set ocidUUIDString to ocidConcreteUUID's UUIDString()
log ocidUUIDString as text
log className() of ocidUUIDString as text
-->(*__NSCFString*)

set strUUIDString to ocidUUIDString as text

|

[ NSUUID]UUID生成 (いわゆるuuidgen)

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

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



set ocidConcreteUUID to refMe's NSUUID's UUID()
log ocidConcreteUUID
log className() of ocidConcreteUUID as text
-->(*__NSConcreteUUID*)

set ocidUUIDString to ocidConcreteUUID's UUIDString()
log ocidUUIDString as text
log className() of ocidUUIDString as text
-->(*__NSCFString*)

set strUUIDString to ocidUUIDString as text

|

その他のカテゴリー

Acrobat Acrobat Annotation Acrobat Dialog Acrobat Form Acrobat JS Acrobat Open Acrobat Plugin Acrobat python Acrobat Reader Acrobat Sequ Acrobat Stamps Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin System Information Admin Tools Admin Users Admin Volumes Adobe Apple AppleScript AppleScript Guide AppleScript Accessibility AppleScript AppKit AppleScript Applications AppleScript AppStore AppleScript Archive AppleScript Attributes 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 Disk AppleScript do shell script AppleScript Dock AppleScript DropBox AppleScript eMail AppleScript Encode Decode AppleScript Error AppleScript EXIFData AppleScript ffmpeg AppleScript File AppleScript Finder AppleScript Firefox AppleScript Folder AppleScript Fonts AppleScript GIF AppleScript HTML AppleScript Icon AppleScript Illustrator AppleScript Image Events AppleScript Image2PDF AppleScript ImageOptim Applescript iWork AppleScript Javascript AppleScript Jedit AppleScript Json AppleScript Label AppleScript List AppleScript locationd AppleScript LRC AppleScript LSSharedFileList AppleScript m3u8 AppleScript MakePDF AppleScript Map AppleScript Math AppleScript Microsoft AppleScript Microsoft Edge AppleScript Microsoft Excel AppleScript Mobileconfig AppleScript Mouse AppleScript Movie AppleScript Music AppleScript NetWork AppleScript Notes AppleScript NSArray 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 NSFont AppleScript NSFontManager 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 NSPDFImageRep AppleScript NSpoint AppleScript NSPredicate AppleScript NSRange 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 NSUserDefaults AppleScript NSUUID AppleScript NSView AppleScript NSWorkspace AppleScript Numbers AppleScript OAuth AppleScript ObjC AppleScript OneDrive AppleScript Osax AppleScript PDF AppleScript PDFAnnotationWidget AppleScript PDFContext AppleScript PDFDisplayBox AppleScript PDFDocumentPermissions AppleScript PDFKit AppleScript PDFnUP AppleScript PDFOutline AppleScript Photos AppleScript Photoshop AppleScript Plist System Events 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 Sort AppleScript Sound AppleScript Spotlight AppleScript SRT AppleScript StandardAdditions AppleScript stringByApplyingTransform AppleScript System Events AppleScript System Settings AppleScript TemporaryItems AppleScript Terminal AppleScript Text AppleScript Text CSV 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 SVG AppleScript XML TTML AppleScript XML webloc AppleScript YouTube AppleScript Zero Suppress Applications Barcode OnLine Tools CityCode Design iPhone List Logs lsappinfo Memo Music perl PlistBuddy pluginkit postalcode ReadMe SF Symbols character id SF Symbols Entity sips Skype Slack sqlite TCC Tools Typography Video Wacom zoom