mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2006
Posts: 167
P
Vogon poet
OP Offline
Vogon poet
P
Joined: Aug 2006
Posts: 167
mIRC seems to randomly fail to add a new line to the clipboard with the -an switch (possibly due to rapid use in a while loop?). And sometimes after such a failure, $cb(0) returns null.

I can't find any pattern to the failures: they're completely random. They occur for me in both 7.19 and 7.23 beta.

Can anyone else reproduce this?

1. Add this alias:

Code:
F3 {

  var %n = 1

  echo -s Clipboard starting lines....: " $+ $cb(0) $+ "

  while (%n <= $cb(0)) {
    hadd -m cbfilter %n $cb(%n)
    inc %n
  }

  echo -s Clipboard hashtable lines...: " $+ $hget(cbfilter,0).item $+ "

  var %n = 1

  while (%n <= $hget(cbfilter,0).item) {
    clipboard $+(-,$iif(%n == 1,n,an)) $hget(cbfilter,%n)
    inc %n
  }

  echo -s Clipboard rebuilding loop...: " $+ $calc(%n - 1) $+ "
  echo -s Clipboard new lines.........: " $+ $cb(0) $+ "

  linesep -s
  hfree cbfilter
}

2. Copy some text to your Windows clipboard from anywhere (at least 40-50 or so lines).

3. Go back into mIRC and with your status window visible, repeatedly press (or just hold down) F3.

Here's what happens for me with 44 lines in my clipboard (status window output):

Code:
Clipboard starting lines....: "44"
Clipboard hashtable lines...: "44"
Clipboard rebuilding loop...: "44"
Clipboard new lines.........: ""
-
Clipboard starting lines....: "25"
Clipboard hashtable lines...: "25"
Clipboard rebuilding loop...: "25"
Clipboard new lines.........: "25"
-
Clipboard starting lines....: "25"
Clipboard hashtable lines...: "25"
Clipboard rebuilding loop...: "25"
Clipboard new lines.........: "25"
-
Clipboard starting lines....: "25"
Clipboard hashtable lines...: "25"
Clipboard rebuilding loop...: "25"
Clipboard new lines.........: "25"
-
Clipboard starting lines....: "25"
Clipboard hashtable lines...: "25"
Clipboard rebuilding loop...: "25"
Clipboard new lines.........: "25"
-
Clipboard starting lines....: "25"
Clipboard hashtable lines...: "25"
Clipboard rebuilding loop...: "25"
Clipboard new lines.........: "25"
-
Clipboard starting lines....: "25"
Clipboard hashtable lines...: "25"
Clipboard rebuilding loop...: "25"
Clipboard new lines.........: "25"
-
Clipboard starting lines....: "25"
Clipboard hashtable lines...: "25"
Clipboard rebuilding loop...: "25"
Clipboard new lines.........: "25"
-
Clipboard starting lines....: "25"
Clipboard hashtable lines...: "25"
Clipboard rebuilding loop...: "25"
Clipboard new lines.........: ""
-
Clipboard starting lines....: "18"
Clipboard hashtable lines...: "18"
Clipboard rebuilding loop...: "18"
Clipboard new lines.........: "18"
-
Clipboard starting lines....: "18"
Clipboard hashtable lines...: "18"
Clipboard rebuilding loop...: "18"
Clipboard new lines.........: ""
-
Clipboard starting lines....: "18"
Clipboard hashtable lines...: "18"
Clipboard rebuilding loop...: "18"
Clipboard new lines.........: "18"
-
Clipboard starting lines....: "18"
Clipboard hashtable lines...: "18"
Clipboard rebuilding loop...: "18"
Clipboard new lines.........: "18"
-
Clipboard starting lines....: "18"
Clipboard hashtable lines...: "18"
Clipboard rebuilding loop...: "18"
Clipboard new lines.........: "18"
-
Clipboard starting lines....: "18"
Clipboard hashtable lines...: "18"
Clipboard rebuilding loop...: "18"
Clipboard new lines.........: ""
-
Clipboard starting lines....: "16"
Clipboard hashtable lines...: "16"
Clipboard rebuilding loop...: "16"
Clipboard new lines.........: "16"
-
Clipboard starting lines....: "16"
Clipboard hashtable lines...: "16"
Clipboard rebuilding loop...: "16"
Clipboard new lines.........: "16"
-

I copied the same 44 lines back to the clipboard and tried again, results were similar but different than previous time (above):

