AppleScript NSURL

[x-apple-findertag]タグのNSURL


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

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

property refMe : a reference to current application

set itemTagName to "レッド"
###コンポーネント初期化
set ocidURLComponents to refMe's NSURLComponents's alloc()'s init()
###スキーム を追加
ocidURLComponents's setScheme:("x-apple-findertag")
###パスを追加(setHostじゃないよ)
ocidURLComponents's setPath:(itemTagName)
set ocidTagURL to ocidURLComponents's |URL|
log ocidTagURL's absoluteString() as text
-->(*x-apple-findertag:%E3%83%AC%E3%83%83%E3%83%89*)

|

[NSURL] eMailのNSURL


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

#!/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.6"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application

###コンポーネント初期化
set ocidComponents to refMe's NSURLComponents's alloc()'s init()
###スキーム mailtoを追加
ocidComponents's setScheme:("mailto")
###パスを追加(setHostじゃないよ)
ocidComponents's setPath:("foo@mail.hoge.com")
###URLに
set ocidEmailURL to ocidComponents's |URL|
log ocidEmailURL's absoluteString() as text
-->(*mailto:foo@mail.hoge.com*)


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

#!/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.6"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application

###コンポーネント初期化
set ocidEmailComponents to refMe's NSURLComponents's alloc()'s init()
###スキーム mailtoを追加
ocidEmailComponents's setScheme:("mailto" )
###パスを追加(setHostじゃないよ)
ocidEmailComponents's setPath:("foo@hoge.com" )
###クエリー追加
set ocidQueryItemArray to refMe's NSMutableArray's alloc()'s initWithCapacity:0
set ocidQueryItem to refMe's NSURLQueryItem's alloc()'s initWithName:("subject") value:("【件名】よろしくお願いします")
ocidQueryItemArray's addObject:ocidQueryItem
set ocidQueryItem to refMe's NSURLQueryItem's alloc()'s initWithName:("body") value:("お世話になります")
ocidQueryItemArray's addObject:ocidQueryItem
set ocidQueryItem to refMe's NSURLQueryItem's alloc()'s initWithName:("cc") value:("cc@mail.foo.hoge.com")
ocidQueryItemArray's addObject:ocidQueryItem
set ocidQueryItem to refMe's NSURLQueryItem's alloc()'s initWithName:("bcc") value:("bcc@mail.foo.hoge.com")
ocidQueryItemArray's addObject:ocidQueryItem
ocidEmailComponents's setQueryItems:(ocidQueryItemArray)
###URLに
set ocidEmailURL to ocidEmailComponents's |URL|
log ocidEmailURL's absoluteString() as text


|

連番URL


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

#!/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

set ocidURLComponents to refMe's NSURLComponents's alloc()'s init()
ocidURLComponents's setScheme:"https"
ocidURLComponents's setHost:"foo.hoge.com"
ocidURLComponents's setPath:"/some/path/file.html"
set ocidURLStrings to ocidURLComponents's |URL|'s absoluteString()
set ocidURL to refMe's NSURL's alloc()'s initWithString:(ocidURLStrings)

