ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE. Software > Post New Requests Here

Alt-LMBclick puts filename in GUI Edit element. Without using clipboard

<< < (2/2)

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

--- Code: Autohotkey ---ClipContents := ClipboardIf (! 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.

Thank you MilesAhead,

Sorry for the late reply, I was distracted by other projects. It's good to know the clipwait returns earlier if the data is ready. Also, thank you for the tips for better code.

My code now works fine for it's original purpose, using GUIControl. However for MsgBox, i really need a clipwait of 2 seconds. It seems like MsgBox is much slower then GUIControl.

Thanks again!


[0] Message Index

[*] Previous page

Go to full version