| View previous topic :: View next topic |
| Author |
Message |
Jerry
Joined: 24 Jun 2004 Posts: 39
|
Posted: Tue Mar 01, 2005 6:59 pm Post subject: if (..) bug |
|
|
I was attempting to find when the clipboard changes and I used the following code.
| Code: | oldText = %clipboard%
oldHold := ClipBoardAll
StringLen , oldLen , oldHold
loop
{
sleep, 200
clipText = %clipboard%
clipHold := ClipBoardAll
StringLen , clipLen , ClipHold
if (oldHold <> clipHold OR oldLen <> clipLen OR oldText <> clipText)
gosub clipchanged
oldHold := clipHold
oldtext = %cliptext%
oldLen = %clipLen%
}
exit
clipchanged:
msgbox,0,clipboard,clipboard changed
return |
Anyway, the checking of oldHold <> clipHold does not seem to see a difference all the time. If the clipboard contents change, from one bitmap to another (pressing print scrn button on different windows) the change clipchanged routine does not get called. |
|
| Back to top |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 3004 Location: Minnesota
|
Posted: Tue Mar 01, 2005 7:12 pm Post subject: |
|
|
| ClipboardAll is meant to work with binary data and is not compatible with string operations like StringLen. Currently, it only works in specialized situations and was made to solve the problem of destructive clipboard opertaions. See the variables page for more info. |
|
| Back to top |
|
 |
Jerry
Joined: 24 Jun 2004 Posts: 39
|
Posted: Tue Mar 01, 2005 9:50 pm Post subject: |
|
|
Thanks Jonny,
I put in the strlen to help identify the length of the binary value hoping that the if would be satified. (if the bitmap changed in size it did help identify that it changed)
Originally the IF statement was only
if (oldHold <> clipHold)
Maybe I'm wrong here but since both variables are binary I would have expected a difference. |
|
| Back to top |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 3004 Location: Minnesota
|
Posted: Tue Mar 01, 2005 9:57 pm Post subject: |
|
|
| In truth, that's just a guess, but ClipboardAll is extremely young. It doesn't seem to be fully supported yet, either. Plus, it's kind of like adding entirely new functionality to AutoHotkey (storing binary data in variables), so new bugs should be expected. I'm just a pessimist about "Bug Reports" (you'd be surprised how many times its just a bad case of RTFM). |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Tue Mar 01, 2005 11:24 pm Post subject: |
|
|
Although you can't compare two "binary" variables, you can use StringLen on them. However, that's about the only string method that they currently support.
The next update will have the following in it. Thanks for the idea.
| Quote: | Variables to which ClipboardAll has been assigned can be compared to each other (but not directly to ClipboardAll) with the <> and = operators. In the following example, the length of each variable is checked first. If that is not enough to make the determination, the contents are compared to break the tie:
if ClipSaved1 <> %ClipSaved2% ; This must be an old-style IF statement, not an expression.
MsgBox The two saved clipboards are different. |
|
|
| Back to top |
|
 |
|