log ocidURL's absoluteString() as text
-->(*https://foo.hoge.com/some/path/file.html*)

log ocidURL's |scheme| as text
log ocidURL's |host| as text
log ocidURL's |path| as text
set ocidExtension to ocidURL's pathExtension

set ocidFileName to ocidURL's lastPathComponent
set ocidBaseFileName to ocidFileName's stringByDeletingPathExtension()
set ocidBaseURL to ocidURL's URLByDeletingLastPathComponent()

set numFileCnt to 1 as integer
repeat 20 times
  ###連番ゼロサプレス
  set strSeroSup to ("000" & (numFileCnt as text)) as text
  set strSeroSup to (text -3 through -1 of strSeroSup) as text
  ###ファイル名に連番つける
  set ocidNewFileName to ocidBaseFileName's stringByAppendingString:(strSeroSup)
  ###拡張子つけて
  set ocidNewFileName to ocidNewFileName's stringByAppendingPathExtension:(ocidExtension)
  ###新しいURLに
  set ocidNewURL to ocidBaseURL's URLByAppendingPathComponent:ocidNewFileName
  log ocidNewURL's absoluteString() as text
  set numFileCnt to numFileCnt + 1 as integer
end repeat

|

[NSURL]URLとヘッダーの分解(CURLとしてコピー)

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos13なので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
property refNSURL : a reference to refMe's NSURL
property refNSData : a reference to refMe's NSData
property refNSMutableString : a reference to refMe's NSMutableString
property refNSMutableArray : a reference to refMe's NSMutableArray


property refNSPasteboard : a reference to refMe's NSPasteboard
set ocidPasteboard to refNSPasteboard's generalPasteboard()

###クリックボードの中のURLを取得
set ocidPasteboardTypeString to ocidPasteboard's stringForType:(refMe's NSPasteboardTypeString)

##可変テキスト形式で格納
set ocidCurlURL to refNSMutableString's alloc()'s initWithCapacity:0
ocidCurlURL's setString:ocidPasteboardTypeString

if (ocidCurlURL as text) starts with "curl" then
log "処理開始"
set ocidDoSeparateURLArrayM to doSeparateURL(ocidCurlURL)
else
return "CURLとしてコピーしてください"
end if

log (item 1 of ocidDoSeparateURLArrayM)'s absoluteString() as text
log (item 2 of ocidDoSeparateURLArrayM)'s absoluteString() as text
log item 3 of ocidDoSeparateURLArrayM as text
log item 4 of ocidDoSeparateURLArrayM as text




to doSeparateURL(ocidCurlURL)
###戻り値用のリスト
set ocidDoSeparateURLArrayM to refNSMutableArray's alloc()'s initWithCapacity:0

