Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[function] Virtual clipboards+


  • Please log in to reply
28 replies to this topic
Learning one
  • Members
  • 1483 posts
  • Last active: Jan 02 2016 02:30 PM
  • Joined: 04 Apr 2009
I remember that when I was writing and testing VirClip(), I concluded that Clipboard, Cut, Copy, Paste sometimes act very strange. Some lines in VirClip() may seem strange and redundant, but as I can remember, I put them in because I concluded they improve reliability.
#1. This is one of examples of what I wrote above. When dealing with clipboard, I remember I concluded that
While !(Clipboard = "") { 
         Clipboard = 
         Sleep, 10 
      }
is more reliable than just Clipboard := "" or Clipboard = . Yes, I know it's strange or maybe wrong conclusion.

#2. Sleeps improve reliability, that's true. I agree that sleep after paste should be longer.
#3. Clipboard := Clipboard filters Clipboard contents to just text.

save the clips to files? That way they could be preserved between reloads. Like Clips\Clip1.dat for instance.

Nice idea. Maybe I'll implement it later.

cause I doubt it's your script.

:!: :?: Why do you think so? Who's function do you think it is? Of course it's mine.

thinkstorm
  • Members
  • 40 posts
  • Last active: Sep 10 2014 06:06 PM
  • Joined: 17 Aug 2004
Why not use Ditto? Or was the idea to specifically copy its functions in AHK?
<!-- m -->http://ditto-cp.sourceforge.net/<!-- m -->
Cheers,

Thorsten

Learning one
  • Members
  • 1483 posts
  • Last active: Jan 02 2016 02:30 PM
  • Joined: 04 Apr 2009
Haven't tried it yet, but looks like nice app. Thanks for the link. I didn't know about it until today, but it's nice to have AHK version too ;)

berban!
  • Guests
  • Last active:
  • Joined: --

cause I doubt it's your script.


Lol! All I meant was I doubt the bug was being caused by your script: i.e. it's a bug with AutoHotkey's clipboard interactions, and not a bug in your code. :p

Yeah, as I said I tested the reliability of Clipboard := "" and it was fine, but if you got different results it probably just varies from computer to computer. So I guess stick to whatever works right?

Clipboard := Clipboard filters Clipboard contents to just text.


Are you sure about this? I thought ClipboardAll was the variable that contained all clipboard data (as the name suggests) whereas Clipboard is always text-only. Furthermore, I was under the impression that a := a never had any effect in AutoHotkey. (It doesn't even trim like a = %a% does.)

berban?
  • Guests
  • Last active:
  • Joined: --
Sorry, caint edit since I'm signed in as guest...

Just wanted to add that, of course, the statement a := a wouldn't be a big deal even if it did nothing. The only difference is that Clipboard assignments take a while for whatever reason.

You've probably noticed this yourself. I'd noticed it; however, I never tested it until just now. According to my test, retrieving the value of the Clipboard (a := Clipboard) takes about 15 times longer than retrieving another variable (a := B). So that's not a huge deal. But changing the value of the Clipboard (Clipboard := a) takes 3000 times longer than a normal assignment!! :O

So at any rate, what I've taken away from noticing this is to always store the contents of the clipboard in another variable before I start to mess around with it, then I put it back when I'm done.

Learning one
  • Members
  • 1483 posts
  • Last active: Jan 02 2016 02:30 PM
  • Joined: 04 Apr 2009
@Berban:
I totally misunderstood meaning of "... cause I doubt it's your script". My apologies. :oops:

I appreciate your observations and suggestions, but I'm currently busy so I won't work on VirClip() for a while. In the meanwhile, everybody is welcome to improve it and post it here. After all, VirClip() is public domain.

berban_
  • Members
  • 202 posts
  • Last active: Aug 05 2014 11:52 PM
  • Joined: 16 Mar 2011
Haha, no worries, I found it funny not offensive, I knew exactly what was going on.

About the being busy: sure thing, I hear ya. It was interesting for me to do those tests as well. Hope you keep up your AutoHotkey skills! :)

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010

Clipboard := Clipboard filters Clipboard contents to just text.


Are you sure about this?

Yes. It's in the Clipboard documentation

berban_
  • Members
  • 202 posts
  • Last active: Aug 05 2014 11:52 PM
  • Joined: 16 Mar 2011
:?: :?:
Where?

I see this:

clipboard = %clipboard%

but that's different

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
no, that's te same. The basic concept:
- Clipboard used in GET is text
- ClipboardAll used in GET is binary
- Clipboard used in SET accepts either.
Therefore:
Clipboard := Clipboard
Assigns TEXT from clipboard in GET to the clipboard, eliminating any 'binary' stuff

  • Guests
  • Last active:
  • Joined: --

no, that's the same.

Are you really sure, try this
clipboard:= "   this is some text     "

MsgBox % "|" clipboard "|"

clipboard:=clipboard

MsgBox % "|" clipboard "|" ; no change

clipboard=%clipboard% 

MsgBox % "|" clipboard "|" ; leading + trailing spaces removed


nimda nli
  • Guests
  • Last active:
  • Joined: --
Ahem, it encompasses the same functionality within the context of this thread

azure
  • Members
  • 1216 posts
  • Last active: Mar 18 2015 09:06 AM
  • Joined: 07 Jun 2007
what is the 30 limit for?

Focuscar
  • Members
  • 13 posts
  • Last active: May 13 2015 06:23 PM
  • Joined: 26 May 2013

Thanks, useful script.

 

BUT the script is about "Virtual Clipboard" and not selected text.

 

- The Thread should really start with "Copy To", which is not well explained that is "Set Text": "VirClip("s",3,"set text")  

- selected text is just extra features.

 

Anyway thanks for the script although I found some bugs on my specific computer.