Skip to content

Windows screen grab gets saved as a list #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ReKylee opened this issue Dec 24, 2024 · 0 comments
Open

Windows screen grab gets saved as a list #15

ReKylee opened this issue Dec 24, 2024 · 0 comments

Comments

@ReKylee
Copy link

ReKylee commented Dec 24, 2024

When I try to screen grab using WIN + Shift + S, I can't paste the image at all.
Here's the original error:

line    1:
E5108: Error executing lua Vim:Error invoking 'python_execute' on channel 3 (python3-script-host):
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    import sys; sys.path = [p for p in sys.path if p != ""]; import neovim; neovim.start_host()
    ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<USERNAME>\AppData\Local\nvim-data\lazy\pastify.nvim\python3\pastify\main.py", line 90, in paste_text
    img.save(img_bytes, format="PNG")
    ^^^^^^^^
AttributeError: 'list' object has no attribute 'save'
stack traceback:
	[C]: at 0x7ff6b58fdf40

I've tried fiddling with that function as such:

 img = ImageGrab.grabclipboard()
# ImageGrab.grabclipboard returns either a: Image, List of file names or None (text)
if isinstance(img, Image.Image):  # Check if clipboard contains an image
    img_bytes = BytesIO()
    img.save(img_bytes, format="PNG")
elif isinstance(img, list):  # Check if clipboard contains file paths
    self.logger(f"Clipboard contains files: {img}", "INFO")
    return
else:
# Handle non-image content as text
    if after:
        vim.command('normal! "+p')
    else:
        vim.command('normal! "+P')
    return

and here's the output I get:

Clipboard contains files: ['C:\Users\<USERNAME>\AppData\Local\Packages\MicrosoftWindows.Client.Core_cw5n1h2txyewy\TempState\ScreenClip\{2B604A04-454F-4548-9661-5D1DCE676C9A}.png']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant