Re: SendInput won't compile
I moved the #define _WIN32_WINNT into the "stdafx.h" file before the MFC
headers and that seems to solve the problem. Thanks! But now the compiler
found 2 undeclared identifiers
XBUTTON1 and
MOUSEEVENTF_XUP
Here is the code:
void CMimicMouseClickDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
UINT x,y;
INPUT Input;
x=GetDlgItemInt(IDC_TXT_X);
y=GetDlgItemInt(IDC_TXT_Y);
if(nIDEvent==1)
{
//::PostMessage(HWND_BROADCAST,WM_LBUTTONDBLCLK,0,0);
//mouse_event(MOUSEEVENTF_LEFTUP,x,y,0,0);
Input.type=INPUT_MOUSE;
Input.mi.dx=x;
Input.mi.dy=y;
Input.mi.mouseData=XBUTTON1;
Input.mi.dwFlags=MOUSEEVENTF_XUP;
Input.mi.time=0;
Input.mi.dwExtraInfo=0;
SendInput(1,&Input,sizeof(INPUT));
}
CDialog::OnTimer(nIDEvent);
}
I searched the winuser.h and they are not defined there! I am using Visual
Studio 6 service pack 6.
Dave
"Joseph M. Newcomer" <newcomer@flounder.com>
??????:5s4ps5l1cnhfqsf87easp455ecpgj2pfuq@4ax.com...
Not sure why you think 0x0501 is going to change ANYTHING, since this was
defined for
Windows NT 4.0 SP 3. So pretty much any setting is going to work!
Even the most casual inspection of the header file shows that this is
conditional under
_WIN32_WINNT > 0x0400. I believe the default values are already greater
than this.
Of course, I'm assuming that you did this definition in stdafx.h, BEFORE
any of the
Windows or MFC header files were included!
Telling us you "defined" it conveys no useful information; knowing WHERE
you defined it
matters a lot! And, of course, you did not mention which version of VS
you were using;
some versions define this symbol in another header file, so if you did
your own #define,
it will be modified by the header file produced by VS.
Show your stdafx.h and where you defined it!
Since you did not say WHERE you defined it, or given any error messages,
it is hard to
guess what is going on here. If you defined it anywhere OTHER than in
stdafx.h, then it
didn't do anything!
joe
On Tue, 20 Apr 2010 01:07:57 +0800, "dave" <xg1@yahoo.com> wrote:
Hi, I try to use the sendinput() function to fire mouse events, but it
won't
compile even after I defined the _WIN32_WINNT as 0x0501. Why is that?
Thanks a bunch.
dave
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm