Barcode2D

【QR】イベント・カレンダー登録用のQRコードを作る(Google Chart利用)

【QR】イベント・カレンダー登録用のQRコードを作る(Google Chart利用)
https://force4u.cocolog-nifty.com/skywalker/2019/07/post-860c14.html

こちらの記事の
php→ python3への対応版(OS11以上用)

ダウンロード - make_qrcode4_eventfile.scpt.zip

iCSファイルを選んで実行すると
20220106-171043


iOSの標準カメラでこんな感じ

Img_0068


(*

make_qrcode4_eventfile.scpt
イベント登録用のQRを作成します。
たぶんiOS専用 

20190714 初回作成
20190715 phpのエラー処理追加
20220106 phpでの%エンコードの処理をpython3に置き換え

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


*)


on run
set theWithPrompt to "QRコードを作成します。"
set theDefLoc to path to downloads folder from user domain
set theFileType to "public.vcard,com.apple.ical.ics,public.calendar-event,public.ics,com.apple.ical.vcs" as text
set AppleScript's text item delimiters to {","}
set theFileTypeList to every text item of theFileType
open (choose file default location theDefLoc ¬
with prompt theWithPrompt ¬
of type theFileTypeList ¬
without invisibles)
end run



on open DropObj
set theFilePath to POSIX path of DropObj
set theChl to (do shell script "cat '" & theFilePath & "'") as text
set AppleScript's text item delimiters to "\r"
set listData to (every text item of theChl) as list
set AppleScript's text item delimiters to ""
set numCntList to (count of listData) as number

set numReadList to 1 as number
repeat numCntList times
set theLineData to (item numReadList of listData) as text


----EVENT ITEM

if theLineData contains "LOCATION:" then
set theLocation to theLineData
set theLocation to doReplace(theLocation, "LOCATION:", "")
set theLocation to my encodeURL(theLocation)
end if
if theLineData contains "DESCRIPTION:" then
set theDescription to theLineData
set theDescription to doReplace(theDescription, "DESCRIPTION:", "")
set theDescription to my encodeURL(theDescription)

end if
if theLineData contains "SUMMARY:" then
set theSummary to theLineData
set theSummary to doReplace(theSummary, "SUMMARY:", "")
set theSummary to my encodeURL(theSummary)
end if
if theLineData contains "URL:" then
set theURL to theLineData
set theURL to doReplace(theURL, "URL:", "")
set theURL to my encodeURL(theURL)
else if theLineData contains "URL;" then
set theURL to theLineData
set theURL to doReplace(theURL, "VALUE=URI:", "")
set theURL to doReplace(theURL, "URL;", "")
set theURL to my encodeURL(theURL)
end if
if theLineData contains "DTSTART:" then
set theDTSTART to theLineData
set theDTSTART to doReplace(theDTSTART, "DTSTART:", "")
end if
if theLineData contains "DTEND:" then
set theDTEND to theLineData
set theDTEND to doReplace(theDTEND, "DTEND:", "")
end if
set numReadList to numReadList + 1 as number
end repeat


set theChl to "BEGIN:VEVENT%0ALOCATION:" & theLocation & "%0ADESCRIPTION:" & theDescription & "%0AURL:" & theURL & "%0ASUMMARY:" & theSummary & "%0ADTSTART:" & theDTSTART & "%0ADTEND:" & theDTEND & "%0AEND:VEVENT" as text


--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 "L" as text

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


-----サファリで開く
tell application "Safari"
activate
make new document with properties {name:"QR-CODE by Google API"}
tell window 1
open location theOpenUrl
end tell
end tell


end open


--------------文字の置き換えサブルーチン
to doReplace(theText, theOrgStr, theNewStr)
set theOldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to theOrgStr
set theTmpList to every text item of theText
set AppleScript's text item delimiters to theNewStr
set theReplaceStr to theTmpList as text
set AppleScript's text item delimiters to theOldDelim
return theReplaceStr
end doReplace




---URLエンコードのサブルーチン
on encodeURL(str)
set scpt to ("python3 -c 'import urllib.parse;[print(urllib.parse.quote(\"" & str & "\", safe=\"/:;#!?=\"))]'") as text
return do shell script scpt
end encodeURL

|

【QR】アドレス帳登録用のQRコードを作る(Google Chart利用)

【QR】アドレス帳登録用のQRコードを作る(Google Chart利用)
https://force4u.cocolog-nifty.com/skywalker/2019/07/post-deb3db.html

AppleScriptでphpを利用していた部分



---URLエンコードのサブルーチン
on encodeURL(str)
set scpt to "php -r 'echo urlencode(\"" & str & "\");'"
return do shell script scpt
end encodeURL


python3に作り直し

---URLエンコードのサブルーチン
on encodeURL(str)
set scpt to ("python3 -c 'import urllib.parse;[print(urllib.parse.quote(\"" & str & "\", safe=\"/:;#!?=\"))]'") as text
return do shell script scpt
end encodeURL

ダウンロード - chart.googleapis.com.add.scpt.zip

(*

chart.googleapis.com.add.scpt
アドレス帳登録用のQRコードを生成します。
たぶんiOS専用 

20190706 初回作成
20190715 phpのエラー処理追加
20211204 phpでの%エンコードの処理をpython3に置き換え

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


*)

----設定項目
set theNa to "" as text ---
set theNb to "寅次郎" as text ---
set theOrg to "くるまや" as text ---会社名
set theMailWork to "foo@hoge.com" as text ---メール会社
set theMailHome to "foo-hoge@mobie.com" as text ---メール自宅
set theTelWork to "123-456-7890" as text ---電話会社
set theTelCell to "000-1111-2222" as text --- 電話携帯
set theTelInt to "" as text ---内線

----設定ここまで
--姓名表示をを整形 半角スペース区切り
set theFN to (theNa & " " & theNb) as text


----URLエンコード
set theNa to my encodeURL(theNa)
----URLエンコード
set theNb to my encodeURL(theNb)
----URLエンコード
set theFN to my encodeURL(theFN)
----URLエンコード
set theOrg to my encodeURL(theOrg)

----Vカードデータを整形 改行コードはMac
set theChl to "BEGIN:VCARD\rVERSION:3.0\rN:" & theNa & ";" & theNb & ";;;\rFN:" & theFN & "\rORG:" & theOrg & ";\rEMAIL;type=INTERNET;type=WORK;type=pref:" & theMailWork & "\rEMAIL;type=INTERNET;type=HOME:" & theMailHome & "\rTEL;type=WORK;type=pref:" & theTelWork & "\rTEL;type=CELL:" & theTelCell & "\ritem1.TEL:" & theTelInt & "\ritem1.X-ABLabel:内線\rEND:VCARD" as text

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

set theCht to "qr" as text

set theChs to "504x504" as text

set theChoe to "UTF-8" as text

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

set theChl to doReplace(theChl, "+", "%20") as text

--URLを整形
set theOpenUrl to ("" & theApiUrl & "&cht=" & theCht & "&chs=" & theChs & "&choe=" & theChoe & "&chld=" & theChld & "&chl=" & theChl & "") as text
---改行を%エンコード
set theOpenUrl to doReplace(theOpenUrl, "\r", "%0A") as text


-----サファリで開く
tell application "Safari"
activate
make new document with properties {name:"QR-CODE by Google API"}
tell window 1
open location theOpenUrl
end tell
end tell



---URLエンコードのサブルーチン
on encodeURL(str)
set scpt to ("python3 -c 'import urllib.parse;[print(urllib.parse.quote(\"" & str & "\", safe=\"/:;#!?=\"))]'") as text
return do shell script scpt
end encodeURL



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

|

[Wifi]Wifiアクセスポイント用のmobileconfigを作成する

出先用
SSIDとパスワードからそのアクセスポイント用のmobileconfigを作成します。
→Apple Configurator で作ってもいいんだけどね…笑
Wifiバーコードも同時生成して、書類フォルダにWifiフォルダを作ってそこに保存します。

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

QRコードの読み取り結果を貼り付けてもOK
Screencapture_816x322_20211102094030


(************************************************************************

     この上の▶︎をぽっちっとしてください
WIFI接続用のモバイルコンフィグファイルとQRコードを作成します。
作成した『mobileconfig』と『png』ファイルは『書類フォルダ』にWifiフォルダを作って
その中に保存します

************************************************************************)


