From c7f8f37c62b00646fb632d9599209a5df7402e07 Mon Sep 17 00:00:00 2001 From: Jim Caten Date: Thu, 21 Apr 2022 02:07:01 -0500 Subject: [PATCH 1/2] Adds PowerShell script for Greenshot Curl is needed as Invoke-WebRequest and Invoke-RestMethod don't like uploading files easily. Curl simplifies the process down to one line of code. --- rtfm/INTEGRATIONS.md | 66 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/rtfm/INTEGRATIONS.md b/rtfm/INTEGRATIONS.md index a88dc15..fb125c6 100644 --- a/rtfm/INTEGRATIONS.md +++ b/rtfm/INTEGRATIONS.md @@ -43,4 +43,68 @@ result=$(curl -s -F "file=@${1}" https://pictshare.net/api/upload.php | jq -r .u xclip -selection clipboard -t image/png -i $1 google-chrome $result -``` \ No newline at end of file +``` + +# Screenshot to pictshare (windows) + +This script will upload a screenshot from [Greenshot](https://getgreenshot.org/) to PictShare with the help of a PowerShell script. + +Requirements: +- curl (choco install curl) +- [PowerShell 7](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows) + +Configure Greenshot: +- Settings -> Output + - Storage location: C:\Temp\ + - Filename pattern: GreenShot + - Image format: jpg +Create a new External command, under Settings -> Plugins -> Click on External command Plugin -> Configure -> New +- Name: what ever you want here +- Command: find and point to pwsh.exe +- Argument: -F Path\to\this\script -Address consto.com + +Create a PowerShell script with the code below. + +Feel free to change "C:\Temp\GreenShot.jpg" and "C:\Temp\pictshare_posts.json" to match your needs. + +pictshare_posts.json is useful for logging and automating deleting old uploads. + +```powershell +#Requires -Version 7 + +param ( + # Change the base url to match your Pictshare server + [Parameter(Mandatory)][string]$Address, + # Change path of where you expect the jpg file to be + [string]$File = "C:\Temp\GreenShot.jpg", + # Log file of all requests + [string]$LogFile = "C:\Temp\pictshare_posts.json", + # Use http and not https + [switch]$IsNotHttps, + # Do not save url to upload to the clipboard + [switch]$NoSaveToClipboard +) +begin { + $Protocol = if ($IsNotHttps){ + "http:" + }else{ + "https:" + } +} +process { + # Upload screenshot + $Response = $(curl -s -F "file=@$File" $Protocol//$Address/api/upload.php) | ConvertFrom-Json + if ($Response.status -like "ok") { + if ($NoSaveToClipboard){ + # Don't save url to clipboard + }else{ + Set-Clipboard -Value $Response.url + } + } + # Output response back from the pictshare server + if($Response){ + $Response | ConvertTo-Json | Out-File -FilePath $LogFile -Append + } +} +end {} +``` From 45b2e117294f8ded0eb89c0434cff8f2a4ccf86d Mon Sep 17 00:00:00 2001 From: Jim Caten Date: Thu, 21 Apr 2022 02:15:26 -0500 Subject: [PATCH 2/2] Adds window style Hidden to PowerShell script --- rtfm/INTEGRATIONS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rtfm/INTEGRATIONS.md b/rtfm/INTEGRATIONS.md index fb125c6..a061c48 100644 --- a/rtfm/INTEGRATIONS.md +++ b/rtfm/INTEGRATIONS.md @@ -61,7 +61,7 @@ Configure Greenshot: Create a new External command, under Settings -> Plugins -> Click on External command Plugin -> Configure -> New - Name: what ever you want here - Command: find and point to pwsh.exe -- Argument: -F Path\to\this\script -Address consto.com +- Argument: -w Hidden -F Path\to\this\script -Address consto.com Create a PowerShell script with the code below.