View Single Post
  #3  
Old 14th August 2006, 04:23
sebart7 sebart7 is offline
Junior Member
 
Join Date: Aug 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default mouse_event, keybd_event, SetCursorPos

Not really.
GetAsyncKeyState is to check if certain key is pressed.

----------------------------------------------------------------------
example in assembly (masm32) to push space bar

FUNCTION

VOID keybd_event(
BYTE bVk, // virtual-key code
BYTE bScan, // hardware scan code
DWORD dwFlags, // flags specifying various function options
DWORD dwExtraInfo // additional data associated with keystroke
);


EXAMPLE PRESS SPACE BAR

invoke keybd_event,VK_SPACE,0,0,0 ; key down
invoke Sleep,50 ; wait a moment
invoke keybd_event,VK_SPACE,0,KEYEVENTF_KEYUP,0 ; key up

to push other keys use VK_A for "a" key VK_1 for "1" ect

----------------------------------------------------------------------
example in assembly (masm32) to push mouse key

FUNCTION

VOID mouse_event(
DWORD dwFlags, // flags specifying various motion/click variants
DWORD dx, // horizontal mouse position or position change
DWORD dy, // vertical mouse position or position change
DWORD dwData, // amount of wheel movement
DWORD dwExtraInfo // 32 bits of application-defined information
);


EXAMPLE PRESS LEFT MOUSE KEY

invoke mouse_event,MOUSEEVENTF_LEFTDOWN ,0,0,0,0 ; key down
invoke Sleep,50 ; wait a moment
invoke mouse_event,MOUSEEVENTF_LEFTUP,0,0,0,0 ; key up

Remark Touse dx and dy set flag as MOUSEEVENTF_MOVE MOUSEEVENTF_ABSOLUTE

invoke mouse_event,MOUSEEVENTF_LEFTDOWN or MOUSEEVENTF_MOVE or MOUSEEVENTF_ABSOLUTE,1000,1000,0,0 ; key down and move to 1000,1000

----------------------------------------------------------------------
example in assembly (masm32) to set mouse in x y position

FUNCTION

BOOL SetCursorPos(
int X, // horizontal position
int Y // vertical position
);


EXAMPLE

invoke SetCursorPos,100,100 ; set mouse pos to 100,100





You may be interested to check details for functions mentioned above.
Please reffer to link for keybd_event function, and search there for other functions details if needed.

Last edited by sebart7; 14th August 2006 at 04:29.
Reply With Quote