"Can't open clipboard for writing"

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Micha
Posts: 50
Joined: 15 Oct 2015, 04:54

"Can't open clipboard for writing"

24 Apr 2018, 03:15

I use an Autohotkey script that inserts a short phrase into the clipboard (to prevent long phrases previously in the clipboard from being there) and then inserts an entry from CTRL C if any. The program then opens a dictionary and uses this info.

The relevant code at the beginning is:

Code: Select all

Clipboard=qx
ClipWait
Sleep, 300
SendInput, ^c
ClipWait
Sleep, 300
Clipboard = %Clipboard% ; remove any leading or trailing spaces
ClipWait
The program has worked fine on my desktop and a previous laptop with Windows 10 64-bit.

I now have a new laptop, and the exact same program frequently produces an error "can't open clipboard for writing", pointing to this clipboard area of the Autohotkey program, and then terminates Autohotkey.

I typed this into Google and see that there were some problems with this years ago, but they were never solved on these forums.

Is a previous program not releasing the clipboard? Is something else going on? Thanks in advance for any insight.
RickC
Posts: 299
Joined: 27 Oct 2013, 08:32

Re: "Can't open clipboard for writing"

24 Apr 2018, 10:39

If you want to clear the clipboard just use clipboard =.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: "Can't open clipboard for writing"

24 Apr 2018, 12:41

- Try this to get info about the process that last used the clipboard.

Code: Select all

q:: ;get info about the process that last used/is using the clipboard
DetectHiddenWindows, On
vOutput := ""

Loop, 2
{
	if (A_Index = 1)
		hWnd := DllCall("GetClipboardOwner", Ptr)
	else
		hWnd := DllCall("GetOpenClipboardWindow", Ptr)
	WinGet, vPName, ProcessName, % "ahk_id " hWnd
	WinGetClass, vWinClass, % "ahk_id " hWnd
	WinGetTitle, vWinTitle, % "ahk_id " hWnd
	vOutput .= vPName "`r`n" vWinClass "`r`n" vWinTitle "`r`n`r`n"
}

vOutput := SubStr(vOutput, 1, -2)
Clipboard := vOutput
MsgBox, % vOutput
return
- Perhaps two AutoHotkey scripts are trying to access the clipboard at the same time.
- Also, I once had an issue with the Gdip library.
- Btw are you the same Micha that wrote this script? Cheers.
Get Info from Context Menu (x64/x32 compatible) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=31971
Last edited by jeeswg on 24 Apr 2018, 13:47, edited 2 times in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Micha
Posts: 50
Joined: 15 Oct 2015, 04:54

Re: "Can't open clipboard for writing"

24 Apr 2018, 13:18

RickC & jeeswg: Thanks!

jeeswg: No, I'm not that Micha. Unfortunately, because he seems to know quite a bit about Autohotkey.

I haven't gotten your script to really work yet; I just get a blank message box w/ no info. I'm going to keep at it.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: "Can't open clipboard for writing"

24 Apr 2018, 13:46

I've added the line DetectHiddenWindows, On to the script above, just in case that helps to reveal something.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
BunInOven

Re: "Can't open clipboard for writing"

24 Apr 2018, 14:34

jeeswg wrote:I've added the line DetectHiddenWindows, On to the script above, just in case that helps to reveal something.
if the last copy was done in chrome i think thats why he gets blank box
Guest

Re: "Can't open clipboard for writing"

25 Apr 2018, 05:47

1. Why not get rid of ClipWait, the Sleeps should be enough.

2. Are you sure you're not running any sort of Clipboard tool that monitors the clipboard?

3. Does it happen if you close the dictionary program (it must not be running). If it works then the dictionary program might be "blocking" it - Excel for example sometimes causes issues for me when manipulating data in the Clipboard.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 307 guests