WinClip - AHKv2 Compatibility

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: WinClip - AHKv2 Compatibility

03 Nov 2019, 22:36

@dereklim78: These allow you to inspect the clipboard contents, that might give you some clues.

Free Clipboard Viewer for Windows
http://www.freeclipboardviewer.com/
InsideClipboard - View the content of all formats stored in the Clipboard
https://www.nirsoft.net/utils/inside_clipboard.html
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: WinClip - AHKv2 Compatibility

04 Nov 2019, 12:53

dereklim78 wrote:
03 Nov 2019, 22:12
All this worked in Win7, but there in Win10 there seems to be a glitch now - it does copy into the clipboard, but when I Ctrl-V into the client program (an electronic medical record), it doesn't paste anything, whereas Ctrl-V in Ms-Word works fine.
strange, sounds like its working if it works in MSWORD, but maybe some win10 change is blocking your medical app

did you try the setRTF modification to the script mentioned above:
https://www.autohotkey.com/boards/viewtopic.php?p=281949#p281949
?

freespacing
Posts: 150
Joined: 28 Sep 2016, 11:14
Contact:

Re: WinClip - AHKv2 Compatibility

05 Jan 2020, 13:28

As mentioned on this thread, WinClip does not paste the html clipboard properly when it has special characters (e.g., a Spanish word such as añadió)

The change below fixed it, but wondering if there's a reason for how it is at the moment?

Original WinClip.ahk:

Code: Select all

GetHtml()
  {
    if !( clipSize := this._fromclipboard( clipData ) )
      return ""
    if !( out_size := this._getFormatData( out_data, clipData, clipSize, "HTML Format" ) )
      return ""
    return strget( &out_data, out_size, "CP0" )
  }

Tweaked function:

Code: Select all

GetHtml(enc:="UTF-8")
  {
    if !( clipSize := this._fromclipboard( clipData ) )
      return ""
    if !( out_size := this._getFormatData( out_data, clipData, clipSize, "HTML Format" ) )
      return ""
    return strget( &out_data, out_size, enc )
  }
Adventurer
Posts: 23
Joined: 18 Apr 2019, 06:24

Re: WinClip - AHKv2 Compatibility

30 Jan 2020, 09:37

GetHtml() and iGetHtml() seem to mangle non-ASCII characters. Changing the output from CP0 to UTF-8 seems to fix it.
User avatar
JoeSchmoe
Posts: 129
Joined: 08 Dec 2014, 08:58

Re: WinClip - AHKv2 Compatibility

28 Oct 2020, 21:34

Has anyone been able to update this to a more recent version of v2? I'm dying to use it, but moving it forward is a bit beyond me.

I started attempting to upgrade the code, but I got stumped by how to upgrade things like ObjSetCapacity, ObjGetAdress, and VarSetCapacity for V2, particularly when they are applied to properties of objects...

Code: Select all

    _setClipData( ByRef data, size )
    {
        if !size
            return 0
        if !ObjSetCapacity( this, "allData", size )
            return 0
        if !( pData := ObjGetAddress( this, "allData" ) )
            return 0
        WinClipAPI.memcopy( pData, &data, size )
        return size
    }
    
    _getClipData( ByRef data )
    {
        if !( clipSize := ObjGetCapacity( this, "allData" ) )
            return 0
        if !( pData := ObjGetAddress( this, "allData" ) )
            return 0
        VarSetCapacity( data, clipSize, 0 )
        WinClipAPI.memcopy( &data, pData, clipSize )
        return clipSize
    }
I'm now working on moving my own code back to v1 so I can use this library. Which is a shame because I love v2.
User avatar
tdalon
Posts: 44
Joined: 21 Apr 2017, 07:19
Location: Germany
Contact:

Re: WinClip - AHKv2 Compatibility

12 Apr 2021, 15:27

I've always had a problem with the WinClip library that is that WinClip.iSetHTML does not work (as I would expect). Anyone using it successfully or having the same issue?
m3user
Posts: 235
Joined: 17 Jan 2014, 18:11

Re: WinClip - AHKv2 Compatibility

25 Apr 2021, 12:22

I'm learning this great class, however I experienced an error with the code below - Continuable Exception Access Violation.

- Copy some random text to the Clipboard - it must be a formatted text, for example copy it from Word,
- Run Ctrl+X to paste the example text using the old ahk method and the image using WinClip.

It seems WinClip doesn't work if the content of the clipboard is formatted text from ClipboardAll.
Can anyone confirm this? What am I doing wrong please? Thanks!

Code: Select all

#include, WinClipAPIMod.ahk
#include, WinClipMod.ahk

^x::
clipbak:=ClipboardAll
clipboard:=""
clipboard:="Test Clipboard Content"
clipwait, 2, 1
sleep 250
Send, ^{vk56}   ;~ send ^v
sleep, 100
clipboard:=""
clipboard:=clipbak
clipwait, 2, 1

WinClip.Snap( data )
clipboard :=""
WinClip.Clear()
WinClip.SetBitmap("D:\Test\Image.png") ;change to your image
sleep, 20
WinClip.Paste()
WinClip.Restore( data )

