I'm trying to send CTRL-C to a window:

invoke SendMessage, handle, WM_KEYDOWN, 63h, 24

it does not work....

Any other solution ? I can't use WM_COPY....

Posted on 2003-07-16 16:18:38 by andras
Might try SendInput and send a keyboard input event.
Posted on 2003-07-16 16:31:51 by donkey
i think SendInput is more complicated..

Anyway i've made a mistake ...then i've tried

invoke SendMessage, handle, WM_KEYDOWN, 63h, 1000001h

but it is still not working..

Posted on 2003-07-16 16:56:15 by andras
Maybe if we see more source, the snip where it occurs (man I say this alot )
I assume the handle is valid? Forgive that question, but everything must be asked.

Posted on 2003-07-16 17:03:56 by RobotBob
Erm... the first message would indicate 24 presses of 3 on the numeric pad, and the other would be a non-existent key. :P
Try this:
push ebx
push edi
xor ebx,ebx
mov bl,17 ; VK_CONTROL
xor edx,edx
inc dh ; WM_KEYDOWN
xor edi,edi
inc edi
push edx
push edi
push ebx
push edx
push handle
call SendMessage
xor bl,82 ; C ^ VK_CONTROL
cmp bl,18
pop edx
jb again2
test dl,dl
jnz done
inc edx ; WM_KEYUP
ror edi,1
jnz again
pop edi
pop ebx
Posted on 2003-07-17 01:33:19 by Sephiroth3
no , didn't work...

OK, what i'm trying to do is get some text out of a window control of an open extern application.
This window is not an Edit or RichEdit Control it's not responding of any of this SendMessage :
but you can somehow select text with the mouse and copy it (CTRL+C) or EDIT->COPY of menu, but i don't know
the ID of COPY menuitem....

my code:

xor eax,eax
mov ax, 150
shl eax,16
mov ax, 100
mov coor, eax
invoke FindWindow, 0, addr windownamec3
invoke FindWindowEx, eax, 0,addr classname1,0
mov hand,eax
invoke SendMessage, eax, WM_LBUTTONDOWN, MK_LBUTTON, coor

xor eax,eax
mov ax, 150
shl eax,16
mov ax, 200
mov coor1, eax
invoke SendMessage, hand, WM_MOUSEMOVE, MK_LBUTTON, coor1
invoke SendMessage, hand, WM_LBUTTONUP, 0, coor1
invoke SendMessage, hand, WM_KEYDOWN, 63h, 1000001h

until the last line is fine, you can see the selected text (highlighted)...

63h == "c"
1000001h == 24th bit is 1 to signal that ctrl is down ..

Posted on 2003-07-17 02:09:17 by andras
invoke  SendMessage, handletothewindowtoretrievetheselectedtext, WM_CHAR, 3, 0
just remember that ctrl-c needs a text selected. :grin:

I've only tested this on edit boxes... :grin:
Posted on 2003-07-17 02:09:27 by arkane
thnx arkane it works !

It works with a simple EDIT control (textarea)..i'll see at work if it works with the unknown window control..
by the way what can it be ? it's class name is Afx:400000:202b:10011:6:0 looks like a richedit comp but
like i sad it is not respondig of any of the usual SendMessage EM_....WM_GETTEXT..... ???
Posted on 2003-07-17 02:26:17 by andras
Unfortunately if it is a custom control the person who wrote the control was the one who decided what it will and won't respond to. There isn't really an easy way to find out unless the author of the control can give you some documentation on it.
Posted on 2003-07-17 02:32:04 by donkey