【macOS】Visual Studio Codeで開くクイック・アクション
【スクリプトエディタで開く】 |
OPEN_VisualStudioCodeWF.scpt | ソース |
|---|
| 001 | #!/usr/bin/env osascript |
| 002 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
| 003 | (* |
| 004 | Visual Studio Codeでファイルを開く |
| 005 | スキーム指定版 |
| 006 | Automator.app用 |
| 007 |
|
| 008 | com.cocolog-nifty.quicktimer.icefloe *) |
| 009 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
| 010 | use AppleScript version "2.8" |
| 011 | use framework "Foundation" |
| 012 | use framework "AppKit" |
| 013 | use scripting additions |
| 014 |
|
| 015 | property refMe : a reference to current application |
| 016 |
|
| 017 |
|
| 018 | #テキストでファイルURLを整形してOPENする |
| 019 | on run {listAliasFilePath} |
| 020 | |
| 021 | repeat with itemAliasFilePath in listAliasFilePath |
| 022 | set aliasFilePath to itemAliasFilePath as alias |
| 023 | set strFilePath to (POSIX path of aliasFilePath) as text |
| 024 | set strFilePath to ("vscode://file/" & strFilePath & "") as text |
| 025 | set strCmd to ("/usr/bin/open \"" & strFilePath & "\"") as text |
| 026 | do shell script strCmd |
| 027 | end repeat |
| 028 | return doQuitAutomatorRunner() |
| 029 | end run |
| 030 |
|
| 031 |
|
| 032 |
|
| 033 |
|
| 034 | ################################## |
| 035 | #com.apple.automator.xpc.runnerの終了 |
| 036 | to doQuitAutomatorRunner() |
| 037 | #terminateAutomaticallyTerminableApplications 自動終了 |
| 038 | refMe's NSRunningApplication's terminateAutomaticallyTerminableApplications() |
| 039 | # |
| 040 | set listBundleID to {"com.apple.automator.xpc.runner", "com.apple.automator.xpc.workflowServiceRunner"} as list |
| 041 | #terminate 通常終了 |
| 042 | repeat with itemBundleID in listBundleID |
| 043 | set ocidAppArray to (refMe's NSRunningApplication's runningApplicationsWithBundleIdentifier:(itemBundleID)) |
| 044 | repeat with itemApp in ocidAppArray |
| 045 | itemApp's terminate() |
| 046 | end repeat |
| 047 | end repeat |
| 048 | |
| 049 | try |
| 050 | tell application "System Events" to quit |
| 051 | end try |
| 052 | #terminateAutomaticallyTerminableApplications 自動終了 |
| 053 | refMe's NSRunningApplication's terminateAutomaticallyTerminableApplications() |
| 054 | end doQuitAutomatorRunner |
| AppleScriptで生成しました |
|---|