News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

What is the best way to monitor clipboard events?

Started by Xacker, October 21, 2008, 02:11:07 PM

Previous topic - Next topic

Xacker

Hi,

old thread: http://www.masm32.com/board/index.php?topic=10155.msg74362#msg74362 (not that old)

this is not a double post, this is a separation between the two different concepts so moderators don't miss understand it with some illegal activities because I can tell the old thread got totally ignored.

Q:
What is the best way to monitor clipboard activities especially the copy event?

I've done my googling, I read articles, I'm not looking for a full source of code, just pointers from professional people who must have done it before and figured several ways for doing it.

thank you in advance.
Xacker.

qWord

Do you want to write a "Clipboard-Extension" ? - if so, there is an simple method without monitoring. Just Register your own Hotkey e.g. : CONTROL+"y". While processing WM_HOTKEY you can use keybd_event to simulate CONTROL+c. After waiting some milliseconds you can open the clipboard to obtain data.
FPU in a trice: SmplMath
It's that simple!

Xacker

Quote from: qWord on October 21, 2008, 03:04:36 PM
Do you want to write a "Clipboard-Extension" ?

sort of, but not exactly, from my old topic

Quote
it's a small utility to allow me copy several phrases/words several times from any window and put them in a list, then by user request and right click of the mouse a pop-up menu shows up to select what phrases/words to paste so the user doesn't have to copy > paste immediately but only when he feels to.

I was trying to avoid the sleep API thing (the concept of waiting for xyz milliseconds not the API itself), add to that it has to work on CTRL+C event, not all users read the manual.

Any other suggestions?
thank you for your time.

Jimg

add a window to the clipboard chain
(google "clipboard chain")

Xacker

Quote from: Jimg on October 21, 2008, 03:23:36 PM
add a window to the clipboard chain
(google "clipboard chain")

We meet again JimG :)

I thought of that, what if my program doesn't have a dialog (in other words, no window > no window handle)?

BogdanOntanu

Quote
I thought of that, what if my program doesn't have a dialog (in other words, no window > no window handle)?

Make a window for it ... or we and your users are going to think that you intend to hide something :D
Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

donkey

Register as a clipboard viewer window, that way you get a notification every time the clipboard changes


http://msdn.microsoft.com/en-us/library/ms649052(VS.85).aspx
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

hutch--

I have a clipboard viewer in the current version of QE and they are very easy to write, just set up a timer at whatever is a convenient interval and read the text from the clipboard into the viewer. It would be easy enough to just append each change to the clipboard to the end of an edit control so you have a clipboard log to check.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

donkey

Quote from: Xacker on October 21, 2008, 06:48:15 PM
Quote from: Jimg on October 21, 2008, 03:23:36 PM
add a window to the clipboard chain
(google "clipboard chain")

We meet again JimG :)

I thought of that, what if my program doesn't have a dialog (in other words, no window > no window handle)?

Use a message only window...

QuoteMessage-Only Windows

A message-only window enables you to send and receive messages. It is not visible, has no z-order, cannot be enumerated, and does not receive broadcast messages. The window simply dispatches messages.

To create a message-only window, specify the HWND_MESSAGE constant or a handle to an existing message-only window in the hWndParent parameter of the CreateWindowEx function. You can also change an existing window to a message-only window by specifying HWND_MESSAGE in the hWndNewParent parameter of the SetParent function.

To find message-only windows, specify HWND_MESSAGE in the hwndParent parameter of the FindWindowEx function. In addition, FindWindowEx searches message-only windows as well as top-level windows if both the hwndParent and hwndChildAfter parameters are NULL.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

hutch--

i had a quick look around and here is a reference that may be useful, the examples are in Delphi but the API reference should do the job.

http://www.delphidabbler.com/articles?article=9
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Xacker

Quote from: donkey on October 21, 2008, 11:39:07 PM
Use a message only window...

Which is exactly what I want  :U thank you it works.

Quote
i had a quick look around and here is a reference that may be useful, the examples are in Delphi but the API reference should do the job.

http://www.delphidabbler.com/articles?article=9

Thanks alot hutch :)

appreciated.

kero

Following MSDN's info contains some serious inaccuracies:

Quote
Message-Only Windows

A message-only window enables you to send and receive messages. It is not visible, has no z-order, cannot be enumerated, and does not receive broadcast messages. The window simply dispatches messages.

To create a message-only window, specify the HWND_MESSAGE constant or a handle to an existing message-only window in the hWndParent parameter of the CreateWindowEx function. You can also change an existing window to a message-only window by specifying HWND_MESSAGE in the hWndNewParent parameter of the SetParent function.

To find message-only windows, specify HWND_MESSAGE in the hwndParent parameter of the FindWindowEx function. In addition, FindWindowEx searches message-only windows as well as top-level windows if both the hwndParent and hwndChildAfter parameters are NULL.

1)   > "cannot be enumerated"

FALSE!

As EnumChildWindows(GetDesktopWindow) enumerates all usual windows -

EnumChildWindows(GetMessageWindow) enumerates all message-only windows,

where GetMessageWindow = GetAncestor(FindWindowEx(HWND_MESSAGE,0,0,0),GA_PARENT),  GetClassName (GetMessageWindow) = "Message".

Btw symmetry: GetDesktopWindow = GetAncestor(FindWindowEx(HWND_DESKTOP,0,0,0),GA_PARENT).

2)  > "To create a message-only window, specify the HWND_MESSAGE constant or a handle to an existing message-only window in the hWndParent parameter of the CreateWindowEx function".

But it's right only for top message-only window (class "Message")!
Any other message-only owner in the hWndParent parameter of the CreateWindowEx preordains usual, non message-only window.

3)  > "You can also change an existing window to a message-only window by specifying HWND_MESSAGE in the hWndNewParent parameter of the SetParent function."

But here we can use any message-only window, not only HWND_MESSAGE constant or top "Message" window.

So MSDN's explanations about hWndParent and hWndNewParent must be exchange :)


See enumeration of all message-only (and all usual) windows in sources of WinTreeSnap and FrameRector:


[attachment deleted by admin]