@crosscopy/clipboard 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,23 @@
1
+ # get clipboard image, convert to base64 string and output to stdout
2
+
3
+ $image = Get-Clipboard -format image
4
+
5
+ if ($null -eq $image) {
6
+ Write-Output "NO_IMAGE"
7
+ } else {
8
+ # Save the image to a temporary file
9
+ $tempFile = [System.IO.Path]::GetTempFileName()
10
+ $image.Save($tempFile)
11
+
12
+ # Read the contents of the temporary file as a byte array
13
+ $bytes = Get-Content -Path $tempFile -Encoding Byte
14
+
15
+ # Convert the byte array to a base64 string
16
+ $base64 = [System.Convert]::ToBase64String($bytes)
17
+
18
+ # Delete the temporary file
19
+ Remove-Item -Path $tempFile -Force
20
+
21
+ # Output the base64 string
22
+ Write-Output $base64
23
+ }
@@ -0,0 +1 @@
1
+ [System.Windows.Forms.Clipboard]::GetText()
@@ -0,0 +1,15 @@
1
+ # save image from db to a tmp file on disk first, get path from arg
2
+ # $imagePath = "C:\path\to\your\image.png"
3
+ param (
4
+ [string]$imagePath
5
+ )
6
+
7
+ # # Load the image into a System.Drawing.Image object
8
+ [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
9
+ $image = [System.Drawing.Image]::FromFile($imagePath)
10
+ # Write-Output $image
11
+ # # Write the image to the clipboard
12
+ # https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.clipboard?view=windowsdesktop-7.0
13
+ [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
14
+ [System.Windows.Forms.Clipboard]::SetData("PNG", $image)
15
+ [System.Windows.Forms.Clipboard]::SetImage($image)
@@ -0,0 +1,7 @@
1
+
2
+ # param (
3
+ # [string]$content
4
+ # )
5
+ $stdin= Read-Host
6
+ Write-Output $stdin
7
+ [System.Windows.Forms.Clipboard]::SetText($stdin)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crosscopy/clipboard",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Cross Platform Clipboard listener that detects both text and image update in clipboard",
5
5
  "source": "index.ts",
6
6
  "types": "./dist/index.d.ts",
@@ -39,7 +39,7 @@
39
39
  "files": [
40
40
  "dist",
41
41
  "go-clipboard/binaries",
42
- "README.md",
43
- "src/scripts"
42
+ "go-clipboard/scripts",
43
+ "README.md"
44
44
  ]
45
45
  }