---------setteing
property theAutoJoin : "true" as text
property theCaptiveBypass : "false" as text
property theDisableAssociationMACRandomization : "true" as text
property theEncryptionType : "WPA3" as text
property theHIDDEN_NETWORK : "false" as text
property theIsHotspot : "false" as text
property theProxyType : "None" as text
---------QR
property theApiUrl : "https://chart.googleapis.com/chart?" as text
property theCht : "qr" as text
property theChs : "540x540" as text
property theChoe : "UTF-8" as text
property theChld : "Q" as text


on run
try
tell application "Finder"
activate
set objDialog to (display dialog "SSID(WIFIアクセスポイント):WifiQRコードの読み取り結果でも可" default answer "" with title "WIFIアクセスポイント")
end tell
set theSSID to (text returned of objDialog) as text
on error
"パスワードを取得できませんでした"
return
error number -128
end try

set theBoolText to (characters 1 thru 5 of theSSID) as text

if theBoolText is "WIFI:" then
set AppleScript's text item delimiters to ";"
set listSSIDData to (every text item of theSSID) as list
set AppleScript's text item delimiters to ""
set theLineDateSSID to (item 1 of listSSIDData) as text
set theLineDateSec to (item 2 of listSSIDData) as text
set theLineDatePW to (item 3 of listSSIDData) as text


set theSSID to doReplace(theLineDateSSID, "WIFI:S:", "") as text
set theEncryptionType to doReplace(theLineDateSec, "T:", "") as text
set thePW to doReplace(theLineDatePW, "P:", "") as text

set theSSID to doReplace(theSSID, ";", "") as text
set theEncryptionType to doReplace(theEncryptionType, ";", "") as text
set thePW to doReplace(thePW, ";", "") as text

set theSSID to doReplace(theSSID, ":", "") as text
set theEncryptionType to doReplace(theEncryptionType, ":", "") as text
set thePW to doReplace(thePW, ":", "") as text

set theSSID to doReplace(theSSID, " ", "") as text
set theEncryptionType to doReplace(theEncryptionType, " ", "") as text
set thePW to doReplace(thePW, " ", "") as text
else
try
tell application "Finder"
activate
set objDialog to (display dialog "WIFIパスワード" default answer "" with title "WIFIアクセスポイント・パスワード")
end tell
set thePW to (text returned of objDialog) as text
on error
"パスワードを取得できませんでした"
return
error number -128
end try
end if
set listReturned to {theSSID, thePW} as list
open (listReturned)
end run



on open listReturned
set theCommandText to ("uuidgen") as text
set theUUIDPayloadA to (do shell script theCommandText)
set theCommandText to ("uuidgen") as text
set theUUIDPayloadB to (do shell script theCommandText)
set theSSID to (item 1 of listReturned) as text
set thePW to (item 2 of listReturned) as text

set theCommandText to ("curl http://smile.s12.xrea.com/getip/hostname.php") as text
set theHOSTname to (do shell script theCommandText)


set theMobileconfig to ("<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"><plist version=\"1.0\"><dict><key>HasRemovalPasscode</key><false/><key>PayloadContent</key><array><dict><key>AutoJoin</key><" & theAutoJoin & "/><key>CaptiveBypass</key><" & theCaptiveBypass & "/><key>DisableAssociationMACRandomization</key><" & theDisableAssociationMACRandomization & "/><key>EncryptionType</key><string>" & theEncryptionType & "</string><key>HIDDEN_NETWORK</key><" & theHIDDEN_NETWORK & "/><key>IsHotspot</key><" & theIsHotspot & "/><key>Password</key><string>" & thePW & "</string><key>PayloadDescription</key><string>Wi-Fi設定を構成します</string><key>PayloadDisplayName</key><string>Wi-Fi</string><key>PayloadIdentifier</key><string>com.apple.wifi.managed." & theUUIDPayloadA & "</string><key>PayloadType</key><string>com.apple.wifi.managed</string><key>PayloadUUID</key><string>" & theUUIDPayloadA & "</string><key>PayloadVersion</key><integer>1</integer><key>ProxyType</key><string>" & theProxyType & "</string><key>SSID_STR</key><string>" & theSSID & "</string></dict></array><key>PayloadDisplayName</key><string>" & theSSID & "</string><key>PayloadIdentifier</key><string>" & theHOSTname & "." & theUUIDPayloadB & "</string><key>PayloadOrganization</key><string>" & theHOSTname & "</string><key>PayloadRemovalDisallowed</key><true/><key>PayloadType</key><string>Configuration</string><key>PayloadUUID</key><string>" & theUUIDPayloadB & "</string><key>PayloadVersion</key><integer>1</integer></dict></plist>") as text

