AppleScript Map

地名検索を修正しました

https://github.com/force4u/AppleScript/blob/main/Script%20Menu/Documents/%E5%9C%B0%E5%90%8D%E6%A4%9C%E7%B4%A2/%E5%9C%B0%E5%90%8D%E6%A4%9C%E7%B4%A2.applescript

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


##通常
set strHostName to ("news.yahoo.co.jp") as text

try
  ##オプリョン -c 1 1回だけ送信 -t 2 タイムアウト2秒
  set strCommandText to ("/sbin/ping -c 1 \"" & strHostName & "\" -t 2 &> /dev/null") as text
log (do shell script strCommandText) as text
on error strMes number numErrorNo
  if numErrorNo is 2 then
log strMes
log strHostName & "は名前解決は出来ましたがpingに応答しなかった"
  else if numErrorNo is 68 then
log strHostName
log strHostName & "は名前解決できないのでドメイン落ちしています"
  end if
end try

##名前解決できない場合
set strHostName to ("bahoo.co.jp") as text

try
  set strCommandText to ("/sbin/ping -c 1 \"" & strHostName & "\" -t 2 &> /dev/null") as text
log (do shell script strCommandText) as text
on error strMes number numErrorNo
  if numErrorNo is 2 then
log strMes
log strHostName & "は名前解決は出来ましたがpingに応答しなかった"
  else if numErrorNo is 68 then
log strHostName
log strHostName & "は名前解決できないのでドメイン落ちしています"
  end if
end try

##pingに応答しないケース
set strHostName to ("yahoo.hatena.com") as text

try
  set strCommandText to ("/sbin/ping -c 1 \"" & strHostName & "\" -t 2 &> /dev/null") as text
log (do shell script strCommandText) as text
on error strMes number numErrorNo
  if numErrorNo is 2 then
log strMes
log strHostName & "は名前解決は出来ましたがpingに応答しなかった"
  else if numErrorNo is 68 then
log strHostName
log strHostName & "は名前解決できないのでドメイン落ちしています"
  end if
end try



|

駅名検索修正

リンクにGoogleMapを追加しました https://github.com/force4u/AppleScript/tree/main/Script%20Menu/Documents/ekidata.jp%E9%A7%85%E5%90%8D%E6%A4%9C%E7%B4%A2

|

[Map]Chromeで開く

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



tell application "Maps"
    activate
end tell

set strURL to ""
doCopyMap()
set strURL to (the clipboard) as text

################################
######ペーストボードを取得
################################
##set ocidPasteboard to refMe's NSPasteboard's generalPasteboard()
#####テキストとして受け取る
##set ocidReadPasteboardTypeString to ocidPasteboard's stringForType:(refMe's NSPasteboardTypeString)
##set strURL to ocidReadPasteboardTypeString as text

################################################
###### URL部分
################################################
set coidURLStr to refMe's NSString's stringWithString:strURL
set coidURL to refMe's NSURL's URLWithString:coidURLStr
set ocidComponents to refMe's NSURLComponents's alloc()'s initWithURL:coidURL resolvingAgainstBaseURL:false



