Issues with simulating cell selection in Excel using PostMessage
Posted
by DD
on Stack Overflow
See other posts from Stack Overflow
or by DD
Published on 2010-04-03T21:49:29Z
Indexed on
2010/04/03
21:53 UTC
Read the original article
Hit count: 251
win32
Hi all,
So far I've tried drag/drop motion in many applications including Visualization software (moving time slider left/right), Photoshop-Paint (drawing) etc. I need some more testing before I make sure that my system works and it failed in Excel.
I'm using the code below to send the input:
m.x = 215; m.y = 200 + 36 + 9 * ( currentTime - 1 );
childH = findChild( w->getHandle(), m );
PostMessage( childH, WM_MOUSEMOVE, 0, MAKELPARAM( m.x, m.y ) );
PostMessage( childH, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM( m.x, m.y ) );
m.x = 215; m.y = 200 + 36 + 9 * ( currentTime );
childH = findChild( w->getHandle(), m );
PostMessage( childH, WM_MOUSEMOVE, MK_LBUTTON, MAKELPARAM( m.x, m.y ) );
PostMessage( childH, WM_LBUTTONUP, 0, MAKELPARAM( m.x, m.y ) );
I can click anywhere in Excel and select the cell, or activate buttons/menus anything. I can even drag a plot around (with the code above) but it doesn't work for clicking and dragging the mouse to select multiple cells. It just doesn't do anything.
I can't use SendInput because the window doesn't have the focus and is in background.
Thanks!
© Stack Overflow or respective owner