tell application "Finder"
try
make new folder at (path to documents folder from user domain) with properties {name:"Wifi", displayed name:"Wifi"}
end try
end tell
tell application "Finder"
set theWifiFolder to (folder "Wifi" of (path to documents folder from user domain)) as alias
try
make new file at theWifiFolder with properties {name:("" & theSSID & ".mobileconfig")}
end try
set theFile to (((theWifiFolder) as text) & (("" & theSSID & ".mobileconfig") as text)) as alias
end tell
tell application "TextEdit"
open theFile
tell document 1
set its text to theMobileconfig
end tell
save document 1
close document 1
end tell
set theFilePath to (POSIX path of theFile) as text
set theCommandText to ("open \"" & theFilePath & "\" | open \"x-apple.systempreferences:com.apple.preferences.configurationprofiles\"") as text
do shell script theCommandText
---------
set theQRcode to ("WIFI:S:" & theSSID & ";T:" & theEncryptionType & ";P:" & thePW & ";;") as text
set theOpenUrl to ("" & theApiUrl & "&cht=" & theCht & "&chs=" & theChs & "&choe=" & theChoe & "&chld=" & theChld & "&chl=" & theQRcode & "") as text
-----
set theCommandText to ("curl -L -o \"$HOME/Documents/Wifi/" & theSSID & ".png\" '" & theOpenUrl & "' --connect-timeout 20") as text
do shell script theCommandText


tell application "Finder"
set theWifiFolder to (folder "Wifi" of (path to documents folder from user domain)) as alias
open theWifiFolder
end tell
---------
end open




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

|

[AppleScripts]WIFIバーコードを作成(データマトリックス)

ダウンロード - wifibarcode.zip

(*
WIFIバーコードをダウンロードします
アンドロイドで使われる
データマトリックス形式
tec-it.comAPIを使います


*)
--設定2項目
--SSID
set theSSID to "wifiB"
--パスワード
set thePSK to "password"


---------------------------------------------------------
set theMakeQrCodeUrl to ("https://barcode.tec-it.com/barcode.ashx?code=DataMatrix_Wifi&multiplebarcodes=false&translate-esc=false&data=WIFI%3AT%3AWPA%3BS%3A" & theSSID & "%3BP%3A" & thePSK & "%3B%3B&unit=Fit&dpi=360&imagetype=Png&rotation=0&color=%23000000&bgcolor=%23ffffff&codepage=Default&qunit=Mm&quiet=10&hidehrt=False&eclevel=M&dmsize=Default") as text


try
set theComandText to ("curl -L -o ~/Downloads/" & theSSID & ".dm.png '" & theMakeQrCodeUrl & "' --connect-timeout 20") as text
do shell script theComandText
on error
"ダウンロードに失敗しました"
return
end try

set theFilePath to ((the path to downloads folder from user domain) & theSSID & ".dm.png") as text

tell application "Finder"
activate
open folder (the path to downloads folder from user domain)
select theFilePath
end tell

|

[AppleScripts]WIFIバーコードを作成(QR)


ダウンロード - wifiバーコード.zip


(*
WIFIバーコードをダウンロードします
iosで使われる
QR形式
googleAPIを使います


*)
--設定2項目
--SSID
set theSSID to "wifiA"
--パスワード
set thePSK to "password"

---------------------------------------------------------

set theMakeQrCodeUrl to ("https://chart.googleapis.com/chart?&cht=qr&chs=540x540&choe=UTF-8&chld=Q&chl=WIFI:S:" & theSSID & ";T:WPA;P:" & thePSK & ";;") as text



try
set theComandText to ("curl -L -o ~/Downloads/" & theSSID & ".qr.png '" & theMakeQrCodeUrl & "' --connect-timeout 20") as text
do shell script theComandText
on error
"ダウンロードに失敗しました"
return
end try
set theFilePath to ((the path to downloads folder from user domain) & theSSID & ".qr.png") as text

tell application "Finder"
activate
open folder (the path to downloads folder from user domain)
select theFilePath
end tell