Code:
Clipboard starting lines....: "44"
Clipboard hashtable lines...: "44"
Clipboard rebuilding loop...: "44"
Clipboard new lines.........: "44"
-
Clipboard starting lines....: "44"
Clipboard hashtable lines...: "44"
Clipboard rebuilding loop...: "44"
Clipboard new lines.........: "40"
-
Clipboard starting lines....: "40"
Clipboard hashtable lines...: "40"
Clipboard rebuilding loop...: "40"
Clipboard new lines.........: "40"
-
Clipboard starting lines....: "40"
Clipboard hashtable lines...: "40"
Clipboard rebuilding loop...: "40"
Clipboard new lines.........: "40"
-
Clipboard starting lines....: "40"
Clipboard hashtable lines...: "40"
Clipboard rebuilding loop...: "40"
Clipboard new lines.........: "39"
-
Clipboard starting lines....: "39"
Clipboard hashtable lines...: "39"
Clipboard rebuilding loop...: "39"
Clipboard new lines.........: ""
-
Clipboard starting lines....: "29"
Clipboard hashtable lines...: "29"
Clipboard rebuilding loop...: "29"
Clipboard new lines.........: ""
-
Clipboard starting lines....: "18"
Clipboard hashtable lines...: "18"
Clipboard rebuilding loop...: "18"
Clipboard new lines.........: "18"
-
Clipboard starting lines....: "18"
Clipboard hashtable lines...: "18"
Clipboard rebuilding loop...: "18"
Clipboard new lines.........: "18"
-
Clipboard starting lines....: "18"
Clipboard hashtable lines...: "18"
Clipboard rebuilding loop...: "18"
Clipboard new lines.........: "15"
-
Clipboard starting lines....: "15"
Clipboard hashtable lines...: "15"
Clipboard rebuilding loop...: "15"
Clipboard new lines.........: "15"
-
Clipboard starting lines....: "15"
Clipboard hashtable lines...: "15"
Clipboard rebuilding loop...: "15"
Clipboard new lines.........: "15"
-
Clipboard starting lines....: "15"
Clipboard hashtable lines...: "15"
Clipboard rebuilding loop...: "15"
Clipboard new lines.........: "15"
-
Clipboard starting lines....: "15"
Clipboard hashtable lines...: "15"
Clipboard rebuilding loop...: "15"
Clipboard new lines.........: "15"
-
Clipboard starting lines....: "15"
Clipboard hashtable lines...: "15"
Clipboard rebuilding loop...: "15"
Clipboard new lines.........: "15"
-
Clipboard starting lines....: "15"
Clipboard hashtable lines...: "15"
Clipboard rebuilding loop...: "15"
Clipboard new lines.........: "15"
-
Clipboard starting lines....: "15"
Clipboard hashtable lines...: "15"
Clipboard rebuilding loop...: "15"
Clipboard new lines.........: "15"
-

Joined: Dec 2002
Posts: 5,502
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,502
I was not able to reproduce this issue, however I recall seeing similar reports in the past. The most common reason is that another application is also monitoring/accessing the clipboard. As only one application can access the clipboard at any one time, this can lead to other applications being blocked.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Yeah, here is one of the threads about it. The last post explains what happened for that person.


Invision Support
#Invision on irc.irchighway.net
Joined: Aug 2006
Posts: 167
P
Vogon poet
OP Offline
Vogon poet
P
Joined: Aug 2006
Posts: 167
Thanks. I would have assumed the Windows clipboard queued rather than blocked calls. And I found the culprit: an open RealVNC Viewer 4.1.3 window on the same machine as mIRC. It had been open to a headless machine for days. The viewer was evidently sensing mIRC's clipboard modifications and attempting to copy each one into its program space. Once the viewer was closed, I could hold F3 indefinitely in mIRC with no problems.


Since this issue can be caused by any number of programs (a la the link from Riamus2), perhaps two things could be done:

Native &binvar support for /clipboard. This would allow (even large) multi-line clipboard payloads to be constructed in advance, so that /clipboard need be executed only once, keeping mIRC "out of the way" of other applications which sense and then immediately read every single clipboard change.

And rather than failing immediately when blocked, let /clipboard and $cb wait for up to 300 miliseconds for a green light from Windows to read/write to the clipboard. This would help conventional uses of /clipboard, like solitary instances of "/clipboard test" or "$cb(0)" which coincide with another application's clipboard access. The delay would even help in cases of "while (whatever) { <build &binvar> } /clipboard &binvar", assuming something repeatedly and rapidly executed the alias housing that code, causing multiple rapid /clipboard and $cb calls after all.

Since most applications which sense and read clipboard changes would, by definition, only be triggered following the use of /clipboard, $cb()'s delay would rarely if ever cause any script slowdowns. For potential speed issues caused by giving /clipboard a delay, on the other hand, mIRC's help could simply point out "/clipboard &multiLineBinvar" as preferable to rapid and repeated /clipboard execution.


Link Copied to Clipboard