MENU

メモ帳やVSCODEで開ける新マニュアルのコード

備忘録として。

目次

index.html

<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>マニュアル</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
<div id="header-placeholder"></div>
<div class="page-wrapper">
<aside id="sidebar">
 <!-- Sidebar content will be injected here by JS -->
</aside>
<div class="content-wrapper">
<div class="main">

<h3 class="head-i">その他</h3>

 <a href="kihon/4masu-memo.html">4マスメモ</a><br>


 <h3 class="head-i">データ・ツール</h3>
&emsp;<a href="https://chatgpt.com/">Chatgpt</a><br>

</div>
        </div>
    </div>
    <script src="load_header.js"></script>
</body>
</html>

load_header.js

/* --------------------------------------------------
   load_header.js (v2025‑07‑15)
   ‑ UNC ネットワークパス (file://server/...) とローカルパス (file:///D:/...) の両方で
     VS Code/メモ帳/Explorer リンクが正しく動作するように改良しました。
   -------------------------------------------------- */

document.addEventListener('DOMContentLoaded', function () {
  /*───────────────────────────────────────────────
    1. ヘッダーナビのリンク先を決定
  ───────────────────────────────────────────────*/
  const currentPathname = window.location.pathname;
  const pathSegments = currentPathname.split('/');
  const currentDir = pathSegments[pathSegments.length - 2]; // 現在のディレクトリ名
  const currentFilePath = window.location.pathname;


  let homeLink, gijyutuLink, sonotaLink, todoLink, calendarLink;

  if (currentDir === 'gijyutu') {
    homeLink     = '../index.html';
    gijyutuLink     = 'gijyutu.html';
    sonotaLink   = '../sonota/sonota.html';
    todoLink     = '../kihon/todo.html';
    calendarLink = '../kihon/calendar.html';
  } else if (currentDir === 'kihon') {
    homeLink     = '../index.html';
    gijyutuLink     = '../gijyutu/gijyutu.html';
    sonotaLink   = '../sonota/sonota.html';
    todoLink     = 'todo.html';
    calendarLink = 'calendar.html';
  } else if (currentDir === 'sonota') {
    homeLink     = '../index.html';
    gijyutuLink     = '../gijyutu/gijyutu.html';
    sonotaLink   = 'sonota.html';
    todoLink     = '../kihon/todo.html';
    calendarLink = '../kihon/calendar.html';
  } else {
    homeLink     = 'index.html';
    gijyutuLink     = 'gijyutu/gijyutu.html';
    sonotaLink   = 'sonota/sonota.html';
    todoLink     = 'kihon/todo.html';
    calendarLink = 'kihon/calendar.html';
  }

  /*───────────────────────────────────────────────
    2. Windows パスを取得(UNC 対応)
       ‑ file:///D:/foo/bar.html  →  D:\foo\bar.html
       ‑ file://server/share/foo →  \\server\share\foo\bar.html
  ───────────────────────────────────────────────*/
  function getWindowsFullPath () {
    const url = new URL(window.location.href);
    if (url.protocol !== 'file:') return '';

    // UNC (file://server/share/...)
    if (url.host) {
      return '\\\\' + url.host + decodeURIComponent(url.pathname).replace(/\//g, '\\');
    }
    // ローカルドライブ (file:///D:/...)
    return decodeURIComponent(url.pathname)
      .replace(/\//g, '\\')   // / → \
      .replace(/^\\/, '');     // 先頭の \ を除去
  }

  const fullPathWin = getWindowsFullPath();                      // 例: D:\work\index.html or \\server\share\index.html
  const dirPathWin  = fullPathWin.substring(0, fullPathWin.lastIndexOf('\\'));
  const VsPathWin = `vscode://file${currentFilePath}`;
  const VsDirPathWin = `vscode://file${currentFilePath.substring(0, currentFilePath.lastIndexOf('/'))}`;

  /*───────────────────────────────────────────────
    3. VS Code / メモ帳 / Explorer 用 URI を生成
  ───────────────────────────────────────────────*/
  const toPosix = p => p.replace(/\\/g, '/');

  const vscodeFileUri   = `vscode://file${toPosix(currentFilePath)}`;
  const vscodeFolderUri = `vscode://file${toPosix(currentFilePath.substring(0, currentFilePath.lastIndexOf('/')))}`;

  const notepadFileUri  = `note:${fullPathWin}`;
  const notepadFolderUri= `note:${dirPathWin}`;

  const explorerFolderUri = dirPathWin.toLowerCase().startsWith('explorer:')
    ? dirPathWin
    : `explorer:${dirPathWin}`;

  /*───────────────────────────────────────────────
    4. ヘッダとサイドバーを描画
  ───────────────────────────────────────────────*/
  const headerContent = `
<header class="main-header">
  <div class="container">
    <div class="header-left">
      <button class="hamburger-menu" aria-label="メニューを開く">
        <span class="bar"></span><span class="bar"></span><span class="bar"></span>
      </button>
      <div class="logo"><a href="${homeLink}">manual</a></div>
    </div>
    <nav class="main-nav" id="main-nav-menu">
      <ul>
        <li><a href="${homeLink}">ホーム</a></li>
        <li><a href="${sonotaLink}">その他</a></li>
        <li><a href="${gijyutuLink}">技術</a></li>
      </ul>
    </nav>
  </div>
</header>`;
  document.getElementById('header-placeholder').innerHTML = headerContent;

  const sidebarContent = `
<ul>
  <!-- <li><a href="${vscodeFileUri}">VS Codeで開く</a></li> -->
  <!-- <li><a href="${vscodeFolderUri}">フォルダを開く</a></li> -->
  <li><a href="${notepadFileUri}">メモ帳で開く</a></li>
  <li><a href="${explorerFolderUri}">エクスプローラーで開く</a></li>
  <li><a href="${todoLink}">TODOリスト</a></li>
  <li><a href="${calendarLink}">カレンダー</a></li>
</ul>`;
  document.getElementById('sidebar').innerHTML = sidebarContent;

  /*───────────────────────────────────────────────
    5. ハンバーガーメニュー制御
  ───────────────────────────────────────────────*/
  const hamburger = document.querySelector('.hamburger-menu');
  const sidebar   = document.getElementById('sidebar');
  const contentWrapper = document.querySelector('.content-wrapper');

  if (hamburger && sidebar && contentWrapper) {
    hamburger.addEventListener('click', () => {
      hamburger.classList.toggle('active');
      sidebar.classList.toggle('active');
      contentWrapper.classList.toggle('sidebar-active');
    });
  }

  /*───────────────────────────────────────────────
    6. index.html のみ TODO 概要を表示
  ───────────────────────────────────────────────*/
  if (window.location.pathname.endsWith('/index.html') || window.location.pathname.endsWith('/')) {
    const indexTodoList = document.getElementById('index-todo-list');
    const noTodoMessage = document.getElementById('no-todo-message');
    const todos = JSON.parse(localStorage.getItem('todos')) || [];
    const incompleteTodos = todos.filter(todo => !todo.completed);

    if (incompleteTodos.length > 0) {
      incompleteTodos.forEach(todo => {
        const li = document.createElement('li');
        li.textContent = todo.text;
        indexTodoList.appendChild(li);
      });
      if (noTodoMessage) noTodoMessage.style.display = 'none';
    } else if (noTodoMessage) {
      noTodoMessage.style.display = 'block';
    }
  }
});

document.addEventListener('DOMContentLoaded', () => {
  const debugDiv = document.getElementById('debug');

  document.querySelectorAll('a.openfolder').forEach(a => {
    const raw = a.dataset.path || '';

    // セグメントごとに encodeURIComponent して openfolder: URI を生成
    const uri = 'openfolder:' +
      raw.replace(/\\/g, '/')
         .split('/')
         .map(encodeURIComponent)
         .join('/');

    a.href = uri;

    // デバッグ出力(#debug があるときだけ)
    if (debugDiv) {
      debugDiv.innerHTML += `<p>元のパス: ${raw}<br>変換後URI: ${uri}</p>`;
    }

    // クリック時ログ(任意)
    a.addEventListener('click', () => console.log('クリック:', uri));
  });
});
/* --------------------------------------------------
   load_header.js (v2025‑07‑15)
   ‑ UNC ネットワークパス (file://server/...) とローカルパス (file:///D:/...) の両方で
     VS Code/メモ帳/Explorer リンクが正しく動作するように改良しました。
   -------------------------------------------------- */

document.addEventListener('DOMContentLoaded', function () {
  /*───────────────────────────────────────────────
    1. ヘッダーナビのリンク先を決定
  ───────────────────────────────────────────────*/
  const currentPathname = window.location.pathname;
  const pathSegments = currentPathname.split('/');
  const currentDir = pathSegments[pathSegments.length - 2]; // 現在のディレクトリ名
  const currentFilePath = window.location.pathname;


  let homeLink, blogLink, sonotaLink, todoLink, calendarLink;

  if (currentDir === 'blog') {
    homeLink     = '../index.html';
    blogLink     = 'blog.html';
    sonotaLink   = '../sonota/sonota.html';
    todoLink     = '../kihon/todo.html';
    calendarLink = '../kihon/calendar.html';
  } else if (currentDir === 'kihon') {
    homeLink     = '../index.html';
    blogLink     = '../blog/blog.html';
    sonotaLink   = '../sonota/sonota.html';
    todoLink     = 'todo.html';
    calendarLink = 'calendar.html';
  } else if (currentDir === 'sonota') {
    homeLink     = '../index.html';
    blogLink     = '../blog/blog.html';
    sonotaLink   = 'sonota.html';
    todoLink     = '../kihon/todo.html';
    calendarLink = '../kihon/calendar.html';
  } else {
    homeLink     = 'index.html';
    blogLink     = 'blog/blog.html';
    sonotaLink   = 'sonota/sonota.html';
    todoLink     = 'kihon/todo.html';
    calendarLink = 'kihon/calendar.html';
  }

  /*───────────────────────────────────────────────
    2. Windows パスを取得(UNC 対応)
       ‑ file:///D:/foo/bar.html  →  D:\foo\bar.html
       ‑ file://server/share/foo →  \\server\share\foo\bar.html
  ───────────────────────────────────────────────*/
  function getWindowsFullPath () {
    const url = new URL(window.location.href);
    if (url.protocol !== 'file:') return '';

    // UNC (file://server/share/...)
    if (url.host) {
      return '\\\\' + url.host + decodeURIComponent(url.pathname).replace(/\//g, '\\');
    }
    // ローカルドライブ (file:///D:/...)
    return decodeURIComponent(url.pathname)
      .replace(/\//g, '\\')   // / → \
      .replace(/^\\/, '');     // 先頭の \ を除去
  }

  const fullPathWin = getWindowsFullPath();                      // 例: D:\work\index.html or \\server\share\index.html
  const dirPathWin  = fullPathWin.substring(0, fullPathWin.lastIndexOf('\\'));
  const VsPathWin = `vscode://file${currentFilePath}`;
  const VsDirPathWin = `vscode://file${currentFilePath.substring(0, currentFilePath.lastIndexOf('/'))}`;

  /*───────────────────────────────────────────────
    3. VS Code / メモ帳 / Explorer 用 URI を生成
  ───────────────────────────────────────────────*/
  const toPosix = p => p.replace(/\\/g, '/');

  const vscodeFileUri   = `vscode://file${toPosix(currentFilePath)}`;
  const vscodeFolderUri = `vscode://file${toPosix(currentFilePath.substring(0, currentFilePath.lastIndexOf('/')))}`;

  const notepadFileUri  = `note:${fullPathWin}`;
  const notepadFolderUri= `note:${dirPathWin}`;

  const explorerFolderUri = dirPathWin.toLowerCase().startsWith('explorer:')
    ? dirPathWin
    : `explorer:${dirPathWin}`;

  /*───────────────────────────────────────────────
    4. ヘッダとサイドバーを描画
  ───────────────────────────────────────────────*/
  const headerContent = `
<header class="main-header">
  <div class="container">
    <div class="header-left">
      <button class="hamburger-menu" aria-label="メニューを開く">
        <span class="bar"></span><span class="bar"></span><span class="bar"></span>
      </button>
      <div class="logo"><a href="${homeLink}">manual</a></div>
    </div>
    <nav class="main-nav" id="main-nav-menu">
      <ul>
        <li><a href="${homeLink}">ホーム</a></li>
        <li><a href="${blogLink}">ブログ</a></li>
        <li><a href="${sonotaLink}">その他</a></li>
      </ul>
    </nav>
  </div>
</header>`;
  document.getElementById('header-placeholder').innerHTML = headerContent;

  const sidebarContent = `
<ul>
  <li><a href="${vscodeFileUri}">VS Codeで開く</a></li>
  <li><a href="${vscodeFolderUri}">フォルダを開く</a></li>
  <li><a href="${notepadFileUri}">メモ帳で開く</a></li>
  <li><a href="${explorerFolderUri}">エクスプローラーで開く</a></li>
  <li><a href="${todoLink}">TODOリスト</a></li>
  <li><a href="${calendarLink}">カレンダー</a></li>
</ul>`;
  document.getElementById('sidebar').innerHTML = sidebarContent;

  /*───────────────────────────────────────────────
    5. ハンバーガーメニュー制御
  ───────────────────────────────────────────────*/
  const hamburger = document.querySelector('.hamburger-menu');
  const sidebar   = document.getElementById('sidebar');
  const contentWrapper = document.querySelector('.content-wrapper');

  if (hamburger && sidebar && contentWrapper) {
    hamburger.addEventListener('click', () => {
      hamburger.classList.toggle('active');
      sidebar.classList.toggle('active');
      contentWrapper.classList.toggle('sidebar-active');
    });
  }

  /*───────────────────────────────────────────────
    6. index.html のみ TODO 概要を表示
  ───────────────────────────────────────────────*/
  if (window.location.pathname.endsWith('/index.html') || window.location.pathname.endsWith('/')) {
    const indexTodoList = document.getElementById('index-todo-list');
    const noTodoMessage = document.getElementById('no-todo-message');
    const todos = JSON.parse(localStorage.getItem('todos')) || [];
    const incompleteTodos = todos.filter(todo => !todo.completed);

    if (incompleteTodos.length > 0) {
      incompleteTodos.forEach(todo => {
        const li = document.createElement('li');
        li.textContent = todo.text;
        indexTodoList.appendChild(li);
      });
      if (noTodoMessage) noTodoMessage.style.display = 'none';
    } else if (noTodoMessage) {
      noTodoMessage.style.display = 'block';
    }
  }
});

style.css

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    background-color: #f8f9fa;
    color: #343a40;
}

.main-header {
    background-color: #2c3e50; /* Dark blue/grey */
    color: #ecf0f1; /* Light grey */
    padding: 0.8rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    box-sizing:border-box;
}

.main a{
 text-decoration: none;
}

.main pre{
 font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
 margin:0;
 white-space: pre-wrap;
}

.main-header .container {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  width: 100%;         /* ← max-widthをやめて100%表示に */
  margin: 0;           /* ← 中央寄せを解除 */
  box-sizing:border-box;
  padding: 0 20px;
}

.header-left {
    display: flex;
    align-items: center;
}

.main-header .logo a {
    color: #ecf0f1;
    text-decoration: none;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 1px;
    margin-left: 20px; /* ハンバーガーメニューとの間隔 */
}

.main-nav {
    margin-left: 20px; /* サイト名との間隔 */
}

.main-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
}

.main-nav ul li {
    margin-left: 30px;
}

.main-nav ul li a {
    color: #ecf0f1;
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 500;
    transition: color 0.3s ease, transform 0.2s ease;
    position: relative;
}

.main-nav ul li a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -5px;
    left: 0;
    background-color: #3498db; /* Blue accent */
    transition: width 0.3s ease;
}

.main-nav ul li a:hover {
    color: #3498db;
    transform: translateY(-2px);
}

.main-nav ul li a:hover::after {
    width: 100%;
}

/*★★★ ハンバーガーメニューのスタイル ★★★*/
.hamburger-menu {
    width: 30px;
    height: 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    position: relative;
    z-index: 1000;
}

.hamburger-menu .bar {
    display: block;
    width: 100%;
    height: 3px;
    background-color: #ecf0f1;
    border-radius: 3px;
    transition: all 0.3s ease-in-out;
    position: absolute;
    left: 0;
}

.hamburger-menu .bar:nth-child(1) { top: 0; }
.hamburger-menu .bar:nth-child(2) { top: 8px; }
.hamburger-menu .bar:nth-child(3) { top: 16px; }

/* ハンバーガーメニューのアニメーション */
.hamburger-menu.active .bar:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}
.hamburger-menu.active .bar:nth-child(2) {
    opacity: 0;
}
.hamburger-menu.active .bar:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

