Error Can't open clipboard for writing

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ozzii
Posts: 481
Joined: 30 Oct 2013, 06:04

Error Can't open clipboard for writing

20 Jul 2015, 01:01

Hi,
From time to time I have this error:

Code: Select all

Error:  Can't open clipboard for writing.

	Line#
	244: {
	245: Boucle += 1
	246: }
	247: Loop,parse,PROFILS,,
	248: {
	249: Progress,B2 zh0 fs11 CW000080 CTFFFFFF WS900 W150 H25,Profils %A_Index%/%Boucle%
	250: Sleep,10
--->	251: Clipboard := A_LoopField
	252: ClipWait
	253: SendInput,^v
	254: Sleep,200
	255: SendInput,{enter}
	256: Sleep,500
	257: SendInput,!tt{enter 3}
	258: Sleep,700

The current thread will exit.
What Can I do to don't have it anymore?
This is not what the ClipWait is supposed to do?

Thanks in advance.
anonymouscoward

Re: Error Can't open clipboard for writing

20 Jul 2015, 15:33

Perhaps another process (program) is accessing the clipboard, perhaps a try-catch will work, if there is a an error, it will wait an additional second and try again, assuming that the other program will be finished with the clipboard. Depending on which program and controls you are pasting into you might circumvent the clipboard by using http://ahkscript.org/docs/commands/ControlSetText.htm - anyway give this a try...

Code: Select all

; ...
Sleep 100
Clipboard:="" ; this might help
Try
	{
	 Clipboard:=A_LoopField ; if there is an error wait for one second and try again
	 ClipWait
	}
Catch
	{
	 Sleep 1000
	 Clipboard:=A_LoopField	
	 ClipWait
	}
SendInput,^v
; ...
Docs: http://ahkscript.org/docs/commands/Try.htm
ozzii
Posts: 481
Joined: 30 Oct 2013, 06:04

Re: Error Can't open clipboard for writing

20 Jul 2015, 23:33

Thanks, I will try to use that.
just me
Posts: 9458
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Error Can't open clipboard for writing

21 Jul 2015, 01:20

ozzii wrote:This is not what the ClipWait is supposed to do?
No, but #ClipboardTimeout might be useful in this case.
ozzii
Posts: 481
Joined: 30 Oct 2013, 06:04

Re: Error Can't open clipboard for writing

21 Jul 2015, 04:07

So no need to do the try/catch with this, right?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: ht55cd3 and 254 guests