I think you may have better results if you give more of a max wait in ClipWait calls. In most cases I use 2 seconds. If the data is ready earlier it returns. It rarely sits for 2 seconds but in those cases when there may be stuff happening on the system allowing up to 2 seconds seems to be enough at least on my Laptop.
Try using 2 or even 3 seconds and see if it is more reliable.
Another thing is it is a good idea to check results after calls. Many scripts on boards or example code skip the error checking to keep it small and easily understood. For instance you can check if you got nothing from the clipboard by
If (! ClipContents)
{
;do something here if I draw a blank
}
else
{
;process the stuff
}
Also I think it is generally preferable to use expression mode when possible. Stuff like
"clipsaved =" is ubiquitous and an easy way to clear memory. But on the whole the more you can keep to expression mode the more stuff acts as you would expect. Plus you can take some shortcuts similar to how it is done in C since an assignment is itself an expression you can init a bunch of variables in one line of code such as "x := y := w := h := -1" before using those in a call to WinGetPos and the like.