/* ページ全体のレイアウト */
.page-wrapper {
    display: flex;
    min-height: 200px;
}

/* サイドバーのスタイル */
#sidebar {
    width: 0;
    background-color: #34495e; /* Darker blue/grey */
    color: #ecf0f1;
    padding-top: 20px;
    overflow-x: hidden;
    transition: width 0.15s ease-in-out;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    flex-shrink: 0;
    height:500px;
}

#sidebar.active {
    width: 250px; /* サイドバーの幅 */
    padding: 20px;
}

#sidebar h2 {
    text-align: center;
    margin-bottom: 20px;
    color: #ecf0f1;
}

#sidebar ul {
    list-style: none;
    padding: 0;
}

#sidebar ul li a {
    display: block;
    padding: 10px 15px;
    color: #ecf0f1;
    text-decoration: none;
    transition: background-color 0.3s ease;
}

#sidebar ul li a:hover {
    background-color: #4a627a;
}

/* コンテンツラッパーのスタイル */
.content-wrapper {
    flex-grow: 1;
    transition: margin-left 0.3s ease-in-out;
}

.content-wrapper.sidebar-active {
    margin-left: 0; /* サイドバーが開いたときにコンテンツがずれないように */
}

/* メインコンテンツのスタイル */
.main{
 width:750px;
 margin-top: 20px;
 margin-left:30px;
 min-height: 500px;
 background-color: #fff;
 padding:20px 30px 20px;
}

.hyoudai{
 font-size:26px;
 text-align:center;
 margin-bottom:-20px;
}

.head-i {
 border-left: solid 6px #4865b2;
 font-weight: bold;
 padding-left: 10px;
 padding-top: 2px;
 padding-bottom: 2px;
 line-height:1.4;
 font-size:18px;
 letter-spacing: 1.6px;
 white-space: nowrap;
 margin-bottom: 15px !important; 
}

.head-a {
 border-left: solid 6px #4865b2;
 font-weight: bold;
 padding-left: 10px;
 padding-top: 3px;
 padding-bottom: 3px;
 line-height:1.4;
 font-size:19px;
 letter-spacing: 1.6px;
 white-space: nowrap;
 margin-bottom: -22px !important; 
 margin-top: -4px !important; 
}

.page-title{
 text-align:center;
}

.grayboxpre{
 width:92%;
 background-color:#efefef;
 border:solid 1px gray;
 margin-left:5px;
 padding-bottom: 20px;
 padding-right: 20px;
 padding-left: 20px;
 padding-top:5px;
 display:table;
 margin-bottom:-20px;
 white-space: pre-wrap;
 line-height:1.5;
}

.graybox{
 width:92%;
 background-color:#efefef;
 border:solid 1px gray;
 margin-left:5px;
 padding-bottom: 20px;
 padding-right: 20px;
 padding-left: 20px;
 padding-top:5px;
 display:table;
 margin-bottom:-20px;
 white-space: pre-wrap;
 line-height:1.5;
}