###改行を取る
set ocidCurlURLLength to ocidCurlURL's |length|()
set ocidCurlURLRange to {location:0, |length|:ocidCurlURLLength}
ocidCurlURL's replaceOccurrencesOfString:("\n") withString:("") options:(refMe's NSRegularExpressionSearch) range:ocidCurlURLRange
###'』でリスト化して2番目がURL
set ocidDelimiters to (refMe's NSCharacterSet)'s characterSetWithCharactersInString:"'"
set ocidCurlURLArray to ocidCurlURL's componentsSeparatedByCharactersInSet:ocidDelimiters

###URL確定(クエリー入り)
set ocidURLString to ocidCurlURLArray's objectAtIndex:1
set ocidURL to refNSURL's URLWithString:ocidURLString
log ocidURL's absoluteString() as text
ocidDoSeparateURLArrayM's addObject:ocidURL

###URL部分(クエリー無し)
set ocidURLComponents to (refMe's NSURLComponents)'s componentsWithURL:ocidURL resolvingAgainstBaseURL:true
ocidURLComponents's setQueryItems:(missing value)
set ocidBaseURL to ocidURLComponents's |URL|
log ocidBaseURL's absoluteString() as text
ocidDoSeparateURLArrayM's addObject:ocidBaseURL

###クエリー部分
set ocidQueryName to ocidURL's query()
log ocidQueryName as text
if ocidQueryName is missing value then
ocidDoSeparateURLArrayM's addObject:""
else
ocidDoSeparateURLArrayM's addObject:ocidQueryName
end if
###ヘッダー部処理
set ocidDelimiters to (refMe's NSCharacterSet)'s characterSetWithCharactersInString:"\\"
set ocidHeaderArray to ocidCurlURL's componentsSeparatedByCharactersInSet:ocidDelimiters
set ocidHeaderArrayLength to ocidHeaderArray's |count|()
set ocidHeaderRange to refMe's NSMakeRange(1, (ocidHeaderArrayLength - 1))
set ocidSubbArray to ocidHeaderArray's subarrayWithRange:ocidHeaderRange
set ocidHeaderText to (ocidSubbArray's componentsJoinedByString:"")

log ocidHeaderText as text
ocidDoSeparateURLArrayM's addObject:ocidHeaderText
###値を戻す
return ocidDoSeparateURLArrayM

end doSeparateURL

|

[NSURL]URLとヘッダーの分解(CURLとしてコピー)

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos13なので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
property refNSURL : a reference to refMe's NSURL
property refNSData : a reference to refMe's NSData
property refNSMutableString : a reference to refMe's NSMutableString

property refNSPasteboard : a reference to refMe's NSPasteboard
set ocidPasteboard to refNSPasteboard's generalPasteboard()

###クリックボードの中のURLを取得
set ocidPasteboardTypeString to ocidPasteboard's stringForType:(refMe's NSPasteboardTypeString)

##可変テキスト形式で格納
set ocidCurlURL to refNSMutableString's alloc()'s initWithCapacity:0
ocidCurlURL's setString:ocidPasteboardTypeString

if (ocidCurlURL as text) starts with "curl" then
log "処理開始"
else
return "CURLとしてコピーしてください"
end if

###改行を取る
set ocidCurlURLLength to ocidCurlURL's |length|()
set ocidCurlURLRange to {location:0, |length|:ocidCurlURLLength}
ocidCurlURL's replaceOccurrencesOfString:("\n") withString:("") options:(refMe's NSRegularExpressionSearch) range:ocidCurlURLRange

###'』でリスト化して2番目がURL
set ocidDelimiters to (refMe's NSCharacterSet)'s characterSetWithCharactersInString:"'"
set ocidCurlURLArray to ocidCurlURL's componentsSeparatedByCharactersInSet:ocidDelimiters

###URL確定(クエリー入り)
set ocidURLString to ocidCurlURLArray's objectAtIndex:1
set ocidURL to refNSURL's URLWithString:ocidURLString
log ocidURL's absoluteString() as text

###URL部分(クエリー無し)
set ocidURLComponents to (refMe's NSURLComponents)'s componentsWithURL:ocidURL resolvingAgainstBaseURL:true
ocidURLComponents's setQueryItems:(missing value)
set ocidBaseURL to ocidURLComponents's |URL|
log ocidBaseURL's absoluteString() as text

###クエリー部分
set ocidQueryName to ocidURL's query()
log ocidQueryName as text

###ヘッダー部
set ocidDelimiters to (refMe's NSCharacterSet)'s characterSetWithCharactersInString:"\\"
set ocidHeaderArray to ocidCurlURL's componentsSeparatedByCharactersInSet:ocidDelimiters
set ocidHeaderArrayLength to ocidHeaderArray's |count|()
set ocidHeaderRange to refMe's NSMakeRange(1, (ocidHeaderArrayLength - 1))
set ocidSubbArray to ocidHeaderArray's subarrayWithRange:ocidHeaderRange
set ocidHeaderText to (ocidSubbArray's componentsJoinedByString:"")

log ocidHeaderText as text
return

























to doGetErrorData(ocidNSErrorData)
#####個別のエラー情報
log "エラーコード:" & ocidNSErrorData's code() as text
log "エラードメイン:" & ocidNSErrorData's domain() as text
log "Description:" & ocidNSErrorData's localizedDescription() as text
log "FailureReason:" & ocidNSErrorData's localizedFailureReason() as text
log ocidNSErrorData's localizedRecoverySuggestion() as text
log ocidNSErrorData's localizedRecoveryOptions() as text
log ocidNSErrorData's recoveryAttempter() as text
log ocidNSErrorData's helpAnchor() as text
set ocidNSErrorUserInfo to ocidNSErrorData's userInfo()
set ocidAllValues to ocidNSErrorUserInfo's allValues() as list
set ocidAllKeys to ocidNSErrorUserInfo's allKeys() as list
repeat with ocidKeys in ocidAllKeys
if (ocidKeys as text) is "NSUnderlyingError" then
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s localizedDescription() as text
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s localizedFailureReason() as text
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s localizedRecoverySuggestion() as text
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s localizedRecoveryOptions() as text
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s recoveryAttempter() as text
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s helpAnchor() as text
else
####それ以外の値はそのままテキストで読める
log (ocidKeys as text) & ": " & (ocidNSErrorUserInfo's valueForKey:ocidKeys) as text
end if
end repeat

end doGetErrorData

|

[NSURL] initWithString URLの組み立て

#!/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

######ログ表示
doLogView()

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSMutableString : a reference to objMe's NSMutableString
property objNSURL : a reference to objMe's NSURL
property objNSURLComponents : a reference to objMe's NSURLComponents
property objNSNotFound : a reference to 9.22337203685477E+18 + 5807


###空のテキスト
set ocidURLstring to objNSString's stringWithString:""
log ocidURLstring as text
log className() of ocidURLstring as text

###空のNSURL
set ocidNSURLinit to objNSURL's alloc()'s initWithString:ocidURLstring
log ocidNSURLinit's absoluteString() as text
log className() of ocidNSURLinit as text

####NSURLComponentsも初期化
set ocidNewURLComponents to objNSURLComponents's alloc()'s init()
log ocidNewURLComponents as list
log className() of ocidNewURLComponents as text


###スキーム追加
ocidNewURLComponents's setScheme:"https"
log ocidNewURLComponents's |scheme| as text
log className() of ocidNewURLComponents as text

####ホスト名追加
ocidNewURLComponents's setHost:"server1.www.aaa.co.jp"
log ocidNewURLComponents's |host| as text
log className() of ocidNewURLComponents as text

####ポート番号追加-->ここだけ数値
ocidNewURLComponents's setPort:8080
log ocidNewURLComponents's |port| as text
log className() of ocidNewURLComponents as text

####パス追加-->拡張子の追加はできない
ocidNewURLComponents's setPath:"/dir1/dir2/dir3/file.exe"
log ocidNewURLComponents's |path| as text
log className() of ocidNewURLComponents as text

####サーバー認証ユーザー名
ocidNewURLComponents's setUser:"MyName"
log ocidNewURLComponents's user as text
log className() of ocidNewURLComponents as text

####サーバー認証パスワード
ocidNewURLComponents's setPassword:"1234"
log ocidNewURLComponents's |password| as text
log className() of ocidNewURLComponents as text

####クエリー追加
ocidNewURLComponents's setQuery:"AAA=BBB&CCCC=DDD"
log ocidNewURLComponents's query as text
log className() of ocidNewURLComponents as text

####フラグメント-->アンカー追加
ocidNewURLComponents's setFragment:"Anchor"
log ocidNewURLComponents's fragment as text
log className() of ocidNewURLComponents as text

###ここまでのURLを表示
set strNewURL to ocidNewURLComponents's |URL|'s absoluteString()
log strNewURL as text
log className() of strNewURL as text



############
#NSURLQueryItemを使っての追加

####クエリーの内容を定義
set ocidURLQueryItemA to objMe's NSURLQueryItem's queryItemWithName:"AAA" value:"BBB"
log ocidURLQueryItemA's query as record
log className() of ocidURLQueryItemA as text

####クエリーの内容を定義
set ocidURLQueryItemB to objMe's NSURLQueryItem's queryItemWithName:"CCC" value:"DDD"
log ocidURLQueryItemB's query as record
log className() of ocidURLQueryItemB as text

###クエリーを追加
ocidNewURLComponents's setQueryItems:{ocidURLQueryItemA, ocidURLQueryItemB}
log ocidNewURLComponents's query as text
log className() of ocidNewURLComponents as text

set strNewURL to ocidNewURLComponents's |URL|'s absoluteString()
log strNewURL as text
log className() of strNewURL as text








#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
end if
end repeat

end doLogView
#########################

|

[NSURL]基本的な処理

#!/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

######ログ表示
doLogView()

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSURL : a reference to objMe's NSURL


set strURL to "https://aaaa.bbbb.cccc.co.jp/DDDD/EEEE/FFFFF.exe?GGGG=HHH&IIII=JJJJ"


####テキストをNSURL
set ocidURL to objNSURL's URLWithString:strURL
log ocidURL's absoluteString() as text
log className() of ocidURL as text
-->(*NSURL*)

####パスコンポーネント
set ocidPathComponent to ocidURL's pathComponents()
log ocidPathComponent as list
log className() of ocidPathComponent as text
-->((*/, DDDD, EEEE, FFFFF.exe*)
-->((*__NSArrayM*)

########
## スキーマ
set ocidSchemeName to ocidURL's |scheme|()
log ocidSchemeName as text
log className() of ocidSchemeName as text
-->(*https*)
-->((*__NSCFConstantString*)

########
###スキーマを抜いたURL
set ocidNSURLResourceSpecifier to ocidURL's resourceSpecifier()
log ocidNSURLResourceSpecifier as text
log className() of ocidNSURLResourceSpecifier as text
-->(*__NSCFString*)
-->(*//aaaa.bbbb.cccc.co.jp/DDDD/EEEE/FFFFF.exe?GGGG=HHH&IIII=JJJJ*)

########
## ホスト名
set ocidHostName to ocidURL's |host|()
log ocidHostName as text
log className() of ocidHostName as text
-->(*aaaa.bbbb.cccc.co.jp*)
-->(*__NSCFString*)

########
## パス
set ocidPath to ocidURL's |path|()
log ocidPath as text
log className() of ocidPath as text
-->(*/DDDD/EEEE/FFFFF.exe*)
-->(*__NSCFString*)

########
## 最後のコンポーネント
set ocidLastPathComponent to ocidURL's lastPathComponent()
log ocidLastPathComponent as text
log className() of ocidLastPathComponent as text
-->(*FFFFF.exe*)
-->(*NSPathStore2*)

########
## クエリー
set ocidQueryName to ocidURL's query()
log ocidQueryName as text
log className() of ocidQueryName as text
-->(*GGGG=HHH&IIII=JJJJ*)
-->(*__NSConcreteURLComponents*)



###拡張子削除
set ocidDeleteExtension to ocidURL's URLByDeletingPathExtension
log ocidDeleteExtension's absoluteString() as text
log className() of ocidDeleteExtension as text
-->(*https://aaaa.bbbb.cccc.co.jp/DDDD/EEEE/FFFFF?GGGG=HHH&IIII=JJJJ*)
-->(*NSURL*)

set ocidAppendingExtension to ocidDeleteExtension's URLByAppendingPathExtension:"php"
log ocidAppendingExtension's absoluteString() as text
log className() of ocidDeleteExtension as text
-->(*https://aaaa.bbbb.cccc.co.jp/DDDD/EEEE/FFFFF.php?GGGG=HHH&IIII=JJJJ*)
-->(*NSURL*)

###最後のURLコンポーネントを削除
set ocidDeleteLastPath to ocidURL's URLByDeletingLastPathComponent
log ocidDeleteLastPath's absoluteString() as text
log className() of ocidDeleteLastPath as text
-->(*https://aaaa.bbbb.cccc.co.jp/DDDD/EEEE/?GGGG=HHH&IIII=JJJJ*)
-->(*NSURL*)

###URLコンポーネントを追加
set ocidAppendingLastPath to ocidDeleteLastPath's URLByAppendingPathComponent:"FFFFF"
log ocidAppendingLastPath's absoluteString() as text
log className() of ocidDeleteLastPath as text
-->(*https://aaaa.bbbb.cccc.co.jp/DDDD/EEEE/FFFFF?GGGG=HHH&IIII=JJJJ*)
-->(*NSURL*)

###resourceSpecifier()
set ocidDeleteLastPath to ocidAppendingLastPath's resourceSpecifier()
log ocidDeleteLastPath as text
log className() of ocidDeleteLastPath as text



################################################
####コンポーネントに格納
set ocidURLComponents to objMe's NSURLComponents's componentsWithURL:ocidURL resolvingAgainstBaseURL:true
log className() of ocidURLComponents as text
-->(*__NSConcreteURLComponents*)

####クエリー部分を削除
ocidURLComponents's setQueryItems:(missing value)
set strBaseURL to ocidURLComponents's |URL|'s absoluteString() as text
log class of strBaseURL as text
log strBaseURL
-->(*text*)
-->(*https://aaaa.bbbb.cccc.co.jp/DDDD/EEEE/FFFFF.exe*)

####テキストになるのでNSURL
set ocidbaseURL to objNSURL's URLWithString:strBaseURL
log className() of ocidbaseURL as text
-->(*NSURL*)

####拡張子
set ocidExtensionName to ocidbaseURL's pathExtension()
log ocidExtensionName as text
log className() of ocidExtensionName as text
-->(*exe*)
-->(*NSPathStore2 =パスの一部分として格納されているnotテキスト*)




#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
end if
end repeat

end doLogView
#########################

|

[NSURL] pathExtension 拡張子の取得

#!/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

######ログ表示
doLogView()

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSURL : a reference to objMe's NSURL


set strURL to "https://developer.apple.com/documentation/foundation/nsurl.exe?AAAA=BBBB"


set ocidURL to objNSURL's URLWithString:strURL
log className() of ocidURL as text

set ocidURLComponents to objMe's NSURLComponents's componentsWithURL:ocidURL resolvingAgainstBaseURL:true
log className() of ocidURLComponents as text
log ocidURLComponents's |URL|'s absoluteString() as text

ocidURLComponents's setQueryItems:(missing value)
log className() of ocidURLComponents as text


ocidURLComponents's |URL|'s absoluteString()
log className() of ocidURLComponents as text

set strBaseURL to ocidURLComponents's |URL|'s absoluteString() as text
log class of strBaseURL as text

set ocidBaseURL to objNSURL's URLWithString:strBaseURL
log className() of ocidBaseURL as text


log ocidBaseURL's pathExtension() as text

#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
end if
end repeat

end doLogView
#########################

|

[NSURLComponents]setQueryItems:(missing value) URLのクエリー部分を削除

#!/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

######ログ表示
doLogView()

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSURL : a reference to objMe's NSURL


set strURL to "https://developer.apple.com/documentation/foundation/nsurl?AAAA=BBBB"


set ocidURL to objNSURL's URLWithString:strURL
log className() of ocidURL as text

set ocidURLComponents to objMe's NSURLComponents's componentsWithURL:ocidURL resolvingAgainstBaseURL:true
log className() of ocidURLComponents as text
log ocidURLComponents's |URL|'s absoluteString() as text

ocidURLComponents's setQueryItems:(missing value)
log className() of ocidURLComponents as text


ocidURLComponents's |URL|'s absoluteString()
log className() of ocidURLComponents as text
log ocidURLComponents's |URL|'s absoluteString() as text



#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
end if
end repeat

end doLogView
#########################

|

[NSURL] resourceSpecifier

#!/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

######ログ表示
doLogView()

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSURL : a reference to objMe's NSURL


set strURL to "https://developer.apple.com/documentation/foundation/nsurl"


set ocidNSURL to objNSURL's URLWithString:strURL
log className() of ocidNSURL as text

set ocidNSURLResourceSpecifier to ocidNSURL's resourceSpecifier()
log className() of ocidNSURLResourceSpecifier as text
log ocidNSURLResourceSpecifier as text



#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
end if
end repeat

end doLogView
#########################

|

より以前の記事一覧

その他のカテゴリー

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