Skip to content

Launching external apps

Yoshifumi Fuyuno edited this page Oct 23, 2022 · 2 revisions

Anyone can edit freely.

If you have a good examples, please share it.

To use this function

  • SPCNMH must be installed.
  • Require nativeMessaging permission. (add-on options -> "General" -> "Bookmarklet: request optional_permissions")

After meeting the above conditions, restart your browser.

Usage

Use this as a bookmarklet.

  • spc.spc.sendNativeMessage(message)
    • Parameters
      message
      object. An object with the following properties:
      path (Optional)
      string. External program path and arguments.
      cwd (Optional)
      string. Current working directory.
    • Return value
      Promise.

e.g.

javascript:spc.spc.sendNativeMessage({path: String.raw`"C:\Program Files\Google\Chrome\Application\chrome.exe" "${{searchTerms}}"`});
javascript:spc.spc.sendNativeMessage({path: String.raw`"C:\Program Files\Google\Chrome\Application\chrome.exe" "${location}"`});
javascript:spc.spc.sendNativeMessage({path: String.raw`start yt-dlp -P "%USERPROFILE%\Desktop" "${location}"`});
javascript:{const filepath = `%temp%\\${location.pathname.split("/").pop()}`; spc.spc.sendNativeMessage({path: String.raw`curl -o "${filepath}" "${location}" & mspaint.exe "${filepath}"`})};

Note: Currently, the exe version of SPCNMH runs as an x86 application. Therefore, on Windows x64, the environment variable "%ProgramFiles%" refers to "C:\Program Files (x86)".

Clone this wiki locally