.link-box{
 width:92%;
 background-color:#efefef;
 margin-left:5px;
 padding-bottom: 20px;
 padding-right: 20px;
 padding-left: 20px;
 padding-top:5px;
 display:table;
 margin-bottom:-20px;
 white-space: pre-wrap;
 line-height:1.5;
 cursor: pointer;
 user-select: all;
}

.pre {
 background-color: rgba(250, 250, 250, .48);
 outline: 1px solid rgba(228, 228, 228, .8705882353);
 color: #444;
 overflow: auto;
 display: block;
 list-style-type: disc;
 list-style-position: outside;
 padding: 0px 10px 30px 20px;
 margin-bottom:-10px;
  line-height: 1.7;
}

/* TODOリストのスタイル */
.todo-container {
    margin-top: 20px;
    padding: 20px;
    border: 1px solid #eee;
    border-radius: 8px;
    background-color: #f9f9f9;
}

#todo-input {
    width: calc(100% - 80px);
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-right: 10px;
    font-size: 1rem;
}

#add-todo-btn {
    padding: 10px 15px;
    background-color: #28a745; /* Green */
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s ease;
}

#add-todo-btn:hover {
    background-color: #218838;
}

#todo-list {
    list-style: none;
    padding: 0;
    margin-top: 20px;
}

