Clipboard Topic is solved

Discuss the future of the AutoHotkey language
User avatar
Flipeador
Posts: 1204
Joined: 15 Nov 2014, 21:31
Location: Argentina
Contact:

Clipboard

28 May 2018, 11:23

Hello!
I would like to propose a change regarding the current behavior of AHK with the clipboard. Apparently, when you set text to the clipboard, it is first emptied, so any other format is completely lost... Is this the behavior we want?; I mean, if you copy a file and then change the clipboard text (CF_UNICODETEXT), then the CF_HDROP data is lost (related).
I know, specifying an empty string Clipboard:="" is useful for using with ClipWait, but... You lose all other formats!.
Would not it be better to have a separate method/function to empty the clipboard? (ClipboardEmpty or Clipboard:=ClipboardAll(0) or Clipboard NewText [, Empty?]).

Maybe I missed something, if that is the case, please let me know.
:wave:
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: Clipboard

28 May 2018, 15:13

Yes this is the behaviour you want.
Clipboard replaces the current content of the clipboard with another one. A single content may be available in multiple formats. Making the replacement of content the default beahviour makes the most sense.
If you want advanced clipboard functionality I reccomend the DllCall functions ( although you probably know them already. )
Recommends AHK Studio
User avatar
Flipeador
Posts: 1204
Joined: 15 Nov 2014, 21:31
Location: Argentina
Contact:

Re: Clipboard

28 May 2018, 15:49

I propose this because the use of the clipboard is quite common and there are many scripts that make use of it. I do not think that this is something advanced, it seems to me something very basic and useful.
A single content may be available in multiple formats
But, this does not make sense. If you are going to establish plain text on the clipboard, the ideal is using the CF_UNICODETEXT format, so all applications can use it. In addition, AutoHotkey only recognizes 3 formats: CF_TEXT, CF_UNICODETEXT and CF_HDROP.

Why delete all other formats If you are only going to establish text?.
User avatar
Flipeador
Posts: 1204
Joined: 15 Nov 2014, 21:31
Location: Argentina
Contact:

Re: Clipboard

28 May 2018, 16:33

A new ClipboardEmpty function would be fine and convert the Clipboard variable to a function.
Clipboard [StrOrAddr] [, SizeAddr] [, Format]
If StrOrAddr is omited, get te content in the specified format (default text). If the specified format is not text (CF_TEXT or CF_UNICODETEXT), you can return a memory address and SizeAddr the size of the content.
If SrrOrAddr is 0, delete the specified format.
In any other case, it establishes the content in the specified format.
Although I recognize that this could be considered "advanced".
User avatar
Flipeador
Posts: 1204
Joined: 15 Nov 2014, 21:31
Location: Argentina
Contact:

Re: Clipboard  Topic is solved

28 May 2018, 17:40

Well, I've been thinking it better and maybe the current behavior is the most appropriate, although I have not been able to do tests because I'm not at home.
I have thought that if an application creates its own format to store text, it will give priority to that format and CF_UNICODETEXTcould be ignored. So emptying the clipboard is the best. Even so, the function that I proposed in my previous comment could be very useful to register our own format and store text in a line of code Clipboard("Text",, "some format name").
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: Clipboard

28 May 2018, 23:47

Well the most basic reason why a simple solution wouldn't work with your idea is bugs.
Imagine if word set the clipboards normal text format and it's own special formatted text format.
Now we only overwrite the normal text but keep the formatted text.
When we now press Ctrl+V in Word we won't get the content we stored into the clipboard but rather the data that was inside before because Word will prefer the special format.
Recommends AHK Studio
User avatar
Flipeador
Posts: 1204
Joined: 15 Nov 2014, 21:31
Location: Argentina
Contact:

Re: Clipboard

29 May 2018, 00:24

Yes, I said that in my previous comment, and I thought exactly in Word as well. :)
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: Clipboard

01 Jun 2018, 21:26

If you assign a := b, would you expect a to now contain b and other, previously-stored data?

Assignment semantics require that Clipboard := x replaces the current clipboard content.
aenigma14344

Re: Clipboardaf

14 Jul 2018, 13:23

Flipeador wrote:Well, I've been thinking it better and maybe the current behavior is the most appropriate, although I have not been able to do tests because I'm not at home.
I have thought that if an application creates its own format to store text, it will give priority to that format and CF_UNICODETEXTcould be ignored. So emptying the clipboard is the best. Even so, the function that I proposed in my previous comment could be very useful to register our own format and store text in a line of code Clipboard("Text",, "some format name").

Return to “AutoHotkey Development”

Who is online

Users browsing this forum: No registered users and 25 guests