Home / GitHub Page

Send screenshot to Joplin (Windows)

Since Joplin doesn’t provide a way to take desktop screenshot and save it automatically, I thought to find a solution.

This depending on 2 components:

  1. ShareX, a free and open source program that lets you capture or record any area of your screen,
  2. Powershell, a task-based command-line shell and scripting language built on .NET.

First, create Powershell script to invoke API POST to Joplin:

I named it post.ps1 and saved it to C:\Users\rami\Downloads\. Following the script content:

# Joplin API endpoint and POST params
$url = "http://127.0.0.1:41184/notes?token=PLACE YOUR TOKEN HERE"

# Convert image to base64
$image_data_url = [convert]::ToBase64String((Get-Content $args[0] -Encoding byte))

#Forming API parameters
$params = -join("{ ""title"": ""Screenshot"", ""parent_id"": ""PLACE FOLDER ID HERE"", ""image_data_url"": ""data:image/png;base64,",$image_data_url,"""}")

#Make API POST request
Invoke-WebRequest $url -Method Post -Body $params

Note: you need to PLACE YOUR TOKEN HERE and PLACE FOLDER ID HERE.

Second, configure ShareX HotKey settings…

  1. For example, customize “Capture region”
    ShareX_-_Hotkey_settings_20191230192957
  2. In “Task”, check “Override after capture settings” and select “Save image to file”, and “Perform actions”
  3. In “Actions”, check “Override actions” and click “Add”. Fill-in the name “Post to Joplin”, “File Path” (where powershell.exe) and “Arguments” (-File full path+file name of the script created in FIRST step and don’t forget to add %input at the end)
    ShareX_-_Actions_20191230224156
    It should look something similar to this:

Now, whenever you take screenshot with (Ctrl+Print Screen), it’ll be saved in Joplin.

2 Likes

where do I find the PLACE FOLDER ID?

I use insomnia rest client to get such information from Joplin api.

Using insomnia:

  1. Select GET method
  2. Use url = http://127.0.0.1:41184/folders
  3. In Query tab, add item name = token and item value = your token
  4. Click Send

You will get all your folders with folder IDs.

For newbies like me who struggle to get this working:

  1. The ‘token’ refered to in ‘PLACE YOUR TOKEN HERE’ is the Joplin Authorisation token found in Tools > Options > Web Clipper > Advanced Options

  2. The WebClipper Sevice needs to be running

  3. If PowerShell ExecutionPolicy is set to Restricted, need to to run PowerShell as administrator and Set-ExecuitionPolicy RemoteSigned

1 Like

For JoplinPortable users that have their post.ps1 file on the same drive as their ShareXPortable app I have found that you can omit the drive letter and colon from the path to the post.ps1 file so this feature can work as you move your USB drive between computers when the drive letter might change.

I have my post.ps1 file next to ShareX’s HotkeysConfig.json file:

X:\PortableApps\ShareXPortable\Data\post.ps1
X:\PortableApps\ShareXPortable\Data\HotkeysConfig.json

so ShareX - Actions - Arguments field is:

-File \PortableApps\ShareXPortable\Data\post.ps1 %input

1 Like