.todo-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #eee;
    font-size: 1.1rem;
    color: #333;
}

.todo-item:last-child {
    border-bottom: none;
}

.todo-item span {
    flex-grow: 1;
    cursor: pointer;
}

.todo-item.completed span {
    text-decoration: line-through;
    color: #888;
}

.two-column-layout {
    display: flex;
    gap: 20px;
}

.main-content {
    flex: 1;
}

.todo-summary {
    width: 300px;
    border: 1px solid #ccc;
    background-color: #f4f4f4;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}


.delete-btn {
    background-color: #dc3545; /* Red */
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.delete-btn:hover {
    background-color: #c82333;
}

explorer_open.vbs

Cドライブのscriptsフォルダにいれる

' explorer_open.vbs
' 引数で渡されたパスをエクスプローラーで開く

Option Explicit

Dim shell, args, encodedPath, path

Set shell = CreateObject("WScript.Shell")
Set args = WScript.Arguments

If args.Count = 0 Then
    MsgBox "パスが指定されていません。", vbExclamation, "エクスプローラーを開けません"
    WScript.Quit
End If

' 引数から explorer: を除去(ループ防止)
encodedPath = args(0)
If LCase(Left(encodedPath, 9)) = "explorer:" Then
    encodedPath = Mid(encodedPath, 10)
End If

' デコード(念のため %20 などをスペースに戻す)
encodedPath = Replace(encodedPath, "%20", " ")
encodedPath = Replace(encodedPath, "%5C", "\")
encodedPath = Replace(encodedPath, "%25", "%") ' %25 = %

' 最後の \index.html などを削除してフォルダパスに変換(もし拡張子が .html なら)
If LCase(Right(encodedPath, 5)) = ".html" Then
    path = Left(encodedPath, InStrRev(encodedPath, "\") - 1)
Else
    path = encodedPath
End If

' パスが存在するか確認
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(path) Then
    MsgBox "指定されたパスが存在しません: " & vbCrLf & path, vbExclamation, "エクスプローラーで開けません"
    WScript.Quit
End If

' エクスプローラーで開く
shell.Run "explorer.exe """ & path & """", 1, False

note_open.vbs

Cドライブのscriptsフォルダにいれる

Option Explicit

Dim shell, rawArg, decodedArg, finalPath, command
Set shell = CreateObject("WScript.Shell")

If WScript.Arguments.Count = 0 Then
    MsgBox "引数がありません。", 48, "エラー"
    WScript.Quit
End If

' note: で始まる引数を取り出し
rawArg = WScript.Arguments(0)
If Left(rawArg, 5) = "note:" Then
    rawArg = Mid(rawArg, 6)
End If

' URLデコード関数(%xx形式 → 文字)
Function UrlDecode(str)
    Dim i, ch, code
    i = 1
    Do While i <= Len(str)
        ch = Mid(str, i, 1)
        If ch = "%" Then
            code = Mid(str, i + 1, 2)
            UrlDecode = UrlDecode & Chr(CLng("&H" & code))
            i = i + 3
        Else
            UrlDecode = UrlDecode & ch
            i = i + 1
        End If
    Loop
End Function

decodedArg = UrlDecode(rawArg)
decodedArg = Replace(decodedArg, "/", "\")

' ダブルクォートで囲んで実行
finalPath = Chr(34) & decodedArg & Chr(34)
command = "notepad.exe " & finalPath
shell.Run command, 1, False

memo.reg

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\note]
@="URL:Note Protocol"
"URL Protocol"=""

[HKEY_CURRENT_USER\Software\Classes\note\shell\open\command]
@="wscript.exe \"C:\\scripts\\note_open.vbs\" \"%1\""

erplorer.reg

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\explorer\shell\open\command]
@="wscript.exe \"C:\\scripts\\explorer_open.vbs\" \"%1\""

[HKEY_CURRENT_USER\Software\Classes\explorer]
@="URL:Explorer Protocol"
"URL Protocol"=""
よかったらシェアしてね!
  • URLをコピーしました!

この記事を書いた人

コメント

コメントする

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)

目次