AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Excel 2003 and ClipboardAll

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
Tekl



Joined: 24 Sep 2004
Posts: 813
Location: Germany

PostPosted: Tue Jun 19, 2007 10:29 am    Post subject: Excel 2003 and ClipboardAll Reply with quote

Hi,

I've selected some simple cells in Excel 2003 SP2 (XP). When I copy them with the following script running, Excel lags and shows me two messages that there is no printer configured!

Code:
#persistent
OnClipBoardChange:
Selection := ClipboardAll
Return


What's happening here? It only happens when using ClipboardAll.
_________________
Tekl
Back to top
View user's profile Send private message Visit poster's website
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10464

PostPosted: Tue Jun 19, 2007 1:53 pm    Post subject: Reply with quote

I can reproduce this. To avoid delaying the 1.0.47 release, I'll look into it afterward.
Back to top
View user's profile Send private message Send e-mail
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10464

PostPosted: Sun Jun 24, 2007 9:19 pm    Post subject: Reply with quote

Although I can reproduce the problem, I don't see a way to fix it. In case it's useful to you or anyone else, here's what I discovered:

When cells are copied onto the clipboard in Excel 2002 (and possibly other versions), the following clipboard formats are placed onto the clipboard:
Code:
C009   DataObject
000E   CF_ENHMETAFILE
0003   CF_METAFILEPICT
0002   CF_BITMAP
C1DF   Biff8
The formats 0xE and 0x3 are the ones that cause the following dialog to appear in Excel:
Quote:
No printers are installed. To install a printer, point to Settings on the Windows Start menu, click Printers, and then double-click Add Printer. Follow the instructions in the wizard.
Unfortunately, those formats cannot be blocked/excluded from ClipboardAll because they're almost certainly not unique/specific to Excel.

I also tried hwnd := DllCall("GetClipboardOwner") to find out the owner of the clipboard, but that owner is of class CLIPBRDWNDCLASS, which seems like a generic class, not one that's likely to be specific to Excel (unverified). In addition, that window has no parent or owner, so there doesn't appear to be any way to use it to detect that Excel is the source of the data currently on the clipboard.

Until a solution is found, I've documented this as a known limitation: "Retrieving ClipboardAll while cells from Microsoft Excel are on the clipboard may cause Excel to display a "no printers" dialog."

The only workaround I can think of is to create a substitute for ClipboardAll in your script that calls GetClipboardData(), etc. to retrieve everything except the two troublesome formats (at least whenever Excel is the active window).

Thanks for reporting the problem because at least now it can be found by anyone else who encounters it.
Back to top
View user's profile Send private message Send e-mail
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Mon Jun 25, 2007 9:42 am    Post subject: Reply with quote

Strange, these formats are metafiles, WMF-like format (vector graphics).
The content of this format is actually a list of GDI calls, it looks like a bug (in Excel or Windows) to require a printer driver to work.
If it happens only if there is no printer driver installed, a possible solution is to install a dummy printer driver, eg. printing to a file.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
engunneer



Joined: 30 Aug 2005
Posts: 6308
Location: Pacific Northwest, US

PostPosted: Mon Jun 25, 2007 5:44 pm    Post subject: Reply with quote

a useful dummy pronter is PrimoPDF - it prints your document to a PDF file, and is slightly easier to install than the open source PDF printers, since you don't need to install GhostScript.
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
Tekl



Joined: 24 Sep 2004
Posts: 813
Location: Germany

PostPosted: Mon Jul 02, 2007 3:03 pm    Post subject: Reply with quote

Hi,

Retrieving everything expect the EMF-Part is no solution as I use ClipboardAll to restore the clipboard at the end of the script.

Installing a dummy printer helps a lot (I used Generic / Text Only form the Standard group). Well, I just had some printers installed, but the default printer was not accesible anymore. So just having a printer driver does not help, it must be accesible.

Very strange.
_________________
Tekl
Back to top
View user's profile Send private message Visit poster's website
Tekl



Joined: 24 Sep 2004
Posts: 813
Location: Germany

PostPosted: Mon Jul 02, 2007 4:03 pm    Post subject: Reply with quote

Before I start making a workaround. Is it possible with GetClipboardData() to catch all data types expect CF_METAFILEPICT so that I can write it to a file and load it back with FileRead into the clipboard?

Can I just do this?
NewVar := DataObject . CF_ENHMETAFILE . CF_BITMAP . Biff8
_________________
Tekl
Back to top
View user's profile Send private message Visit poster's website
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10464

PostPosted: Thu Jul 05, 2007 2:00 am    Post subject: Reply with quote

I don't think so because most AutoHotkey features cannot manipulate binary data (i.e. data containing binary zeros). Therefore, you'd have to use DllCall to manipulate the data in memory and read/write it to files.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group