@crosscopy/clipboard 0.1.5 → 0.1.7
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.
package/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# General Clipboard Listener
|
|
2
2
|
|
|
3
3
|
> A Cross-Platform clipboard listener that listens for both text and image (screenshots).
|
|
4
|
+
> Designed for NodeJS, not for web.
|
|
5
|
+
> Provides API to read and write text/image from/to clipboard.
|
|
4
6
|
|
|
5
|
-
npm package: https://www.npmjs.com/package/
|
|
7
|
+
npm package: https://www.npmjs.com/package/@crosscopy/clipboard
|
|
6
8
|
|
|
7
9
|
## Installation
|
|
8
10
|
|
|
@@ -99,6 +101,8 @@ If your nodejs gives different platform or arch, it may not work.
|
|
|
99
101
|
|
|
100
102
|
Cross Compile doesn't work due to some CGO problem. Have to build on different platforms manually.
|
|
101
103
|
|
|
104
|
+
Within `go-clipboard` folder.
|
|
105
|
+
|
|
102
106
|
```bash
|
|
103
107
|
go build -o binaries/go-clipboard-darwin-arm64
|
|
104
108
|
go build -o binaries/go-clipboard-darwin-x64
|
|
@@ -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)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crosscopy/clipboard",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
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",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "git+https://github.com/
|
|
17
|
+
"url": "git+https://github.com/CrossCopy/clipboard.git"
|
|
18
18
|
},
|
|
19
19
|
"keywords": [
|
|
20
20
|
"clipboard"
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"author": "Huakun Shen",
|
|
23
23
|
"license": "ISC",
|
|
24
24
|
"bugs": {
|
|
25
|
-
"url": "https://github.com/
|
|
25
|
+
"url": "https://github.com/CrossCopy/clipboard/issues"
|
|
26
26
|
},
|
|
27
|
-
"homepage": "https://github.com/
|
|
27
|
+
"homepage": "https://github.com/CrossCopy/clipboard#readme",
|
|
28
28
|
"dependencies": {},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@jest/globals": "^29.3.1",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"files": [
|
|
40
40
|
"dist",
|
|
41
41
|
"go-clipboard/binaries",
|
|
42
|
-
"
|
|
43
|
-
"
|
|
42
|
+
"go-clipboard/scripts",
|
|
43
|
+
"README.md"
|
|
44
44
|
]
|
|
45
45
|
}
|