|

【AppleAcripts】ブラウザで開いているURLをQRコードに変換生成(GoogleAPI)

各種ブラウザで開いているURLのQRコードをGoogleAPIを利用して

QRコードを生成しますの一部修正

インストール先は

~/Library/Scripts/Applications/Safari

~/Library/Scripts/Applications/Chrome

~/Library/Scripts/Applications/ Microsoft Edge

ダウンロード - url2qr.zip

 

ダウンロード - url2qr.zip

|

【QR】マップ用のQRコードを作る(Google Chart利用)

マップ用のリンクは
ブラウザ閲覧用→これは正解が見つからなかった
GoogleMap用

 

5737

 

AppleMap用 の振り分け

 

225737

 

GoogleMap用
https://www.google.com/maps/@Latitude,Longitude,range
→この方式を選択
↓この方法でも良かったかな…
https://www.google.com/maps/search/?api=1&query=Latitude,Longitude

 

 

AppleMap用は
GEO:Latitude,Longitude ←これはiOS専用かね?

 

そして汎用として
http://maps.apple.com/?q=Latitude,Longitude

iOS以外のデバイスでアクセスするとGoogleMapに転送されるので両刀使いでお勧め

 


 

(*

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

20190715 初回作成

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/?q=" & 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

 

 

ダウンロード - geo2qr4chrome.scpt.zip

 

|

【QR】イベント・カレンダー登録用のQRコードを作る(Google Chart利用)

Website_20190714193401

 

iCalフォーマットのicsファイルをQRコードに変換します。

 

 

192234

 

 


(*

make_qrcode4_eventfile.scpt
イベント登録用のQRを作成します。
たぶんiOS専用 

20190714 初回作成

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


*)


on run
set theWithPrompt to "QRコードを作成します。"
set theDefLoc to path to downloads folder from user domain
set theFileType to "public.vcard,com.apple.ical.ics" as text
set AppleScript's text item delimiters to {","}
set theFileTypeList to every text item of theFileType
open (choose file default location theDefLoc ¬
with prompt theWithPrompt ¬
of type theFileTypeList ¬
without invisibles)
end run



on open DropObj
set theFilePath to POSIX path of DropObj
set theChl to (do shell script "cat '" & theFilePath & "'") as text
set theChl to doReplace(theChl, "\r ", "") as text
set theChl to doReplace(theChl, "\"", "\\\"") as text
set theChl to my encodeURL(theChl) as text
set theChl to doReplace(theChl, "+", "%20") as text

--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 "L" as text

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


-----サファリで開く
tell application "Safari"
activate
make new document with properties {name:"QR-CODE by Google API"}
tell window 1
open location theOpenUrl
end tell
end tell


end open


--------------文字の置き換えサブルーチン
to doReplace(theText, theOrgStr, theNewStr)
set theOldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to theOrgStr
set theTmpList to every text item of theText
set AppleScript's text item delimiters to theNewStr
set theReplaceStr to theTmpList as text
set AppleScript's text item delimiters to theOldDelim
return theReplaceStr
end doReplace


---URLエンコードのサブルーチン
on encodeURL(str)
set scpt to "php -r 'echo urlencode(\"" & str & "\");'"
return do shell script scpt
end encodeURL

 

 

ダウンロード - make_qrcode4_eventfile.zip

 

 

 

 

 

 

 

|

【QR】ブラウザで表示中のURLをQRコードにする(Google Chart利用)

Www

 

 

ユーザーのアプリケーションスクリプトフォルダに入れて使います。

 

 

(*

Url2QR4Safari.scpt
サファリで開いているページのQRを作成します。
たぶんiOS専用 

20190706 初回作成

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


*)

tell application "Safari"
activate
tell window 1
set theChl to do JavaScript "encodeURIComponent(document.URL)" in front document
end tell
end tell


--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


-----サファリで開く
tell application "Safari"
activate
make new document with properties {name:"QR-CODE by Google API"}
tell window 1
open location theOpenUrl
end tell
end tell

 

ダウンロード - url2qr.zip

 

 

|

【QR】アドレス帳登録用のQRコードを作る(Google Chart利用)

50

 

こんな感じのQRコードを作成します。

 

(*

chart.googleapis.com.scpt
アドレス帳登録用のQRコードを生成します。
たぶんiOS専用 

20190706 初回作成

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


*)

----設定項目
set theNa to "林檎" as text ---
set theNb to "太郎" as text ---
set theOrg to "アップルコンピュータ" as text ---会社名
set theMailWork to "work@hoge.com" as text ---メール会社
set theMailHome to "home@hoge.com" as text ---メール自宅
set theTelWork to "0123-456-7890" as text ---電話会社
set theTelCell to "000-000-00000" as text --- 電話携帯
set theTelInt to "1234" as text ---内線

----設定ここまで
--姓名表示をを整形 半角スペース区切り
set theFN to (theNa & " " & theNb) as text

----Vカードデータを整形 改行コードはMac
set theChl to "BEGIN:VCARD\rVERSION:3.0\rN:" & theNa & ";" & theNb & ";;;\rFN:" & theFN & "\rORG:" & theOrg & ";\rEMAIL;type=INTERNET;type=WORK;type=pref:" & theMailWork & "\rEMAIL;type=INTERNET;type=HOME:" & theMailHome & "\rTEL;type=WORK;type=pref:" & theTelWork & "\rTEL;type=CELL:" & theTelCell & "\ritem1.TEL:" & theTelInt & "\ritem1.X-ABLabel:内線\rEND:VCARD" as text


----URLエンコード
set theChl to my encodeURL(theChl)

--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


-----サファリで開く
tell application "Safari"
activate
make new document with properties {name:"QR-CODE by Google API"}
tell window 1
open location theOpenUrl
end tell
end tell



---URLエンコードのサブルーチン
on encodeURL(str)
set scpt to "php -r 'echo urlencode(\"" & str & "\");'"
return do shell script scpt
end encodeURL

 

ダウンロード - chart.googleapis.com.scpt.zip

|

その他のカテゴリー

Accessibility AccessibilityCheck AccessibilityForm AccessibilityInDesign AccessibilityPDF Acrobat Acrobat Action Acrobat Annotation Acrobat AppleScripts Acrobat Character Acrobat Layer Acrobat PDF Embed API Acrobat PDF Form Print Acrobat Plug-ins Acrobat Portfolios Acrobat Print AcrobatBarcode AcrobatDialog AcrobatForm AcrobatJS AcrobatMenu AcrobatPDF AcrobatStamp AcrobatYouTube AddressBook Adobe Adobe InDesign Adobe Photoshop AdobeAppleScript AdobeBridge AdobeIllustrator AdobeJSX aed Alfresco Android AnimationGif Apple AppleScript AppleScriptBasics AppleScriptCharacter AppleScriptColor AppleScriptDroplet AppleScriptErrorNum AppleScriptFolder AppleScriptFontBook AppleScriptRename AppleScriptTools AppleSymbols Applications Barcode Barcode2D BarcodePostal BetterHTMLExport Book BOX Browser buzz Certificates CharacterEntity CharacterSets Colors Cool Site CSS Cutting DecoMail DecorationMail Design Desktop Diff DJ dmg DNS Documents Download DTP eBook Editer eMail Envelopes ExifTool Facebook FFmpeg File System Fonts FontsTool FontsWeb FOOD FormPrint ftp Gadget Gif Animation Google Google Chrome Enterprise HexEditor HTML info iPhoto ISBN ISO iTunes iWork iWorkNumbers iWorkNumbersCalendar iWorkNumbersTimecard iWorkPages JavaScript JeditX JeditX Regexp JeditXAppleScript JIS jquery Letterpress Library logo Mac Admin Mac Archiver Mac Browser Mac Browser Plugin Mac QuickLook Mac Setup Mac Spotlight Mac Video Map Memo Microsoft Teams Mobby mobileconfig Moto Movies Music Network Basic ntp OCR Office OfficePowerPoint OSX Paint Pantone Paper PDFlib Permission Photo Pictograms Print Public Python QuickLook QuickTime QuickTimeSetting QuickTimeSound Real Media ReName ResourceFork ruby Sample Screen ScreenCast Search Security SEO Sharing SLAResource Sound Spotlight Stamp SWF TCC.db Tutorial PSD TV Twitter Typography Unicode Utilities Video WEB APP WebFont Wedding Windows WindowsMedia XML XMP XPS YouTube YouTube Rss