return
User avatar
JoeSchmoe
Posts: 129
Joined: 08 Dec 2014, 08:58

Re: WinClip - AHKv2 Compatibility

16 May 2021, 18:59

What version of AHK are you using?
MrDoge
Posts: 160
Joined: 27 Apr 2020, 21:29

Re: WinClip - AHKv2 Compatibility

19 May 2021, 08:19

EDIT: I'm done converting it automatically (it's different)
WinClipAPI.ah2
WinClip.ah2

@JoeSchmoe
same, I wanted to use v2

so I converted to AHK_H v2: https://github.com/FuPeiJiang/WinClipv2
only tested on WinClip.SetHTML() & WinClip.GetHtml() (because I only needed these)
if it doesn't work, submit a github issue (or PR if you can see how I converted it?)

but I really want to convert automatically (so I'm working on a v1 parser)
m3user
Posts: 235
Joined: 17 Jan 2014, 18:11

Re: WinClip - AHKv2 Compatibility

24 May 2021, 12:42

JoeSchmoe wrote:
16 May 2021, 18:59
What version of AHK are you using?
Sorry for a late reply, I'm using 1.1.30.03. Can you confirm the issue? Any workaround?
MrDoge
Posts: 160
Joined: 27 Apr 2020, 21:29

Re: WinClip - AHKv2 Compatibility

24 May 2021, 15:13

@m3user
I've downloaded AutoHotkey_1.1.30.03 from https://autohotkey.com/download/1.1/
and ran "Downloads\AutoHotkey_1.1.30.03\AutoHotkeyU64.exe" "test35.ahk"
I've tested and also done ExitApp and haven't gotten "Continuable Exception Access Violation"

1) you should download latest version: https://autohotkey.com/download/
does "Continuable Exception Access Violation" still happen ?
this happens for me when using AHK_H v2
whenever a class is extended for ex: class WinClip extends WinClip_base
and when I ExitApp, this error will be thrown

2) what is inside ?:
#include, WinClipAPIMod.ahk
#include, WinClipMod.ahk

(test paste and image paste are working correctly)
so I isolated the issue (idk if it's with WinClip or with ahk.exe itself(clipboard) ):
READ THE COMMENTS

Code: Select all

; clipboard:=ClipboardAll ;this doesn't cause the error ;I guess this is coded(in ahk.exe) to do nothing at all
clipBak:=ClipboardAll ;saving ClipboardAll to a variable then .Snap transforms it into weird characters
clipboard:=clipBak
WinClip.Snap( data )
WinClip.Restore( data )
send, ^v 
User avatar
JoeSchmoe
Posts: 129
Joined: 08 Dec 2014, 08:58

Re: WinClip - AHKv2 Compatibility

24 May 2021, 16:27

MrDoge wrote:
19 May 2021, 08:19
EDIT: I'm done converting it automatically (it's different)
WinClipAPI.ah2
WinClip.ah2
Very impressive!

I'm afraid that your technical skills are way above mine. Will this work with AHK2 (not AHK_H)? If so, do you recommend a version of AHK2? I use v2.0-a122.

I am very glad you are working on this. We need an updated v2 version of WinClip.
Last edited by JoeSchmoe on 24 May 2021, 22:15, edited 1 time in total.
m3user
Posts: 235
Joined: 17 Jan 2014, 18:11

Re: WinClip - AHKv2 Compatibility

24 May 2021, 16:46

I’m actually using AHK_H (not 2). Never thought this would be the reason, should report it on a H forum.
User avatar
JnLlnd
Posts: 487
Joined: 29 Sep 2013, 21:29
Location: Montreal, Quebec, Canada
Contact:

Re: WinClip - AHKv2 Compatibility

24 Feb 2024, 18:00

I asked a question here but moved it to the "Ask for help" section.
:thumbup: Author of freeware Quick Access Popup, the powerful Windows folders, apps and documents launcher!
:P Now working on Quick Clipboard Editor
:ugeek: The Automator's Courses on AutoHotkey
User avatar
tdalon
Posts: 44
Joined: 21 Apr 2017, 07:19
Location: Germany
Contact:

Re: WinClip - AHKv2 Compatibility

11 Apr 2024, 00:31

Trying to move to v2 and I also have the issue to get WinClip library compatible to v2. Currently it won't even run with WinClip.
I had to replace Exception with Error, replace ByRef with &.
My last problem is the line:

Code: Select all

class WinClipAPI_base extends WinClip_base
{
    __Get( name ) {
        if !this.HasOwnProp(initialized)
            this.Init()
        else
            throw Error( "Unknown field '" name "' requested from object '" this.__Class "'", -1 )
    }
}
The variable 'intialized' appears to never be assigned a value
User avatar
tdalon
Posts: 44
Joined: 21 Apr 2017, 07:19
Location: Germany
Contact:

Re: WinClip - AHKv2 Compatibility

11 Apr 2024, 00:35

Update: this post shall be moved maybe or renamed.
See viewtopic.php?f=83&t=91054&p=402344&hilit=winclip#p402344

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: gwarble and 148 guests