Results 1 to 6 of 6

Thread: How do I know when my Ctrl + C command has been processed?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2017
    Posts
    761

    Question How do I know when my Ctrl + C command has been processed?

    I need to copy the currently selected text from the currently active window in the currently active app. If the app support guiInfo.hwndCaret, then I use this. However, in some cases, the app does not support guiInfo.hwnd_Caret, and I have to fall back to plain copying to clipboard to get the currently selected text.

    I am checking the WM_CLIPBOARDUPDATE message to see when the content of the clipboard has changed.

    However, when nothing is selected in the current active window, this message is not called because the clipboard has not changed.

    How would I know that the Ctrl + C has been processed anyways?

    Thank you!

  2. #2
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,667

    Re: How do I know when my Ctrl + C command has been processed?

    You don't know when other apps read the clipboard.

    I think you need a better way to communicate programs. Using the clipboard is a bad idea anyway.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2017
    Posts
    761

    Re: How do I know when my Ctrl + C command has been processed?

    I have not found any other way to copy the selected text from chrome.exe.

  4. #4
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,667

    Re: How do I know when my Ctrl + C command has been processed?

    Quote Originally Posted by tmighty2 View Post
    I have not found any other way to copy the selected text from chrome.exe.
    Better describe exactly what you are trying to achieve, maybe we can have an idea (or not).

  5. #5
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    7,653

    Re: How do I know when my Ctrl + C command has been processed?

    Did you read my comment in the other thread about this?

    You don't need a pause, doevents, or loop.

    Pseudocode:

    Code:
    bExpectingCopy As Boolean
    Dim lSent As Long, lReceived As Long
    
    Sub that sends CtrlC:
    
    GetTickCount lSent
    bExpectingCopy = True
    SendCtrlC
    
    SubclassProc:
    
    Case WM_CLIPBOARDUPDATE
      If bExpectingCopy Then
       GetTickCount lReceived
        If lReceived - lSent < 100 Then
            You're only here if text was copied.
    Last edited by fafalone; Apr 22nd, 2022 at 06:34 PM.

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2017
    Posts
    761

    Re: How do I know when my Ctrl + C command has been processed?

    Yes, I did read it, thank you.
    I have isolated my problem now, and the real issue is that there is no event if Ctrl + C was processed, but the clipboard was not changed because the selection was empty.

    There is no solution to this problem, so I use a timer (similar to what you proposed with GetTickCount), and after a certain elapsed amount of time without this window message, I assume that the selection was indeed empty.

Tags for this Thread

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