Click here to Skip to main content
15,905,683 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Mouse Event Pin
wangningyu26-Feb-10 21:07
wangningyu26-Feb-10 21:07 
1、keyboard event:

keybd_event(VK_CONTROL,0,0,0);
keybd_event(VK_MENU, 0, 0, 0);  
keybd_event('S', 0, 0, 0);   
 
keybd_event('S', 0, KEYEVENTF_KEYUP, 0);   
keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);  


::PostMessage(hWnd,WM_KEYDOWN,VK_CONTROL,0);
::PostMessage(hWnd,WM_KEYDOWN,VK_MENU,0);
::PostMessage(hWnd,WM_KEYDOWN,'1',0);

::PostMessage(hWnd,WM_KEYUP,'1',0);
::PostMessage(hWnd,WM_KEYUP,VK_MENU,0);
::PostMessage(hWnd,WM_KEYUP,VK_CONTROL,0);



2、mouse event:
CString gameCaption="XXXXX";
HWND	hWnd=::FindWindow(NULL,gameCaption);
DWORD	dwPid;
RECT	rect;
POINT	ptOld;

::GetWindowThreadProcessId(hWnd,&dwPid);
::GetWindowRect(hWnd,&rect);

::GetCursorPos(&ptOld);
::SetCursorPos(80,150);

mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);

SetCursorPos(rect.left +200,rect.top +150);
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);


CString gameCaption="XXXXX";
HWND	hWnd=::FindWindow(NULL,gameCaption);

::PostMessage(hWnd,WM_MOUSEMOVE, MK_LBUTTON, MAKELONG(80,130));
::PostMessage(hWnd,WM_LBUTTONDOWN,MK_LBUTTON,MAKELPARAM(80,130));   
::PostMessage(hWnd,WM_LBUTTONUP,MK_LBUTTON,MAKELPARAM(80,130));
Sleep(10);



more Information,please click here.
http://blog.csdn.net/wangningyu/archive/2009/12/13/4994295.aspx
QuestionCompressed image movement is too slow Pin
Game-point25-Feb-10 19:25
Game-point25-Feb-10 19:25 
AnswerRe: Compressed image movement is too slow Pin
Stuart Dootson25-Feb-10 20:43
professionalStuart Dootson25-Feb-10 20:43 
GeneralRe: Compressed image movement is too slow Pin
Game-point25-Feb-10 21:41
Game-point25-Feb-10 21:41 
GeneralRe: Compressed image movement is too slow Pin
Stuart Dootson25-Feb-10 21:44
professionalStuart Dootson25-Feb-10 21:44 
GeneralRe: Compressed image movement is too slow Pin
Game-point25-Feb-10 22:18
Game-point25-Feb-10 22:18 
QuestionHow to Get List of Function Pin
Anubhava Dimri25-Feb-10 17:32
Anubhava Dimri25-Feb-10 17:32 
AnswerRe: How to Get List of Function Pin
Cool_Dev25-Feb-10 18:02
Cool_Dev25-Feb-10 18:02 
AnswerRe: How to Get List of Function Pin
Joshua Tully25-Feb-10 18:02
Joshua Tully25-Feb-10 18:02 
QuestionDuplicatreHande question Pin
ForNow25-Feb-10 15:32
ForNow25-Feb-10 15:32 
AnswerRe: DuplicatreHande question Pin
Gwenio25-Feb-10 16:08
Gwenio25-Feb-10 16:08 
QuestionExporting a struct from a DLL Pin
masnu25-Feb-10 9:57
masnu25-Feb-10 9:57 
AnswerRe: Exporting a struct from a DLL Pin
Richard MacCutchan25-Feb-10 10:26
mveRichard MacCutchan25-Feb-10 10:26 
AnswerRe: Exporting a struct from a DLL Pin
Avi Berger25-Feb-10 10:36
Avi Berger25-Feb-10 10:36 
QuestionQuestion on Dialog & ComboBox Pin
Software200725-Feb-10 8:08
Software200725-Feb-10 8:08 
AnswerRe: Question on Dialog & ComboBox Pin
Maximilien25-Feb-10 8:13
Maximilien25-Feb-10 8:13 
GeneralRe: Question on Dialog & ComboBox Pin
Software200725-Feb-10 8:18
Software200725-Feb-10 8:18 
QuestionRe: Question on Dialog & ComboBox Pin
David Crow25-Feb-10 17:10
David Crow25-Feb-10 17:10 
AnswerRe: Question on Dialog & ComboBox Pin
KingsGambit25-Feb-10 19:21
KingsGambit25-Feb-10 19:21 
AnswerRe: Question on Dialog & ComboBox Pin
David Crow26-Feb-10 4:18
David Crow26-Feb-10 4:18 
QuestionUsing Flashvars in MFC C++ Pin
lesliecasas25-Feb-10 7:36
lesliecasas25-Feb-10 7:36 
QuestionProblem with owner-drawn list box Pin
sashoalm25-Feb-10 6:30
sashoalm25-Feb-10 6:30 
AnswerRe: Problem with owner-drawn list box Pin
Maximilien25-Feb-10 7:41
Maximilien25-Feb-10 7:41 
AnswerRe: Problem with owner-drawn list box Pin
Eugen Podsypalnikov25-Feb-10 20:09
Eugen Podsypalnikov25-Feb-10 20:09 
Questionaccounting for the scrollbar GetSystemMetrics(SM_CYBORDER) Pin
23_44425-Feb-10 6:08
23_44425-Feb-10 6:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.