Results 1 to 2 of 2

Thread: [RESOLVED] "Can't open Clipboard" message, what to do ?

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2006
    Posts
    6

    [RESOLVED] "Can't open Clipboard" message, what to do ?

    I need grab the data from the scrolling window in another application. The data have a table structure, so I can get them manually using Ctrl-C,Ctrl-V method and stepping down row-by-row.
    I am trying to create a simple program in VB6 which could do it automatically. I imitated all keyboard keys and it works. However, I must introduce some time delays at each step like "Sleep 400" or I get "Can't open Clipboard" message". However, if the number of rows 200 or so it is slow. I read somewhere to try the following to avoid "Sleep" command:

    Get ProcID of the process and insert WaitForInputIdle ProcID.

    I did that at each step of the cycle for the process where the window belongs to and for the clipboard process like

    hwnd1 = GetClipboardOwner()
    GetWindowThreadProcessId hwnd, procid
    GetWindowThreadProcessId hwnd1, procid1
    WaitForInputIdle procid, INFINITE
    WaitForInputIdle procid1, INFINITE

    Here hwnd is the handle to the scrolling window. It is not working. I am getting occasionally that message "Can't open Clipboard". I tried to introduce Error handling trying to repeat Ctrl-C,Ctrl-V sequence few times, but the program locks in such loop of error corrections.

    Could anyone advise me how to handle this "Can't open Clipboard" problem ?
    Last edited by butsefal; Dec 14th, 2006 at 06:59 AM.

  2. #2

    Thread Starter
    New Member
    Join Date
    Dec 2006
    Posts
    6

    Re: "Can't open Clipboard" message, what to do ?

    After few days I found a solution of this problem in one forum ...

    I removed all WaitForInputIdle, they don't work. A partial solution is to put
    DoEvents before accessing Clipboard. Then you get Error 521 "Can't open Clipboard" very rarely. When I added it twice like

    On Error Resume Next
    ...
    DoEvents
    Clip$=Clipboard.GetText
    Sleep 10
    DoEvents
    Clip$=Clipboard.GetText
    ...
    it completely resolved the problem.
    Hope that it will be useful for someone.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width