################################################
###### ホスト名取り出し
################################################
set ocidHostName to ocidComponents's |host|()
set strHostName to ocidHostName as text
####処理分岐するなら
if strHostName contains "maps.apple.com" then
    log "AppleMap"
    set ocidGeoLLArray to doGetLLappleMap(coidURL)
    set strLatitude to (ocidGeoLLArray's objectAtIndex:0) as text
    set strLongitude to (ocidGeoLLArray's objectAtIndex:1) as text
else
    log "他サービス"
    return "緯度経度値を取得できません"
end if

log strLatitude
log strLongitude

set strURL to "https://www.google.com/maps/@" & strLatitude & "," & strLongitude & ",17z/"

################################################
###### ブラウザで開く
################################################

tell application "Google Chrome"
    activate
    set URL of active tab of front window to strURL
end tell



################################################
###### サブルーチン
################################################

###################################################
###AppleMap処理
to doGetLLappleMap(argURL)
    
    ################################################
    ###### URLをコンポーネントに
    ################################################
    set ocidComponents to refMe's NSURLComponents's alloc()'s initWithURL:argURL resolvingAgainstBaseURL:false
    
    ################################################
    ###### コンポーネントからクエリーを取り出し
    ################################################
    set ocidURLQueryArray to ocidComponents's queryItems()
    
    ################################################
    ###### クエリーをレコードに
    ################################################
    ###格納用の可変ディクショナリ
    set ocidQueryDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
    ###クエリーの数だけ繰り返し
    repeat with itemURLQueryArray in ocidURLQueryArray
        ###KEY
        set ocidQueryKey to itemURLQueryArray's |name|()
        ####値
        set ocidQueryValue to itemURLQueryArray's value()
        ####ディクショナリに格納
        (ocidQueryDict's setObject:ocidQueryValue forKey:ocidQueryKey)
    end repeat
    
    ################################################
    ######  キーで値を取り出す
    ################################################
    ###緯度経度取得
    set ocidGeoLL to (ocidQueryDict's valueForKey:"ll")
    ###カンマで区切ってArrayにして
    set ocidGeoLLArray to ocidGeoLL's componentsSeparatedByString:","
    
    ###戻り値はArrayのまま戻す
    return ocidGeoLLArray
    
    
    (*     ##値を取り出す時は
    set strLatitude to (ocidGeoLLArray's objectAtIndex:0) as text
    set strLongitude to (ocidGeoLLArray's objectAtIndex:1) as text
    *)
    
end doGetLLappleMap


###################################################
### Mapのコピー処理


to doCopyMap()
    tell application "System Events"
        launch
    end tell
    tell application "Maps"
        activate
    end tell
    try
        tell application "System Events"
            tell process "Maps"
                ##    get every menu bar
                tell menu bar 1
                    ##    get every menu bar item
                    tell menu bar item "編集"
                        ##    get every menu bar item
                        tell menu "編集"
                            ##    get every menu item
                            tell menu item "リンクをコピー"
                                click
                            end tell
                        end tell
                    end tell
                end tell
            end tell
        end tell
        tell application "System Events"
            tell process "Maps"
                ##    get every menu bar
                tell menu bar 1
                    ##    get every menu bar item
                    tell menu bar item "編集"
                        ##    get every menu bar item
                        tell menu "編集"
                            ##    get every menu item
                            tell menu item "リンクをコピー"
                                click
                            end tell
                        end tell
                    end tell
                end tell
            end tell
        end tell
    on error
        try
            tell application "System Events"
                tell process "Maps"
                    get every menu bar
                    tell menu bar 1
                        get every menu bar item
                        tell menu bar item "編集"
                            get every menu bar item
                            tell menu "編集"
                                get every menu item
                                tell menu item "コピー"
                                    click
                                end tell
                            end tell
                        end tell
                    end tell
                end tell
            end tell
            tell application "System Events"
                tell process "Maps"
                    get every menu bar
                    tell menu bar 1
                        get every menu bar item
                        tell menu bar item "編集"
                            get every menu bar item
                            tell menu "編集"
                                get every menu item
                                tell menu item "コピー"
                                    click
                                end tell
                            end tell
                        end tell
                    end tell
                end tell
            end tell
        end try
    end try
end doCopyMap

|

[map]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 ocidPasteboard to refMe's NSPasteboard's generalPasteboard()
#####テキストとして受け取る
set ocidReadPasteboardTypeString to ocidPasteboard's stringForType:(refMe's NSPasteboardTypeString)


set strURL to "https://maps.apple.com/?ll=35.658558,139.745504"

set strURL to "https://www.google.com/maps/@35.6585805,139.7454329,17z/"


################################################
###### URL部分
################################################
set coidURLStr to refMe's NSString's stringWithString:strURL
set coidURL to refMe's NSURL's URLWithString:coidURLStr
set ocidComponents to refMe's NSURLComponents's alloc()'s initWithURL:coidURL resolvingAgainstBaseURL:false



################################################
###### ホスト名取り出し
################################################
set ocidHostName to ocidComponents's |host|()
set strHostName to ocidHostName as text
####処理分岐するなら
if strHostName contains "maps.apple.com" then
    log "AppleMap"
    set ocidGeoLLArray to doGetLLappleMap(coidURL)
    set strLatitude to (ocidGeoLLArray's objectAtIndex:0) as text
    set strLongitude to (ocidGeoLLArray's objectAtIndex:1) as text
else if strHostName contains "google.com" then
    log "GoogleMap"
    set ocidGeoLLArray to doGetLLgooleMap(coidURL)
    set strLatitude to (ocidGeoLLArray's objectAtIndex:1) as text
    set strLongitude to (ocidGeoLLArray's objectAtIndex:2) as text
else
    log "他サービス"
    return "緯度経度値を取得できません"
end if

log strLatitude
log strLongitude



################################################
###### サブルーチン
################################################

###################################################
###Googlemap処理

to doGetLLgooleMap(argURL)
    
    ################################################
    ###### URLをコンポーネントに
    ################################################
    set ocidComponents to refMe's NSURLComponents's alloc()'s initWithURL:argURL resolvingAgainstBaseURL:false
    
    ################################################
    ###### パスを取り出し
    ################################################
    set ocidPathComponent to ocidComponents's |path|()
    ###格納用の可変Array
    set ocidPathArray to refMe's NSMutableArray's alloc()'s initWithCapacity:0
    ###カンマで区切ってArrayにして
    set ocidPathArray to ocidPathComponent's componentsSeparatedByString:"/"
    ###クエリーの数だけ繰り返し
    repeat with itemPathArray in ocidPathArray
        set strItemPathArray to itemPathArray as text
        ###対象のパスアイテムを取得
        if strItemPathArray starts with "@" then
            set strGeoLL to strItemPathArray as text
        end if
    end repeat
    ################################################
    ###### 必要なデータのみ取り出す
    ################################################
    #####区切り文字指定
    set ocidLineEndChrSet to refMe's NSCharacterSet's characterSetWithCharactersInString:"@,z"
    ###テキストを戻して
    set ocidGeoLL to refMe's NSString's stringWithString:strGeoLL
    ###区切り文字でリストに
    set ocidGeoLLArray to ocidGeoLL's componentsSeparatedByCharactersInSet:ocidLineEndChrSet
    
    ###戻り値はArrayのまま戻す
    return ocidGeoLLArray
    (* 値を取り出す時は
        ##値を取り出す
    set strLatitude to (ocidGeoLLArray's objectAtIndex:1) as text
    set strLongitude to (ocidGeoLLArray's objectAtIndex:2) as text
    *)
end doGetLLgooleMap

###################################################
###AppleMap処理
to doGetLLappleMap(argURL)
    
    ################################################
    ###### URLをコンポーネントに
    ################################################
    set ocidComponents to refMe's NSURLComponents's alloc()'s initWithURL:argURL resolvingAgainstBaseURL:false
    
    ################################################
    ###### コンポーネントからクエリーを取り出し
    ################################################
    set ocidURLQueryArray to ocidComponents's queryItems()
    
    ################################################
    ###### クエリーをレコードに
    ################################################
    ###格納用の可変ディクショナリ
    set ocidQueryDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
    ###クエリーの数だけ繰り返し
    repeat with itemURLQueryArray in ocidURLQueryArray
        ###KEY
        set ocidQueryKey to itemURLQueryArray's |name|()
        ####値
        set ocidQueryValue to itemURLQueryArray's value()
        ####ディクショナリに格納
        (ocidQueryDict's setObject:ocidQueryValue forKey:ocidQueryKey)
    end repeat
    
    ################################################
    ######  キーで値を取り出す
    ################################################
    ###緯度経度取得
    set ocidGeoLL to (ocidQueryDict's valueForKey:"ll")
    ###カンマで区切ってArrayにして
    set ocidGeoLLArray to ocidGeoLL's componentsSeparatedByString:","
    
    ###戻り値はArrayのまま戻す
    return ocidGeoLLArray
    
    
    (*     ##値を取り出す時は
    set strLatitude to (ocidGeoLLArray's objectAtIndex:0) as text
    set strLongitude to (ocidGeoLLArray's objectAtIndex:1) as text
    *)
    
end doGetLLappleMap


|

[Maps]Mapの場所をChromeで開き直す

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

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSURL : a reference to objMe's NSURL
##
property objNSDictionary : a reference to objMe's NSDictionary
property objNSMutableDictionary : a reference to objMe's NSMutableDictionary
property objNSArray : a reference to objMe's NSArray
property objNSMutableArray : a reference to objMe's NSMutableArray


############################
###コピーのサブへ
doCopyMap()
############################
###クリップボードからURLを取得する
tell application "Finder"
set theURL to (the clipboard) as text
end tell
set strURL to theURL as text
############################
##値がコピー出来なかったときエラーになるので
##ここはトライ
try
####################################
###URLNSURLに格納
set ocidURL to objNSURL's alloc's initWithString:strURL
log className() of ocidURL as text
--> NSURL
####################################
###クエリー部を取り出し
set ocidQueryUrl to ocidURL's query
log className() of ocidQueryUrl as text
--> __NSCFString
log ocidQueryUrl as text
on error
###エラーしたらコピー取り直し
tell application "System Events"
tell process "Maps"
##get every menu bar
tell menu bar 1
##get every menu bar item
tell menu bar item "編集"
##get every menu bar item
tell menu "編集"
##get every menu item
tell menu item "リンクをコピー"
click
end tell
end tell
end tell
end tell
end tell
end tell
tell application "Finder"
set theURL to (the clipboard) as text
end tell
####################################
###URLNSURLに格納
set ocidURL to objNSURL's alloc's initWithString:strURL
log className() of ocidURL as text
--> NSURL
####################################
###クエリー部を取り出し
set ocidQueryUrl to ocidURL's query
log className() of ocidQueryUrl as text
--> __NSCFString
log ocidQueryUrl as text
end try

####################################
###取り出したクエリを&を区切り文字でリストに
set ocidArrayComponent to (ocidQueryUrl's componentsSeparatedByString:"&")
log className() of ocidArrayComponent as text
--> __NSArrayM
log ocidArrayComponent as list

####################################
####可変レコードを作成
set ocidRecordQuery to objNSMutableDictionary's alloc()'s init()
####値が空のレコードを定義
set recordQuery to {t:"", q:"", address:"", near:"", ll:"", z:"18", spn:"", saddr:"", daddr:"", dirflg:"", sll:"", sspn:"", ug:""} as record
####↑の定義で値が空の可変レコードを作成
set ocidRecordQuery to objNSMutableDictionary's dictionaryWithDictionary:recordQuery
####################################
###ここからクエリー分繰り返し
repeat with objArrayComponent in ocidArrayComponent
#####渡されたクエリーを=を境に分割してArray=リストにする
set ocidArrayFirstObject to (objArrayComponent's componentsSeparatedByString:"=")

####まずは順番に キー と 値 で格納
set ocidKey to item 1 of ocidArrayFirstObject
log ocidKey as text

set ocidValue to item 2 of ocidArrayFirstObject
log ocidValue as text

#########位置情報 緯度 経度
if (ocidKey as text) = "ll" then
set ll of ocidRecordQuery to ocidValue
####カンマでわけて緯度 経度に
set ocidArrayLL to (ocidValue's componentsSeparatedByString:",")
log ocidArrayLL as list
###最初の項目
set ocidLatitude to item 1 of ocidArrayLL
log "Latitude:" & ocidLatitude as text
###あとの項目
set ocidLongitude to item 2 of ocidArrayLL
log "Longitude:" & ocidLongitude as text

#########Address String 住所
else if (ocidKey as text) = "address" then
set address of ocidRecordQuery to ocidValue
set ocidAddEnc to ocidValue's stringByRemovingPercentEncoding
log "AddressString:" & ocidAddEnc as text

#########The zoom level. 高さ方向
else if (ocidKey as text) = "z" then
set z of ocidRecordQuery to ocidValue
set ocidZoomValue to ocidValue
log "ZoomValue:" & ocidZoomValue

#########マップビュー
else if (ocidKey as text) = "t" then
set t of ocidRecordQuery to ocidValue
set ocidMapType to ocidValue
log "MapType:" & ocidMapType
(*
m (standard view)
k (satellite view)
h (hybrid view)
r (transit view)
goole
map_action=pano
map_action=map
basemap=satellite
terrain
roadmap
*)
####################################
#########dirflg 移動方法
else if (ocidKey as text) = "dirflg" then
set dirflg of ocidRecordQuery to ocidValue
set ocidDirflgType to ocidValue
log "DirflgType:" & ocidDirflgType
(*
d (by car)
w (by foot)
r (by public transit)

goole
travelmode=driving
walking
transit
*)

#########Dirflg Parameters 出発点
else if (ocidKey as text) = "saddr" then
set saddr of ocidRecordQuery to ocidValue
set strSaddrEnc to ocidValue as text
set ocidSaddrEnc to ocidValue's stringByRemovingPercentEncoding
log "StartingPoint:" & ocidSaddrEnc as text

#########Destination 到着店
else if (ocidKey as text) = "daddr" then
set daddr of ocidRecordQuery to ocidValue
set strDaddrEnc to ocidValue as text
set ocidDaddrEnc to ocidValue's stringByRemovingPercentEncoding
log "DestinationPoint:" & ocidDaddrEnc as text

#########Search Query 検索語句
else if (ocidKey as text) = "q" then
set q of ocidRecordQuery to ocidValue
set strRecordQuery to ocidValue as text
set ocidSearchQueryEnc to ocidValue's stringByRemovingPercentEncoding
log "SearchQuery" & ocidSearchQueryEnc as text

####################################
#########語句検索時の周辺情報の有無による分岐

else if (ocidKey as text) = "sll" then
set sll of ocidRecordQuery to ocidValue
####カンマでわけて緯度 経度に
set ocidSearchArrayLL to (ocidValue's componentsSeparatedByString:",")
log ocidSearchArrayLL as list
####最初の項目
set ocidNearLatitude to item 1 of ocidSearchArrayLL
log "NearLatitude:" & ocidNearLatitude as text
####あとの項目
set ocidNearLongitude to item 2 of ocidSearchArrayLL
log "NearNearLongitude:" & ocidNearLongitude as text

else if (ocidKey as text) = "spn" then
####周囲情報の範囲
set spn of ocidRecordQuery to ocidValue


####################################
#########during search周辺 位置情報 緯度 経度

else if (ocidKey as text) = "near" then
set near of ocidRecordQuery to ocidValue
####カンマでわけて緯度 経度に
set ocidNearArrayLL to (ocidValue's componentsSeparatedByString:",")
log ocidNearArrayLL as list
###最初の項目
set ocidNearLatitude to item 1 of ocidNearArrayLL
log "NearLatitude:" & ocidNearLatitude as text
###あとの項目
set ocidNearLongitude to item 2 of ocidNearArrayLL
log "NearNearLongitude:" & ocidNearLongitude as text

####################################
#########ガイド時のug
else if (ocidKey as text) = "ug" then
set ug of ocidRecordQuery to ocidValue
end if
end repeat


##############################################
###GoogleMap用の小数点以下の桁揃え
###逆ゼロサプレス
set theLatitude to (ocidLatitude as text)
set AppleScript's text item delimiters to "."
set listLatitude to every text item of theLatitude as list
set AppleScript's text item delimiters to ""
set strLatitudeInt to text item 1 of listLatitude as text
set strLatitudeDecimal to text item 2 of listLatitude as text
set strLatitudeDecimal to (text 1 through 7 of (strLatitudeDecimal & "000000000")) as text
set theLatitude to ("" & strLatitudeInt & "." & strLatitudeDecimal & "")

set theLongitude to (ocidLongitude as text)
set AppleScript's text item delimiters to "."
set listLongitude to every text item of theLongitude as list
set AppleScript's text item delimiters to ""
set strLongitudeInt to text item 1 of listLongitude as text
set strLongitudeDecimal to text item 2 of listLongitude as text
set strLongitudeDecimal to (text 1 through 7 of (strLongitudeDecimal & "000000000")) as text
set theLongitude to ("" & strLongitudeInt & "." & strLongitudeDecimal & "")

set theGooglemapParts to ("@" & theLatitude & "," & theLongitude & "," & (z of ocidRecordQuery as text) & "z")

set theChl to ("https://www.google.com/maps/" & theGooglemapParts & "") as text



tell application "Google Chrome"
activate
make new window
open location theChl
end tell


return true


to doCopyMap()
tell application "System Events"
launch
end tell
tell application "Maps"
activate
end tell
try
tell application "System Events"
tell process "Maps"
##get every menu bar
tell menu bar 1
##get every menu bar item
tell menu bar item "編集"
##get every menu bar item
tell menu "編集"
##get every menu item
tell menu item "リンクをコピー"
click
end tell
end tell
end tell
end tell
end tell
end tell
on error
tell application "System Events"
tell process "Maps"
get every menu bar
tell menu bar 1
get every menu bar item
tell menu bar item "編集"
get every menu bar item
tell menu "編集"
get every menu item
tell menu item "コピー"
click
end tell
end tell
end tell
end tell
end tell
end tell
end try
end doCopyMap

|

[Maps]Mapの場所をSafariで開き直す

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

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSURL : a reference to objMe's NSURL
##
property objNSDictionary : a reference to objMe's NSDictionary
property objNSMutableDictionary : a reference to objMe's NSMutableDictionary
property objNSArray : a reference to objMe's NSArray
property objNSMutableArray : a reference to objMe's NSMutableArray


############################
###コピーのサブへ
doCopyMap()
############################
###クリップボードからURLを取得する
tell application "Finder"
set theURL to (the clipboard) as text
end tell
set strURL to theURL as text
############################
##値がコピー出来なかったときエラーになるので
##ここはトライ
try
####################################
###URLNSURLに格納
set ocidURL to objNSURL's alloc's initWithString:strURL
log className() of ocidURL as text
--> NSURL
####################################
###クエリー部を取り出し
set ocidQueryUrl to ocidURL's query
log className() of ocidQueryUrl as text
--> __NSCFString
log ocidQueryUrl as text
on error
###エラーしたらコピー取り直し
tell application "System Events"
tell process "Maps"
##get every menu bar
tell menu bar 1
##get every menu bar item
tell menu bar item "編集"
##get every menu bar item
tell menu "編集"
##get every menu item
tell menu item "リンクをコピー"
click
end tell
end tell
end tell
end tell
end tell
end tell
tell application "Finder"
set theURL to (the clipboard) as text
end tell
####################################
###URLNSURLに格納
set ocidURL to objNSURL's alloc's initWithString:strURL
log className() of ocidURL as text
--> NSURL
####################################
###クエリー部を取り出し
set ocidQueryUrl to ocidURL's query
log className() of ocidQueryUrl as text
--> __NSCFString
log ocidQueryUrl as text
end try

####################################
###取り出したクエリを&を区切り文字でリストに
set ocidArrayComponent to (ocidQueryUrl's componentsSeparatedByString:"&")
log className() of ocidArrayComponent as text
--> __NSArrayM
log ocidArrayComponent as list

####################################
####可変レコードを作成
set ocidRecordQuery to objNSMutableDictionary's alloc()'s init()
####値が空のレコードを定義
set recordQuery to {t:"", q:"", address:"", near:"", ll:"", z:"18", spn:"", saddr:"", daddr:"", dirflg:"", sll:"", sspn:"", ug:""} as record
####↑の定義で値が空の可変レコードを作成
set ocidRecordQuery to objNSMutableDictionary's dictionaryWithDictionary:recordQuery
####################################
###ここからクエリー分繰り返し
repeat with objArrayComponent in ocidArrayComponent
#####渡されたクエリーを=を境に分割してArray=リストにする
set ocidArrayFirstObject to (objArrayComponent's componentsSeparatedByString:"=")

####まずは順番に キー と 値 で格納
set ocidKey to item 1 of ocidArrayFirstObject
log ocidKey as text

set ocidValue to item 2 of ocidArrayFirstObject
log ocidValue as text

#########位置情報 緯度 経度
if (ocidKey as text) = "ll" then
set ll of ocidRecordQuery to ocidValue
####カンマでわけて緯度 経度に
set ocidArrayLL to (ocidValue's componentsSeparatedByString:",")
log ocidArrayLL as list
###最初の項目
set ocidLatitude to item 1 of ocidArrayLL
log "Latitude:" & ocidLatitude as text
###あとの項目
set ocidLongitude to item 2 of ocidArrayLL
log "Longitude:" & ocidLongitude as text

#########Address String 住所
else if (ocidKey as text) = "address" then
set address of ocidRecordQuery to ocidValue
set ocidAddEnc to ocidValue's stringByRemovingPercentEncoding
log "AddressString:" & ocidAddEnc as text

#########The zoom level. 高さ方向
else if (ocidKey as text) = "z" then
set z of ocidRecordQuery to ocidValue
set ocidZoomValue to ocidValue
log "ZoomValue:" & ocidZoomValue

#########マップビュー
else if (ocidKey as text) = "t" then
set t of ocidRecordQuery to ocidValue
set ocidMapType to ocidValue
log "MapType:" & ocidMapType
(*
m (standard view)
k (satellite view)
h (hybrid view)
r (transit view)
goole
map_action=pano
map_action=map
basemap=satellite
terrain
roadmap
*)
####################################
#########dirflg 移動方法
else if (ocidKey as text) = "dirflg" then
set dirflg of ocidRecordQuery to ocidValue
set ocidDirflgType to ocidValue
log "DirflgType:" & ocidDirflgType
(*
d (by car)
w (by foot)
r (by public transit)

goole
travelmode=driving
walking
transit
*)

#########Dirflg Parameters 出発点
else if (ocidKey as text) = "saddr" then
set saddr of ocidRecordQuery to ocidValue
set strSaddrEnc to ocidValue as text
set ocidSaddrEnc to ocidValue's stringByRemovingPercentEncoding
log "StartingPoint:" & ocidSaddrEnc as text

#########Destination 到着店
else if (ocidKey as text) = "daddr" then
set daddr of ocidRecordQuery to ocidValue
set strDaddrEnc to ocidValue as text
set ocidDaddrEnc to ocidValue's stringByRemovingPercentEncoding
log "DestinationPoint:" & ocidDaddrEnc as text

#########Search Query 検索語句
else if (ocidKey as text) = "q" then
set q of ocidRecordQuery to ocidValue
set strRecordQuery to ocidValue as text
set ocidSearchQueryEnc to ocidValue's stringByRemovingPercentEncoding
log "SearchQuery" & ocidSearchQueryEnc as text

####################################
#########語句検索時の周辺情報の有無による分岐

else if (ocidKey as text) = "sll" then
set sll of ocidRecordQuery to ocidValue
####カンマでわけて緯度 経度に
set ocidSearchArrayLL to (ocidValue's componentsSeparatedByString:",")
log ocidSearchArrayLL as list
####最初の項目
set ocidNearLatitude to item 1 of ocidSearchArrayLL
log "NearLatitude:" & ocidNearLatitude as text
####あとの項目
set ocidNearLongitude to item 2 of ocidSearchArrayLL
log "NearNearLongitude:" & ocidNearLongitude as text

else if (ocidKey as text) = "spn" then
####周囲情報の範囲
set spn of ocidRecordQuery to ocidValue


####################################
#########during search周辺 位置情報 緯度 経度

else if (ocidKey as text) = "near" then
set near of ocidRecordQuery to ocidValue
####カンマでわけて緯度 経度に
set ocidNearArrayLL to (ocidValue's componentsSeparatedByString:",")
log ocidNearArrayLL as list
###最初の項目
set ocidNearLatitude to item 1 of ocidNearArrayLL
log "NearLatitude:" & ocidNearLatitude as text
###あとの項目
set ocidNearLongitude to item 2 of ocidNearArrayLL
log "NearNearLongitude:" & ocidNearLongitude as text

####################################
#########ガイド時のug
else if (ocidKey as text) = "ug" then
set ug of ocidRecordQuery to ocidValue

end if

end repeat


##############################################
###GoogleMap用の小数点以下の桁揃え
###逆ゼロサプレス
set theLatitude to (ocidLatitude as text)
set AppleScript's text item delimiters to "."
set listLatitude to every text item of theLatitude as list
set AppleScript's text item delimiters to ""
set strLatitudeInt to text item 1 of listLatitude as text
set strLatitudeDecimal to text item 2 of listLatitude as text
set strLatitudeDecimal to (text 1 through 7 of (strLatitudeDecimal & "000000000")) as text
set theLatitude to ("" & strLatitudeInt & "." & strLatitudeDecimal & "")

set theLongitude to (ocidLongitude as text)
set AppleScript's text item delimiters to "."
set listLongitude to every text item of theLongitude as list
set AppleScript's text item delimiters to ""
set strLongitudeInt to text item 1 of listLongitude as text
set strLongitudeDecimal to text item 2 of listLongitude as text
set strLongitudeDecimal to (text 1 through 7 of (strLongitudeDecimal & "000000000")) as text
set theLongitude to ("" & strLongitudeInt & "." & strLongitudeDecimal & "")

set theGooglemapParts to ("@" & theLatitude & "," & theLongitude & "," & (z of ocidRecordQuery as text) & "z")

set theChl to ("https://www.google.com/maps/" & theGooglemapParts & "") as text



tell application "Safari"
activate
make new document with properties {name:"maps.google.co.jp"}
tell window 1
open location theChl
end tell

end tell


return true


to doCopyMap()
tell application "System Events"
launch
end tell
tell application "Maps"
activate
end tell
try
tell application "System Events"
tell process "Maps"
##get every menu bar
tell menu bar 1
##get every menu bar item
tell menu bar item "編集"
##get every menu bar item
tell menu "編集"
##get every menu item
tell menu item "リンクをコピー"
click
end tell
end tell
end tell
end tell
end tell
end tell
on error
tell application "System Events"
tell process "Maps"
get every menu bar
tell menu bar 1
get every menu bar item
tell menu bar item "編集"
get every menu bar item
tell menu "編集"
get every menu item
tell menu item "コピー"
click
end tell
end tell
end tell
end tell
end tell
end tell
end try
end doCopyMap

|

[Map]位置情報をQRコードにするv2

[Map]位置情報をQRコードにする
https://quicktimer.cocolog-nifty.com/icefloe/2022/04/post-af06ee.html
こちらのアップデートです。
現時点ではここまでにしょうか…と
NSMutableDictionaryを使ってみたものの…
処理は煩雑になるわ、テキスト形式に戻すのに記述が増えるは…で
あまり良い事なかった。
1:便利な機能は使っていく
2:記述にこだわらず、可読性や処理のシンプルさが結局後で効く

こだわらずに、最適と思われる方法にすればよかったなぁ…遠い目
(読みにくいわ…修正しにくいわで、最低な出来だと…トホホ)

ダウンロード - geo2qr4mapv2.applescript.zip




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

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSURL : a reference to objMe's NSURL
##
property objNSDictionary : a reference to objMe's NSDictionary
property objNSMutableDictionary : a reference to objMe's NSMutableDictionary
property objNSArray : a reference to objMe's NSArray
property objNSMutableArray : a reference to objMe's NSMutableArray

set objFileManager to objMe's NSFileManager's defaultManager()

###リセット
set theURL to "" as text
set ocidNSInlineData to "" as text
set ocidNSBitmapImagePadRep to "" as text

tell application "Finder"
set the clipboard to the theURL as string
end tell

objMe's NSLog("■:osascript:Start Script Geo2Qr4Map")

###コピーのサブへ
doCopyMap()

log "theURL:" & theURL
objMe's NSLog("■:osascript:コピー OK" & theURL & "")
###クリップボードからURLを取得する
tell application "Finder"
set theURL to (the clipboard) as text
end tell
delay 0.5

##################################################
objMe's NSLog("■:osascript: theURL" & theURL & "")
set strURL to theURL as text

##################################################
if strURL is "" then
###URLの取得に失敗しているパターン
set aliasIconPath to POSIX file "/System/Applications/Maps.app/Contents/Resources/AppIcon.icns" as alias
set strDefaultAnswer to "https://maps.apple.com/?ll=35.658558,139.745504" as text
try
set objResponse to (display dialog "URLの取得に失敗しました" with title "QRテキスト" default answer strDefaultAnswer 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 objResponse) then
return "時間切れですやりなおしてください"
end if
if "OK" is equal to (button returned of objResponse) then
set strURL to (text returned of objResponse) as text
else
return "キャンセル"
end if
end if

############################
##値がコピー出来なかったときエラーになるので
##ここはトライ
try
####################################
###URLNSURLに格納
set ocidURL to objNSURL's alloc's initWithString:strURL
log className() of ocidURL as text
--> NSURL
####################################
###クエリー部を取り出し
set ocidQueryUrl to ocidURL's query
log className() of ocidQueryUrl as text
--> __NSCFString
log ocidQueryUrl as text
on error
###エラーしたらコピー取り直し
doCopyMap()
tell application "Finder"
set theURL to (the clipboard) as text
end tell
####################################
###URLNSURLに格納
set ocidURL to objNSURL's alloc's initWithString:strURL
log className() of ocidURL as text
--> NSURL
####################################
###クエリー部を取り出し
set ocidQueryUrl to ocidURL's query
log className() of ocidQueryUrl as text
--> __NSCFString
log ocidQueryUrl as text
end try

####################################
###取り出したクエリを&を区切り文字でリストに
set ocidArrayComponent to (ocidQueryUrl's componentsSeparatedByString:"&")
log className() of ocidArrayComponent as text
--> __NSArrayM
log ocidArrayComponent as list

####################################
####可変レコードを作成
set ocidRecordQuery to objNSMutableDictionary's alloc()'s init()
####値が空のレコードを定義
set recordQuery to {t:"", q:"", address:"", near:"", ll:"", z:"18", spn:"", saddr:"", daddr:"", dirflg:"", sll:"", sspn:"", ug:""} as record
####↑の定義で値が空の可変レコードを作成
set ocidRecordQuery to objNSMutableDictionary's dictionaryWithDictionary:recordQuery
####################################
###ここからクエリー分繰り返し
repeat with objArrayComponent in ocidArrayComponent
#####渡されたクエリーを=を境に分割してArray=リストにする
set ocidArrayFirstObject to (objArrayComponent's componentsSeparatedByString:"=")

####まずは順番に キー と 値 で格納
set ocidKey to item 1 of ocidArrayFirstObject
log ocidKey as text

set ocidValue to item 2 of ocidArrayFirstObject
log ocidValue as text

#########位置情報 緯度 経度
if (ocidKey as text) = "ll" then
set ll of ocidRecordQuery to ocidValue
####カンマでわけて緯度 経度に
set ocidArrayLL to (ocidValue's componentsSeparatedByString:",")
log ocidArrayLL as list
###最初の項目
set ocidLatitude to item 1 of ocidArrayLL
log "Latitude:" & ocidLatitude as text
###あとの項目
set ocidLongitude to item 2 of ocidArrayLL
log "Longitude:" & ocidLongitude as text

#########Address String 住所
else if (ocidKey as text) = "address" then
set address of ocidRecordQuery to ocidValue
set ocidAddEnc to ocidValue's stringByRemovingPercentEncoding
log "AddressString:" & ocidAddEnc as text

#########The zoom level. 高さ方向
else if (ocidKey as text) = "z" then
set z of ocidRecordQuery to ocidValue
set ocidZoomValue to ocidValue
log "ZoomValue:" & ocidZoomValue

#########マップビュー
else if (ocidKey as text) = "t" then
set t of ocidRecordQuery to ocidValue
set ocidMapType to ocidValue
log "MapType:" & ocidMapType
(*
m (standard view)
k (satellite view)
h (hybrid view)
r (transit view)
goole
map_action=pano
map_action=map
basemap=satellite
terrain
roadmap
*)
####################################
#########dirflg 移動方法
else if (ocidKey as text) = "dirflg" then
set dirflg of ocidRecordQuery to ocidValue
set ocidDirflgType to ocidValue
log "DirflgType:" & ocidDirflgType
(*
d (by car)
w (by foot)
r (by public transit)

goole
travelmode=driving
walking
transit
*)

#########Dirflg Parameters 出発点
else if (ocidKey as text) = "saddr" then
set saddr of ocidRecordQuery to ocidValue
set strSaddrEnc to ocidValue as text
set ocidSaddrEnc to ocidValue's stringByRemovingPercentEncoding
log "StartingPoint:" & ocidSaddrEnc as text

#########Destination 到着店
else if (ocidKey as text) = "daddr" then
set daddr of ocidRecordQuery to ocidValue
set strDaddrEnc to ocidValue as text
set ocidDaddrEnc to ocidValue's stringByRemovingPercentEncoding
log "DestinationPoint:" & ocidDaddrEnc as text

#########Search Query 検索語句
else if (ocidKey as text) = "q" then
set q of ocidRecordQuery to ocidValue
set strRecordQuery to ocidValue as text
set ocidSearchQueryEnc to ocidValue's stringByRemovingPercentEncoding
log "SearchQuery" & ocidSearchQueryEnc as text

####################################
#########語句検索時の周辺情報の有無による分岐

else if (ocidKey as text) = "sll" then
set sll of ocidRecordQuery to ocidValue
####カンマでわけて緯度 経度に
set ocidSearchArrayLL to (ocidValue's componentsSeparatedByString:",")
log ocidSearchArrayLL as list
####最初の項目
set ocidNearLatitude to item 1 of ocidSearchArrayLL
log "NearLatitude:" & ocidNearLatitude as text
####あとの項目
set ocidNearLongitude to item 2 of ocidSearchArrayLL
log "NearNearLongitude:" & ocidNearLongitude as text

else if (ocidKey as text) = "spn" then
####周囲情報の範囲
set spn of ocidRecordQuery to ocidValue


####################################
#########during search周辺 位置情報 緯度 経度

else if (ocidKey as text) = "near" then
set near of ocidRecordQuery to ocidValue
####カンマでわけて緯度 経度に
set ocidNearArrayLL to (ocidValue's componentsSeparatedByString:",")
log ocidNearArrayLL as list
###最初の項目
set ocidNearLatitude to item 1 of ocidNearArrayLL
log "NearLatitude:" & ocidNearLatitude as text
###あとの項目
set ocidNearLongitude to item 2 of ocidNearArrayLL
log "NearNearLongitude:" & ocidNearLongitude as text

####################################
#########ガイド時のug
else if (ocidKey as text) = "ug" then
set ug of ocidRecordQuery to ocidValue

end if

end repeat

log ocidRecordQuery as record
objMe's NSLog("■:osascript: RecordQuery Done")
#####################################################
#####QRコード保存要ファイル名
if (q of ocidRecordQuery as text) is not "" then
###検索語句あり
if (count of (ocidSearchQueryEnc as text)) < 8 then
set strQueryEnc to (ocidSearchQueryEnc as text) as text
else
set strQueryEnc to characters 1 thru 8 of (ocidSearchQueryEnc as text) as text
end if
set strFileName to ("" & strQueryEnc & ".png")
objMe's NSLog("■:osascript: ocidSearchQueryEnc " & (ocidSearchQueryEnc as text) & "")

else if (daddr of ocidRecordQuery as text) is not "" then
###行き先語句あり
set strDaddrEnc to characters 1 thru 8 of (ocidDaddrEnc as text) as text
set strFileName to ("" & strDaddrEnc & ".png")
objMe's NSLog("■:osascript: ocidDaddrEnc " & (ocidDaddrEnc as text) & "")
else
###語句の無い場合は日付をファイル名にする
set strDateFormat to "yyyyMMMMddhhmm" as text
set ocidForMatter to objMe's NSDateFormatter's alloc()'s init()
ocidForMatter's setLocale:(objMe's NSLocale's localeWithLocaleIdentifier:"ja_JP_POSIX")
ocidForMatter's setDateFormat:(strDateFormat)
set objDate to (current date)
set strDateTime to (ocidForMatter's stringFromDate:(objDate)) as text
set strFileName to ("" & strDateTime & ".png")
end if

####################################################
#########対応アプリの分岐
###ホスト名を取り出し
set ocidHostUrl to ocidURL's |host|
log className() of ocidHostUrl as text
--> __NSCFString
log ocidHostUrl as text
####################################
###ホストによる分岐
if (ocidHostUrl as text) is "guides.apple.com" then
-->このままの値でバーコードを作成する
set listButtonAset to {"AppleMapガイド用"} as list
set strAlertMes to "ガイドリンクはAppleMap専用です"

else if (ocidHostUrl as text) is "collections.apple.com" then
-->コレクションは現在は『ガイド』になった?
set listButtonAset to {"AppleMapガイド用"} as list
set strAlertMes to "ガイドリンクはAppleMap専用です"

else if (ocidHostUrl as text) is "maps.apple.com" then
-->ガイド以外
-->処理する
####################################
###内容によっての分岐
if (ll of ocidRecordQuery as text) is not "" then
######緯度経度がある場合
set listButtonAset to {"AppleMap", "GoogleMap", "GeoQR"} as list
set strAlertMes to "GeoQRは対応していない機種やアプリがあります"

else if (q of ocidRecordQuery as text) is not "" then
######検索語句がある場合
set listButtonAset to {"AppleMap", "GoogleMap", "汎用"} as list
set strAlertMes to "iOSAppleMapQRコードを作成する OR 一般的なQRコードを作成する"

else if (daddr of ocidRecordQuery as text) is not "" then
set listButtonAset to {"AppleMap経路", "GoogleMap経路"} as list
set strAlertMes to "経路情報用のMapになります"

else
######緯度経度無し検索語句無しだとAppleMapのみ
set listButtonAset to {"AppleMap用のみ"} as list
set strAlertMes to "ガイドリンクはAppleMap専用です"

end if
end if
##############################################
log listButtonAset
try
set objAns to (display alert "どちら用のQRコードを作成しますか?" message strAlertMes default button 1 buttons listButtonAset)
on error
log "エラーしました"
return
end try

set objResponse to (button returned of objAns) as text
##############################################

if objResponse is "GeoQR" then
### 緯度経度でGEOバーコード 対応機種に制限がある場合あり
set theChl to ("GEO:" & (ocidLatitude as text) & "," & (ocidLongitude as text) & "," & (z of ocidRecordQuery as text) & "") as text
###経路情報 Map
else if objResponse is "AppleMap経路" then
set theChl to ("http://maps.apple.com/?daddr=" & (ocidDaddrEnc as text) & "&saddr=" & (ocidSaddrEnc as text) & "") as text
###経路情報 Google
else if objResponse is "GoogleMap経路" then
set theChl to ("https://www.google.com/maps/?daddr=" & (ocidDaddrEnc as text) & "&saddr=" & (ocidSaddrEnc as text) & "") as text
####AppleMapのガイドリンク
else if objResponse is "AppleMapガイド用" then
set theChl to ("" & strURL & "") as text

else if objResponse is "GoogleMap" then
##############################################
###GoogleMap用の小数点以下の桁揃え
###逆ゼロサプレス
set theLatitude to (ocidLatitude as text)
set AppleScript's text item delimiters to "."
set listLatitude to every text item of theLatitude as list
set AppleScript's text item delimiters to ""
set strLatitudeInt to text item 1 of listLatitude as text
set strLatitudeDecimal to text item 2 of listLatitude as text
set strLatitudeDecimal to (text 1 through 7 of (strLatitudeDecimal & "000000000")) as text
set theLatitude to ("" & strLatitudeInt & "." & strLatitudeDecimal & "")

set theLongitude to (ocidLongitude as text)
set AppleScript's text item delimiters to "."
set listLongitude to every text item of theLongitude as list
set AppleScript's text item delimiters to ""
set strLongitudeInt to text item 1 of listLongitude as text
set strLongitudeDecimal to text item 2 of listLongitude as text
set strLongitudeDecimal to (text 1 through 7 of (strLongitudeDecimal & "000000000")) as text
set theLongitude to ("" & strLongitudeInt & "." & strLongitudeDecimal & "")

set theGooglemapParts to ("@" & theLatitude & "," & theLongitude & "," & (z of ocidRecordQuery as text) & "z")

set theChl to ("https://www.google.com/maps/" & theGooglemapParts & "") as text
else
set theChl to ("http://maps.apple.com/?q=" & (ocidLatitude as text) & "," & (ocidLongitude as text) & "," & (z of ocidRecordQuery as text) & "z") as text
end if


##############################################
log theChl

###フォルダのパス
###ピクチャーフォルダのパス
tell application "Finder"
set aliasDirPath to (path to pictures folder from user domain) as alias
set strDirPath to POSIX path of aliasDirPath as text
end tell
####フォルダ名
set strFolderName to "QRcode" as text
set strDirPath to ("" & strDirPath & strFolderName & "") as text
###NSStringテキスト
set ocidDirPath to objNSString's stringWithString:strDirPath
###フォルダを作る
###途中のフォルダも作る-->true
set boolMakeNewFolder to (objFileManager's createDirectoryAtPath:ocidDirPath withIntermediateDirectories:true attributes:(missing value) |error|:(missing value))

####ファイルパス
set strSaveFilePath to ("" & strDirPath & "/" & strFileName & "") as text

objMe's NSLog("■:osascript: strSaveFilePath" & strSaveFilePath & "")

##############################################
set strInputText to theChl as text
####テキストをNSString
set ocidInputString to objNSString's stringWithString:strInputText
####テキストをUTF8
set ocidUtf8InputString to ocidInputString's dataUsingEncoding:(objMe's NSUTF8StringEncoding)
####CIQRCodeGenerator初期化
set ocidQRcodeImage to objMe's CIFilter's filterWithName:"CIQRCodeGenerator"
ocidQRcodeImage's setDefaults()
###テキスト設定
ocidQRcodeImage's setValue:ocidUtf8InputString forKey:"inputMessage"
###読み取り誤差値設定L, M, Q, H
ocidQRcodeImage's setValue:"Q" forKey:"inputCorrectionLevel"
###QRコード本体のイメージ
set ocidCIImage to ocidQRcodeImage's outputImage()
-->ここで生成されるのはQRのセルが1x1pxの最小サイズ
###QRコードの縦横取得
set ocidCIImageDimension to ocidCIImage's extent()
set ocidCIImageWidth to (item 1 of item 2 of ocidCIImageDimension) as integer
set ocidCIImageHight to (item 2 of item 2 of ocidCIImageDimension) as integer
###最終的に出力したいpxサイズ
set numScaleMax to 720
###整数で拡大しないとアレなのでの値のニアなサイズになります
set numWidth to ((numScaleMax / ocidCIImageWidth) div 1) as integer
set numHight to ((numScaleMax / ocidCIImageHight) div 1) as integer
###↑サイズの拡大縮小する場合はここで値を調整すれば良い
####変換スケール作成-->拡大
set recordScalse to objMe's CGAffineTransform's CGAffineTransformMakeScale(numWidth, numHight)
##変換スケールを適応(元のサイズに元のサイズのスケール適応しても意味ないけど
set ocidCIImageScaled to ocidCIImage's imageByApplyingTransform:recordScalse
#######元のセルが1x1pxの最小サイズで出したいときはここで処理
##set ocidCIImageScaled to ocidCIImage
###イメージデータを展開
set ocidNSCIImageRep to objMe's NSCIImageRep's imageRepWithCIImage:ocidCIImageScaled
###出力用のイメージの初期化
set ocidNSImageScaled to objMe's NSImage's alloc()'s initWithSize:(ocidNSCIImageRep's |size|())
###イメージデータを合成
ocidNSImageScaled's addRepresentation:ocidNSCIImageRep
###出来上がったデータはOS_dispatch_data
set ocidOsDispatchData to ocidNSImageScaled's TIFFRepresentation()
####NSBitmapImageRep
set ocidNSBitmapImageRep to objMe's NSBitmapImageRep's imageRepWithData:ocidOsDispatchData
#################################################################
###quiet zone用に画像をパディングする
set numPadWidth to ((ocidCIImageWidth * numWidth) + (numWidth * 6)) as integer
set numPadHight to ((ocidCIImageHight * numHight) + (numHight * 6)) as integer
###左右に3セル分づつ余白 quiet zoneを足す
####まずは元のQRコードのサイズに6セルサイズ分足したサイズの画像を作って
set ocidNSBitmapImagePadRep to (objMe's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:numPadWidth pixelsHigh:numPadHight bitsPerSample:8 samplesPerPixel:4 hasAlpha:true isPlanar:false colorSpaceName:(objMe's NSCalibratedRGBColorSpace) bitmapFormat:(objMe's NSAlphaFirstBitmapFormat) bytesPerRow:0 bitsPerPixel:32)
###初期化
objMe's NSGraphicsContext's saveGraphicsState()
###ビットマップイメージ
(objMe's NSGraphicsContext's setCurrentContext:(objMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:ocidNSBitmapImagePadRep))
###塗り色を『白』に指定して
objMe's NSColor's whiteColor()'s |set|()
##画像にする
objMe's NSRectFill({origin:{x:0, y:0}, |size|:{width:numPadWidth, height:numPadHight}})
###出来上がった画像にQRバーコードを左右3セル分ずらした位置にCompositeSourceOverする
ocidNSBitmapImageRep's drawInRect:{origin:{x:(numWidth * 3), y:(numHight * 3)}, |size|:{width:numPadWidth, Hight:numPadHight}} fromRect:{origin:{x:0, y:0}, |size|:{width:numPadWidth, height:numPadHight}} operation:(objMe's NSCompositeSourceOver) fraction:1.0 respectFlipped:true hints:(missing value)
####画像作成終了
objMe's NSGraphicsContext's restoreGraphicsState()
objMe's NSLog("■:osascript: restoreGraphicsState")
#################################################################

####JPEG用の圧縮プロパティ
##set ocidNSSingleEntryDictionary to objMe's NSDictionary's dictionaryWithObject:1 forKey:(objMe's NSImageCompressionFactor)
####PNG用の圧縮プロパティ
set ocidNSSingleEntryDictionary to objMe's NSDictionary's dictionaryWithObject:true forKey:(objMe's NSImageInterlaced)

#####出力イメージへ変換
set ocidNSInlineData to (ocidNSBitmapImagePadRep's representationUsingType:(objMe's NSBitmapImageFileTypePNG) |properties|:ocidNSSingleEntryDictionary)

######インラインデータをファイルに書き出し
set boolMakeQrCode to (ocidNSInlineData's writeToFile:strSaveFilePath atomically:true)

set aliasDirPath to POSIX file strDirPath as alias
###保存場所を開いて
tell application "Finder"
select aliasDirPath
end tell
####プレビューに表示
tell application "Preview"
launch
activate
open aliasDirPath
end tell

objMe's NSLog("■:osascript: Done")
set theURL to ""
set the clipboard to theURL
set ocidNSInlineData to ""
set ocidNSBitmapImagePadRep to ""


return true


to doCopyMap()
tell application "System Events"
launch
end tell
tell application "Maps"
activate
end tell
try
tell application "System Events"
tell process "Maps"
##get every menu bar
tell menu bar 1
##get every menu bar item
tell menu bar item "編集"
##get every menu bar item
tell menu "編集"
##get every menu item
tell menu item "リンクをコピー"
click
end tell
end tell
end tell
end tell
end tell
end tell
on error
tell application "System Events"
tell process "Maps"
get every menu bar
tell menu bar 1
get every menu bar item
tell menu bar item "編集"
get every menu bar item
tell menu "編集"
get every menu item
tell menu item "コピー"
click
end tell
end tell
end tell
end tell
end tell
end tell
end try
end doCopyMap

|

[Map]URLの分解

[Map]位置情報をQRコードにする
https://quicktimer.cocolog-nifty.com/icefloe/2022/04/post-af06ee.html
QRコードを生成するのに必要なのがURLの分解query部の処理が
上手出来ない、本当はquery部をNSDictionary(レコード形式)として格納すれば良いんだと思うのですが…
どうやっても上手くいかない…方法がわからん
Mapのparametersは
https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/MapLinks/MapLinks.html
現在できる事は
NSString--> NSURL-->クエリー部を-->NSCFString-->NSArrayMで取り出す
これって…

set AppleScript's text item delimiters to "="


取り出すのと変わらん 厳密には処理速度とか違うのかもしれんけど


ホストでの分岐

set strURL to "https://guides.apple.com/?ug=Cg%2FmlrDopo%2FjgqzjgqTjg4k%3D"

set ocidURL to objNSURL's alloc's initWithString:strURL
log className() of ocidURL as text
--> NSURL

set ocidHostUrl to ocidURL's |host|
log className() of ocidHostUrl as text
--> __NSCFString
log ocidHostUrl as text


if ocidHostUrl is "maps.apple.com" then
-->このままの値でバーコードを作成する

else if ocidHostUrl is "guides.apple.com" then
-->このままの値でバーコードを作成する

else if ocidHostUrl is "collections.apple.com" then
-->コレクションは現在は『ガイド』になった?

end if

URLのパスがGoの場合


set strURL to "https://maps.apple.com/go?"


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

############パスの取得
set ocidPathComponentsUrl to ocidURL's |path|
log className() of ocidPathComponentsUrl as text
--> __NSArrayM
log ocidPathComponentsUrl as text
-->(*/go*)

if (ocidPathComponentsUrl as text) contains "go" then
-->Go=Mapアプリで開く

end if



現在自分ができる、クエリをレコードにする方法

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

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

property objNSDictionary : a reference to objMe's NSDictionary
property objNSMutableDictionary : a reference to objMe's NSMutableDictionary
property objNSArray : a reference to objMe's NSArray
property objNSMutableArray : a reference to objMe's NSMutableArray



set strURL to "https://maps.apple.com/?ll=35.471134,139.606745&q=%E7%A5%9E%E5%A5%88%E5%B7%9D%E7%9C%8C%20%E2%80%94%20%E6%A8%AA%E6%B5%9C%E5%B8%82%E7%A5%9E%E5%A5%88%E5%B7%9D%E5%8C%BA&spn=0.084274,0.132120&t=m"


####可変レコードを作成
set ocidRecordQuery to objNSMutableDictionary's alloc()'s init()
####値が空のレコードを定義
set recordQuery to {t:"", q:"", address:"", near:"", ll:"", z:"", spn:"", saddr:"", daddr:"", dirflg:"", sll:"", sspn:"", ug:""} as record
####↑の定義で値が空の可変レコードを作成
set ocidRecordQuery to objNSMutableDictionary's dictionaryWithDictionary:recordQuery

####################################
###URLをNSURLに格納
set ocidURL to objNSURL's alloc's initWithString:strURL
log className() of ocidURL as text
--> NSURL

####################################
###クエリー部を取り出し
set ocidQueryUrl to ocidURL's query
log className() of ocidQueryUrl as text
--> __NSCFString
log ocidQueryUrl as text

####################################
###取り出したクエリを&を区切り文字でリストに
set ocidArrayComponent to (ocidQueryUrl's componentsSeparatedByString:"&")
log className() of ocidArrayComponent as text
--> __NSArrayM
log ocidArrayComponent as list

####################################
###ここからクエリー分繰り返し
repeat with objArrayComponent in ocidArrayComponent
#####渡されたクエリーを=を境に分割してArray=リストにする
set ocidArrayFirstObject to (objArrayComponent's componentsSeparatedByString:"=")

####まずは順番に キー と 値 で格納
set ocidKey to item 1 of ocidArrayFirstObject
log ocidKey as text

set ocidValue to item 2 of ocidArrayFirstObject
log ocidValue as text

#########位置情報 緯度 経度
if (ocidKey as text) = "ll" then
set ll of ocidRecordQuery to ocidValue
####カンマでわけて緯度 経度に
set ocidArrayLL to (ocidValue's componentsSeparatedByString:",")
log ocidArrayLL as list
###最初の項目
set ocidLatitude to item 1 of ocidArrayLL
log "Latitude:" & ocidLatitude as text
###あとの項目
set ocidLongitude to item 2 of ocidArrayLL
log "Longitude:" & ocidLongitude as text

#########Address String 住所
else if (ocidKey as text) = "address" then
set address of ocidRecordQuery to ocidValue
set ocidAddEnc to ocidValue's stringByRemovingPercentEncoding
log "AddressString:" & ocidAddEnc as text

#########The zoom level. 高さ方向
else if (ocidKey as text) = "z" then
set z of ocidRecordQuery to ocidValue
set ocidZoomValue to ocidValue
log "ZoomValue:" & ocidZoomValue

#########マップビュー
else if (ocidKey as text) = "t" then
set t of ocidRecordQuery to ocidValue
set ocidMapType to ocidValue
log "MapType:" & ocidMapType
(*
m (standard view)
k (satellite view)
h (hybrid view)
r (transit view)
*)
####################################
#########dirflg 移動方法
else if (ocidKey as text) = "dirflg" then
set dirflg of ocidRecordQuery to ocidValue
set ocidDirflgType to ocidValue
log "DirflgType:" & ocidDirflgType
(*
d (by car)
w (by foot)
r (by public transit)
*)

#########Dirflg Parameters 出発点
else if (ocidKey as text) = "saddr" then
set saddr of ocidRecordQuery to ocidValue
set ocidSaddrEnc to ocidValue's stringByRemovingPercentEncoding
log "StartingPoint:" & ocidSaddrEnc as text

#########Destination 到着店
else if (ocidKey as text) = "daddr" then
set daddr of ocidRecordQuery to ocidValue
set ocidDaddrEnc to ocidValue's stringByRemovingPercentEncoding
log "DestinationPoint:" & ocidDaddrEnc as text

#########Search Query 検索語句
else if (ocidKey as text) = "q" then
set q of ocidRecordQuery to ocidValue
set ocidSearchQueryEnc to ocidValue's stringByRemovingPercentEncoding
log "SearchQuery" & ocidSearchQueryEnc as text
####################################
#########語句検索時の周辺情報の有無による分岐

else if (ocidKey as text) = "sll" then
set sll of ocidRecordQuery to ocidValue
####カンマでわけて緯度 経度に
set ocidSearchArrayLL to (ocidValue's componentsSeparatedByString:",")
log ocidSearchArrayLL as list
###最初の項目
set ocidNearLatitude to item 1 of ocidSearchArrayLL
log "NearLatitude:" & ocidNearLatitude as text
###あとの項目
set ocidNearLongitude to item 2 of ocidSearchArrayLL
log "NearNearLongitude:" & ocidNearLongitude as text

else if (ocidKey as text) = "spn" then
set spn of ocidRecordQuery to ocidValue


####################################
#########during search周辺 位置情報 緯度 経度

else if (ocidKey as text) = "near" then
set near of ocidRecordQuery to ocidValue
####カンマでわけて緯度 経度に
set ocidNearArrayLL to (ocidValue's componentsSeparatedByString:",")
log ocidNearArrayLL as list
###最初の項目
set ocidNearLatitude to item 1 of ocidNearArrayLL
log "NearLatitude:" & ocidNearLatitude as text
###あとの項目
set ocidNearLongitude to item 2 of ocidNearArrayLL
log "NearNearLongitude:" & ocidNearLongitude as text

####################################
#########ガイド時のug
else if (ocidKey as text) = "ug" then
set ug of ocidRecordQuery to ocidValue

end if

end repeat

log ocidRecordQuery as record


続く

|

[Map]位置情報をQRコードにする

macOSのMapアプリはApplescript対応していないので、System Eventsを使うのですが

20220430020817_1280x627x144_0
20220430020817_1280x557x144_0
状態によって
メニュー名が変わります
これに、気がつかなかった…トホホ

ダウンロード - geo2qr4.applescript.zip



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

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
set objFileManager to objMe's NSFileManager's defaultManager()

set theURL to ""
set ocidNSInlineData to ""
set ocidNSBitmapImagePadRep to ""


###set strLogFile to "/tmp/Geo2Qr4.txt"

tell application "System Events"
launch
end tell
(*
tell application "System Events"
tell application process "Maps"
keystroke "C" using {command down}
end tell
end tell

tell application "System Events"
keystroke "c" using {command down}
end tell
*)
try
tell application "System Events"
tell process "Maps"
get every menu bar
tell menu bar 1
get every menu bar item
tell menu bar item "編集"
get every menu bar item
tell menu "編集"
get every menu item
tell menu item "リンクをコピー"
click
end tell
end tell
end tell
end tell
end tell
end tell
on error
tell application "System Events"
tell process "Maps"
get every menu bar
tell menu bar 1
get every menu bar item
tell menu bar item "編集"
get every menu bar item
tell menu "編集"
get every menu item
tell menu item "コピー"
click
end tell
end tell
end tell
end tell
end tell
end tell
end try

(*
tell application "System Events"
tell process "Maps"
tell menu bar 1
tell menu bar item "Edit"
tell menu "Edit"
click menu item "Copy Link"
end tell
end tell
end tell
end tell
end tell
*)


tell application "Finder"
set theURL to (the clipboard) as text
end tell
delay 0.5


try
set objAns to (display alert "どちら用のQRコードを作成しますか?" message "iOSAppleMapQRコードを作成する OR 一般的なQRコードを作成する" default button 1 buttons {"AppleMap", "GoogleMap", "汎用"})
on error
log "エラーしました"
return
end try


set objResponse to (button returned of objAns) as text

set theURL to theURL as text


###
###do shell script "echo \"" & theURL & "\" >> " & strLogFile & ""
####

#########################
####URLの整形
set AppleScript's text item delimiters to "ll="
set listUrl to every text item of theURL as list
set AppleScript's text item delimiters to ""

set strSubURL to text item 2 of listUrl as text

set AppleScript's text item delimiters to "&"
set listSubURL to every text item of strSubURL as list
set AppleScript's text item delimiters to ""

set strLL to text item 1 of listSubURL as text

set AppleScript's text item delimiters to ","
set listLL to every text item of strLL as list
set AppleScript's text item delimiters to ""

set theLatitude to (item 1 of listLL) as text
set theLongitude to (item 2 of listLL) as text


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

set strFileName to ("" & theLatitude & "-" & theLongitude & ".png")
#####################################################
if objResponse is "AppleMap" then
set theChl to ("GEO:" & theLatitude & "," & theLongitude & "") as text
log theChl
else if objResponse is "GoogleMap" then

###GoogleMap用の小数点以下の桁揃え
###逆ゼロサプレス
(**)
set AppleScript's text item delimiters to "."
set listLatitude to every text item of theLatitude as list
set AppleScript's text item delimiters to ""
set strLatitudeInt to text item 1 of listLatitude as text
set strLatitudeDecimal to text item 2 of listLatitude as text
set strLatitudeDecimal to (text 1 through 7 of (strLatitudeDecimal & "000000000")) as text
set theLatitude to ("" & strLatitudeInt & "." & strLatitudeDecimal & "")

set AppleScript's text item delimiters to "."
set listLongitude to every text item of theLongitude as list
set AppleScript's text item delimiters to ""
set strLongitudeInt to text item 1 of listLongitude as text
set strLongitudeDecimal to text item 2 of listLongitude as text
set strLongitudeDecimal to (text 1 through 7 of (strLongitudeDecimal & "000000000")) as text
set theLongitude to ("" & strLongitudeInt & "." & strLongitudeDecimal & "")

set theGooglemapParts to ("@" & theLatitude & "," & theLongitude & ",16z")

set theChl to ("https://www.google.com/maps/" & theGooglemapParts & "") as text
else
set theChl to ("http://maps.apple.com/?q=" & theLatitude & "," & theLongitude & "") as text
end if
#######################


###フォルダのパス
###ピクチャーフォルダのパス
tell application "Finder"
set aliasDirPath to (path to pictures folder from user domain) as alias
set strDirPath to POSIX path of aliasDirPath as text
end tell
####フォルダ名
set strFolderName to "QRcode" as text
set strDirPath to ("" & strDirPath & strFolderName & "") as text
###NSStringテキスト
set ocidDirPath to objNSString's stringWithString:strDirPath
###フォルダを作る
###途中のフォルダも作る-->true
set boolMakeNewFolder to (objFileManager's createDirectoryAtPath:ocidDirPath withIntermediateDirectories:true attributes:(missing value) |error|:(missing value))

####ファイルパス
set strSaveFilePath to ("" & strDirPath & "/" & strFileName & "") as text


################################################################
set strInputText to theChl as text
####テキストをNSString
set ocidInputString to objNSString's stringWithString:strInputText
####テキストをUTF8
set ocidUtf8InputString to ocidInputString's dataUsingEncoding:(objMe's NSUTF8StringEncoding)
####CIQRCodeGenerator初期化
set ocidQRcodeImage to objMe's CIFilter's filterWithName:"CIQRCodeGenerator"
ocidQRcodeImage's setDefaults()
###テキスト設定
ocidQRcodeImage's setValue:ocidUtf8InputString forKey:"inputMessage"
###読み取り誤差値設定L, M, Q, H
ocidQRcodeImage's setValue:"Q" forKey:"inputCorrectionLevel"
###QRコード本体のイメージ
set ocidCIImage to ocidQRcodeImage's outputImage()
-->ここで生成されるのはQRのセルが1x1pxの最小サイズ
###QRコードの縦横取得
set ocidCIImageDimension to ocidCIImage's extent()
set ocidCIImageWidth to (item 1 of item 2 of ocidCIImageDimension) as integer
set ocidCIImageHight to (item 2 of item 2 of ocidCIImageDimension) as integer
###最終的に出力したいpxサイズ
set numScaleMax to 720
###整数で拡大しないとアレなのでの値のニアなサイズになります
set numWidth to ((numScaleMax / ocidCIImageWidth) div 1) as integer
set numHight to ((numScaleMax / ocidCIImageHight) div 1) as integer
###↑サイズの拡大縮小する場合はここで値を調整すれば良い
####変換スケール作成-->拡大
set recordScalse to objMe's CGAffineTransform's CGAffineTransformMakeScale(numWidth, numHight)
##変換スケールを適応(元のサイズに元のサイズのスケール適応しても意味ないけど
set ocidCIImageScaled to ocidCIImage's imageByApplyingTransform:recordScalse
#######元のセルが1x1pxの最小サイズで出したいときはここで処理
##set ocidCIImageScaled to ocidCIImage
###イメージデータを展開
set ocidNSCIImageRep to objMe's NSCIImageRep's imageRepWithCIImage:ocidCIImageScaled
###出力用のイメージの初期化
set ocidNSImageScaled to objMe's NSImage's alloc()'s initWithSize:(ocidNSCIImageRep's |size|())
###イメージデータを合成
ocidNSImageScaled's addRepresentation:ocidNSCIImageRep
###出来上がったデータはOS_dispatch_data
set ocidOsDispatchData to ocidNSImageScaled's TIFFRepresentation()
####NSBitmapImageRep
set ocidNSBitmapImageRep to objMe's NSBitmapImageRep's imageRepWithData:ocidOsDispatchData
#################################################################
###quiet zone用に画像をパディングする
set numPadWidth to ((ocidCIImageWidth * numWidth) + (numWidth * 6)) as integer
set numPadHight to ((ocidCIImageHight * numHight) + (numHight * 6)) as integer
###左右に3セル分づつ余白 quiet zoneを足す
####まずは元のQRコードのサイズに6セルサイズ分足したサイズの画像を作って
set ocidNSBitmapImagePadRep to (objMe's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:numPadWidth pixelsHigh:numPadHight bitsPerSample:8 samplesPerPixel:4 hasAlpha:true isPlanar:false colorSpaceName:(objMe's NSCalibratedRGBColorSpace) bitmapFormat:(objMe's NSAlphaFirstBitmapFormat) bytesPerRow:0 bitsPerPixel:32)
###初期化
objMe's NSGraphicsContext's saveGraphicsState()
###ビットマップイメージ
(objMe's NSGraphicsContext's setCurrentContext:(objMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:ocidNSBitmapImagePadRep))
###塗り色を『白』に指定して
objMe's NSColor's whiteColor()'s |set|()
##画像にする
objMe's NSRectFill({origin:{x:0, y:0}, |size|:{width:numPadWidth, height:numPadHight}})
###出来上がった画像にQRバーコードを左右3セル分ずらした位置にCompositeSourceOverする
ocidNSBitmapImageRep's drawInRect:{origin:{x:(numWidth * 3), y:(numHight * 3)}, |size|:{width:numPadWidth, Hight:numPadHight}} fromRect:{origin:{x:0, y:0}, |size|:{width:numPadWidth, height:numPadHight}} operation:(objMe's NSCompositeSourceOver) fraction:1.0 respectFlipped:true hints:(missing value)
####画像作成終了
objMe's NSGraphicsContext's restoreGraphicsState()

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

####JPEG用の圧縮プロパティ
##set ocidNSSingleEntryDictionary to objMe's NSDictionary's dictionaryWithObject:1 forKey:(objMe's NSImageCompressionFactor)
####PNG用の圧縮プロパティ
set ocidNSSingleEntryDictionary to objMe's NSDictionary's dictionaryWithObject:true forKey:(objMe's NSImageInterlaced)

#####出力イメージへ変換
set ocidNSInlineData to (ocidNSBitmapImagePadRep's representationUsingType:(objMe's NSBitmapImageFileTypePNG) |properties|:ocidNSSingleEntryDictionary)

######インラインデータをファイルに書き出し
set boolMakeQrCode to (ocidNSInlineData's writeToFile:strSaveFilePath atomically:true)

set aliasDirPath to POSIX file strDirPath as alias
###保存場所を開いて
tell application "Finder"
select aliasDirPath
end tell
####プレビューに表示
tell application "Preview"
launch
activate
open aliasDirPath
end tell


set theURL to ""
set the clipboard to theURL
set ocidNSInlineData to ""
set ocidNSBitmapImagePadRep to ""
return true


to doReplace(theText, orgStr, newStr)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to orgStr
set tmpList to every text item of theText
set AppleScript's text item delimiters to newStr
set tmpStr to tmpList as text
set AppleScript's text item delimiters to oldDelim
return tmpStr
end doReplace

|

[Chrome]地図用のQRコードを生成する

AppleのURLに誤りがあったので修正
https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/MapLinks/MapLinks.html


(*


Chromeで開いているページのQRを作成します。
たぶんiOS専用 

20190706 初回作成
20210429 URLを修正

APIの仕様は
https://developers.google.com/chart/infographics/docs/qr_codes


*)

tell application "Google Chrome"
activate
tell window 1
tell active tab
set theURL to URL as text
end tell
end tell
end tell

tell application "Finder"
activate
set objAns to ¬
display alert ¬
"どちら用のQRコードを作成しますか?" message ¬
"iOSAppleMapQRコードを作成する OR 一般的なQRコードを作成する" default button 1 ¬
buttons {"AppleMap", "GoogleMap", "汎用"}
end tell


set AppleScript's text item delimiters to {"/"}
set listUrl to every text item of theURL as list
set numCntUrl to (count of listUrl) as number
set numSepUrl to 1 as number
set AppleScript's text item delimiters to {""}
log numCntUrl

repeat numCntUrl times
set theSepUrl to (item numSepUrl of listUrl) as text
try
set theUrlParts to (the character 1 of theSepUrl)
on error
set theUrlParts to " "
end try


if theUrlParts is "@" then
set theGooglemapParts to theSepUrl
set theSepUrl to doReplace(theSepUrl, "@", "")
set AppleScript's text item delimiters to {","}
set listSepUrl to every text item of theSepUrl as list

set theLatitude to (item 1 of listSepUrl) as text
set theLongitude to (item 2 of listSepUrl) as text

set AppleScript's text item delimiters to {""}
end if
set numSepUrl to numSepUrl + 1 as number
end repeat





if (button returned of objAns) is "AppleMap" then

set theChl to ("GEO:" & theLatitude & "," & theLongitude & "") as text
log theChl
else if (button returned of objAns) is "GoogleMap" then
set theChl to ("https://www.google.com/maps/" & theGooglemapParts & "") as text
else
set theChl to ("http://maps.apple.com/?ll=" & theLatitude & "," & theLongitude & "") as text

end if


--API各項目
--BASE URL
set theApiUrl to "https://chart.googleapis.com/chart?" as text

set theCht to "qr" as text

set theChs to "540x540" as text

set theChoe to "UTF-8" as text

---L M Q R
set theChld to "Q" as text

--URLを整形
set theOpenUrl to ("" & theApiUrl & "&cht=" & theCht & "&chs=" & theChs & "&choe=" & theChoe & "&chld=" & theChld & "&chl=" & theChl & "") as text


-----Chromeで開く
tell application "Google Chrome"
activate
tell window 1
set active tab index to 1
make new tab
tell active tab
set URL to theOpenUrl
end tell
end tell
end tell







to doReplace(theText, orgStr, newStr)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to orgStr
set tmpList to every text item of theText
set AppleScript's text item delimiters to newStr
set tmpStr to tmpList as text
set AppleScript's text item delimiters to oldDelim
return tmpStr
end doReplace

|

その他のカテゴリー

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