Skip to content

Commit

Permalink
Merge pull request #138 from quonic/master
Browse files Browse the repository at this point in the history
Adds PowerShell script for Greenshot on Windows
  • Loading branch information
geek-at committed May 12, 2022
2 parents 6ad94f2 + 96e73e2 commit 0346419
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions rtfm/INTEGRATIONS.md
Expand Up @@ -45,6 +45,70 @@ xclip -selection clipboard -t image/png -i $1
google-chrome $result
```

# 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: -w Hidden -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 {}
# PHP
```php
Expand Down

0 comments on commit 0346419

Please sign in to comment.