Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[Class] WinClip - direct clipboard manipulations


  • Please log in to reply
94 replies to this topic
CodeKiller
  • Members
  • 2067 posts
  • Last active: Feb 26 2016 09:30 AM
  • Joined: 10 Jul 2008
:?:

!!! Make attention, that data from clipboardall, and WinClip.Snap() is not compatible


Just above :
clipData := clipboardall 
clipSize := WinClip.Snap( clipData )

So... what ?

Deo
  • Members
  • 199 posts
  • Last active: Jan 31 2014 03:19 PM
  • Joined: 16 May 2010
sorry, man, didn't understand your question

jarris
  • Members
  • 8 posts
  • Last active: Apr 05 2012 12:21 AM
  • Joined: 03 Apr 2012

Thanks Deo, That worked beautifully. Now I don't have to depend on outlook signatures and outlook quick parts

Working Code

::utsig:: ; usual signature
WinClip.Clear()
rtf := FileOpen("c:\bin\autohotkey\rtf\utsignature.rtf", "r").read()
WinClip.SetRTF(rtf)
WinClip.Paste()
Return



Hi all. I've been trying to get Autohotkey to copy some formatted text in an rtf file and paste it to Word and Thunderbird (as formatted text) and was directed to this thread.

I've tried the above code (changing the file path to an existing rtf file), but get the following error code:

Error: Call to nonexistent function.

Specifically: WinClip.Clear()

	Line#
--->	281: WinClip.Clear()
	282: rtf := FileOpen("c:\autohotkey\test1.rtf", "r").read()
	283: WinClip.SetRTF(rtf)
	284: WinClip.Paste()
	285: Return
	295: Exit

The error code also refers to the preceding script, which I use to paste unformatted text:

;	Paste unformatted - CNTL + SHIFT +V

$^+v::
  ClipSaved := ClipboardAll  ;save original clipboard contents
  clipboard = %clipboard%  ;remove formatting
  Send   ^v  ;send the Ctrl+V command
  Clipboard := ClipSaved  ;restore the original clipboard contents
  ClipSaved =  ;clear the variable
Return

Any help on how to fix this would be appreciated.

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
jarris, I believe you are using AutoHotkey Basic and the script requires AutoHotkey_L.

jarris
  • Members
  • 8 posts
  • Last active: Apr 05 2012 12:21 AM
  • Joined: 03 Apr 2012
Thanks Lexicos.

I downloaded and installed AutoHotkey_L (the Unicode 64bit version - I use Win7 64bit), but it still doesn't work. On activating the script by typing "utsig" the text just disappears - I had to stop AHK to be able to type "utsig" here :-)

As much as I appreciate everyone's help, I might have to put it in the "nice to have, but will have to live without it" basket.

Thanks again. Appreciated.

Deo
  • Members
  • 199 posts
  • Last active: Jan 31 2014 03:19 PM
  • Joined: 16 May 2010
jarris
Did you included WinClip as described in first post?

jarris
  • Members
  • 8 posts
  • Last active: Apr 05 2012 12:21 AM
  • Joined: 03 Apr 2012
Thanks Deo, but I am TOTALLY out of my depth here. I've no idea what to do with WinClip.

I did download the WinClip.zip file and extracted the three files.

Double clicking "WinClip.ahk" brings up an error code for line 1 which says,

Line lext: WinClip_base
Unknown Class
The program will exit

Copying all the code from WinClip.ahk to my usual *.ahk file doesn't work either and I get the same error code as above.

I'm sure you are either having a good laugh, or shaking your head and uttering a few expletives. Thanks again, but I'm sure you have better things to do. I'll just stick with the basic Hotstrings I use now - which are a great time-saver and for which I'm very thankful.

  • Guests
  • Last active:
  • Joined: --

Thanks Deo, but I am TOTALLY out of my depth here. I've no idea what to do with WinClip.


