Jump to content

Clipboard, Ctrl C and ClipGet()


middae
 Share

Recommended Posts

I have noticed this in both VBA(Excel 2000) and AutoIt. Many times, the only way to get information from a window is to highlight and Ctrl+C to send it to the clipboard. Then I use ClipGet() or equiv. vba code to retrieve the contents and parse the resulting string.

What I've noticed is that clipboard content retrieval will occasionally lag behind, resulting in either prior data, or not all data being retrieved.

For Example.

Clipboard contains "AB1"

ClipGet() - results in "AB1"

do stuff, highlight, send CTRL-C on "CD2"

ClipGet() - results in "" or "AB1"

This only happens every once in awhile. If I have notepad open, and notice the ClipGet() is resulting the wrong info, I can Ctrl_V into Notepad, and it shows the new stuff that was supposed to be retrieved. I guess it's missing a tick or the clipboard data on another process or something.

I used to ClipPut() a "CLEAR", and compare ClipGet() to it to see if it got the new info or not, but ClipGet() still may result in erroneous information.

Thoughts on always getting the proper info?

Link to comment
Share on other sites

Just make sure you know the clipboard is clear for a fact, then setup a copy:

HotKeySet("^c", "Clip")

Func Clip()

Do
Clipput()
Sleep(10)
Until Clipget() = ""

HotKeySet("^c", "")
    Send('^c')
HotKeySet("^c", "Clip")
    $e = 0
    Do
        $e += 1
        If $e > 25 Then
            For $i = 0 To 5
                HotKeySet("^c", "")
    Send('^c')
HotKeySet("^c", "Clip")
            Next
;~              ExitLoop
        EndIf
    Until ClipGet() <> ""

EndFunc

I'm sure someones going to come behind me and clean this code up. But thats roughly what you do.

Edited by TouchOdeath
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...