AutoHotkey Community

It is currently May 27th, 2012, 11:56 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: October 21st, 2010, 3:23 pm 
[Moderator's note: Moved from Ask for Help to Bug Reports.]

Hi everyone!

I have a problem with this portion of code. AutoHotkey_L often crashes with this part of code!
It saves the clipboard to a file
Code:
!c::
Clipboard := ""
Send, ^c
ClipWait, 5
If !Clipboard
   Return
InputBox, FileName, Save Clipboard:, File name ?,, 250, 140
If (!FileName || ErrorLevel )
   Return
Path := A_ScriptDir "\" FileName ".txt"
FileDelete, %Path%
FileAppend, %ClipboardAll%, %Path%


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2010, 3:41 pm 
Offline

Joined: January 29th, 2009, 9:50 pm
Posts: 483
Location: Belgium
could you do a sleep between filedelete and fileappend?
see if that helps

_________________
Stopwatch emdkplayer
the code i post falls under the: WTFYW-WTFPL license


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2010, 4:40 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
No need for filedelete, see docs: a fileappend, %clipboardall% automatically deletes the file if present.

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2010, 6:09 pm 
Offline

Joined: February 29th, 2008, 8:36 pm
Posts: 901
Location: Vault 7
Where exactly does it crash?

_________________
ImageDebugging,Container,FileContainer,Object Preferences,ShellFileOperation


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2010, 8:43 pm 
Offline

Joined: April 14th, 2009, 10:40 am
Posts: 182
I think it crashes with FileAppend and may be with big contents.
If I save the clipboard with simple plain text, it works fine but if I try to save a selection in Word (text, formula, table), it crashes!

For more details, I use this part of code to store formulas and paste them with Regex hotstrings


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2010, 8:49 pm 
Offline

Joined: February 29th, 2008, 8:36 pm
Posts: 901
Location: Vault 7
I am able to reproduce the problem copying an equation from Word

_________________
ImageDebugging,Container,FileContainer,Object Preferences,ShellFileOperation


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2010, 8:55 pm 
Offline

Joined: February 29th, 2008, 8:36 pm
Posts: 901
Location: Vault 7
It seems that Office programs do not play well with AHK in this regard. I think I found a workaround, though:

Code:
temp := ClipboardAll
FileDelete, %Path%
FileAppend, %temp%, %Path%


Try that instead. Saving the entire clipboard to a variable first seems to work better.

_________________
ImageDebugging,Container,FileContainer,Object Preferences,ShellFileOperation


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2010, 8:57 pm 
Offline

Joined: April 14th, 2009, 10:40 am
Posts: 182
@Rapte_Of_Suzaku: Sorry for my English but you mean you have the same problem?! I'm trying your solution.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2010, 9:02 pm 
Offline

Joined: February 29th, 2008, 8:36 pm
Posts: 901
Location: Vault 7
All I meant was: I successfully got the same problem to happen on my computer. If I can't first get the problem to happen on my computer, it is harder to find the solution.

_________________
ImageDebugging,Container,FileContainer,Object Preferences,ShellFileOperation


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2010, 9:27 pm 
Offline

Joined: April 14th, 2009, 10:40 am
Posts: 182
I tried your solution, it still crashes but less!
I think this is a problem with Word because with Writer (open office) it never crashes!
Even if it works with Writer, I would it to work also with Word!

Edit: With Writer I save a clipboard with formula, table, graphics and pictures and no problems!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2010, 9:34 pm 
Offline

Joined: February 29th, 2008, 8:36 pm
Posts: 901
Location: Vault 7
You might consider posting this in the bug report section now. It may be Word's fault, but it feels like a bug to have AHK crash.

_________________
ImageDebugging,Container,FileContainer,Object Preferences,ShellFileOperation


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2010, 9:49 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Which Office version do you use?

It seems to work fine for me (Office 2003SP3)

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2010, 9:50 pm 
Offline

Joined: February 29th, 2008, 8:36 pm
Posts: 901
Location: Vault 7
I'm using 2010

_________________
ImageDebugging,Container,FileContainer,Object Preferences,ShellFileOperation


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2010, 10:02 pm 
Offline

Joined: April 14th, 2009, 10:40 am
Posts: 182
I'm using Office 2007 and Open Office 3
The solution of Rapte_Of_Suzaku reduce the crash.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 22nd, 2010, 2:00 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
It seems that AutoHotkey (any version) assumes that GetClipboardData(format) will return a handle to a block of memory. This naive approach works for the most part since GlobalSize() fails when it is given an invalid handle, causing unsupported formats to be skipped over. During my testing, the crashes occurred when trying to call GlobalSize() with a handle returned by GetClipboardData(CF_ENHMETAFILE). Sometimes it crashed, sometimes it merely returned error 6 (ERROR_INVALID_HANDLE).

Reading Standard Clipboard Formats, it appears that at least the following formats should not be interpreted as memory handles: CF_BITMAP, CF_ENHMETAFILE and (probably) CF_DSPENHMETAFILE. It might be sufficient to simply skip these formats. I need to review the other uses of ClipboardAll before I attempt a bug-fix.

I've moved the thread to Bug Reports.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 27 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group