Follow these steps:
1) go here <!-- m -->http://www.autohotkey.com/download/<!-- m --> grab the latest AutoHotkey_L installer, when you install it make sure you choose UNICODE (already default version)
2) download the winclip files from the first post, unpack all into a directory
3) in that same directory create a new script with this code:
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

[color=red]#Include WinClipAPI.ahk
#Include WinClip.ahk
wc := new WinClip[/color]

::utsig:: ; usual signature
WinClip.Clear()
rtf := FileOpen("c:\bin\autohotkey\rtf\utsignature.rtf", "r").read()
WinClip.SetRTF(rtf)
WinClip.Paste()
Return
4) I think you forgot the lines marked in Red above + you may have the incorrect version of AutoHotkey installed hence steps 1-2-3

jarris
  • Members
  • 8 posts
  • Last active: Apr 05 2012 12:21 AM
  • Joined: 03 Apr 2012
EUREKA!!!! I'm one HAPPY camper :D

A HUGE thank you to everyone.

I did have AutoHotkey_L installed (thanks to Lexicos) and had chosen Unicode 64 bit. The problem was obviously steps 2) and 3). Thank you Guest.

This works GREAT in Word and will be an even bigger time saver.

Strangely, it does not work in Thunderbird emails. If I copy and paste the old way from the rtf file to Thunderbird, no problem. But, over 80% of my work where I would need this is in Word, so that's no biggie.

Thanks again everyone. I will pass the kindness forward.

  • Guests
  • Last active:
  • Joined: --
For TB I think you need to look into the HTML functions.

jarris
  • Members
  • 8 posts
  • Last active: Apr 05 2012 12:21 AM
  • Joined: 03 Apr 2012
Thanks Guest, but I think I should count my blessings and let that particular sleeping dog lie. <sigh of relief from everyone>

  • Guests
  • Last active:
  • Joined: --
Same type of script, example
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.

SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.

SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.



#Include WinClipAPI.ahk

#Include WinClip.ahk

wc := new WinClip



FileDelete,test.htm ; just to create a test file

FileAppend,

(

<ul>

<li>AutoHotkey and</li>

<li>WinClip</li>

<li>Rocks</li>

</ul>

),test.htm





::utsig:: ; usual signature

WinClip.Clear()

html := FileOpen("test.htm", "r").read()

WinClip.SetHTML(html)

WinClip.Paste()

Return


jarris
  • Members
  • 8 posts
  • Last active: Apr 05 2012 12:21 AM
  • Joined: 03 Apr 2012
Hi Guest. I got it to work with some variations - I got lucky, but couldn't have done it without you. UR brilliant!

As I already had the following in my *.ahk file I didn't add it again.

#NoEnv  
SendMode Input  
SetWorkingDir %A_ScriptDir%  

#Include WinClipAPI.ahk
#Include WinClip.ahk
wc := new WinClip

My previous rtf file-paste code looked like this:

::~n:: 
WinClip.Clear()
rtf := FileOpen("C:\autohotkey\notes.rtf", "r").read()
WinClip.SetRTF(rtf)
WinClip.Paste()
Return

I re-saved my "notes.rtf" to an htm file format in the same file path location. So, using your code format (variation) for html, the next bit of code for a TB paste was:

::~n2:: 
WinClip.Clear()
html := FileOpen("C:\autohotkey\notes.htm", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
Return

It works brilliantly. Even a table and it's contents copies across perfectly aligned.

Thank you SOOO much and everyone, be sure to have a very happy and safe Easter break - if you're having one.

  • Guests
  • Last active:
  • Joined: --
Don't thank me, it is Deo's brilliant work! Now I wonder if there is an Easter Egg hidden in WinClip ;-)

jarris
  • Members
  • 8 posts
  • Last active: Apr 05 2012 12:21 AM
  • Joined: 03 Apr 2012
Deo, THANK YOU too!. I hope the Easter Bunny brings *everyone* heaps of good things.