-
Notifications
You must be signed in to change notification settings - Fork 676
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
Checking if clipboard is available on windows #3541
Comments
I think there is no bug here. From what I understand, you copy text to the clipboard and after the reboot the clipboard is reset and it does not contain any value. The other situation is that you copy text to the clipboard and then take a screenshot and of course the text is no longer on the clipboard but the screenshot is. If you try to do the same with Notepad you also get the same result, because the image is not compatible with text. |
You are right. However, what I meant is that, for example, after a PC reboot, when I try to copy text to the clipboard using |
So in this case just use the following:
|
I think he is saying that once printscreen is used before app starts then copy to clipboard fails from then on - not that the clipboard text is being overwritten. i.e. that the code which checks whether clipboard is working on OS Windows is bugged and is saying there is no clipboard implementation when really there is. Basically the constructor for WindowsClipboard is asking OS if there is text data available to paste. What it should be doing is asking windows if clipboard functionality exists at all. So should just be: public WindowsClipboard ()
{
IsSupported = true;
} What code should probably be The real issue here is that IsSupported is set once only when the driver is created then used like a way to decide whether the user can copy/paste from that point on: public WindowsDriver ()
{
WinConsole = new WindowsConsole ();
clipboard = new WindowsClipboard ();
isWindowsTerminal = Environment.GetEnvironmentVariable ("WT_SESSION") != null;
} |
Now I got it, sorry. I was doing a print screen after open the Terminal.Gui. Now opening the app after the print screen I confirm now that this is bugged for sure. |
Yes, that is what I meant |
Describe the bug
I am developing a simple password manager in F# and I noticed that after rebooting or taking a screenshot, all of a sudden I can't access the clipboard from my app. When I checked what the issue was, I discovered that the
IsSupported
field fromClipboard
class is false, which results in not being able to access or set data in the clipboard. In the Windows implementation, checking if the clipboard is supported is based on this piece of code:So basically, we are checking if the current format of the clipboard is UnicodeText, not if the clipboard is available on the given platform.
So whenever I take a screenshot and then run my app (which uses clipboard functionality from Terminal.Gui) on a Windows device, it stops working as intended.
Also, I think it is worth mentioning that if app already runs and I take a screenshot, everything works as intended.
I tried this simple workaround which seems to work fine, but before submitting a PR, I wanted to confirm that I am not overlooking some edge cases:
To Reproduce
If you want to reproduce this issue you can try it using my app. Try copying a password to the clipboard after a PC reboot or after taking a screenshot.
The text was updated successfully, but these errors were encountered: