Click here to Skip to main content
15,894,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a problem:
I want to Simulate mouse button by use Virtual Key Codes

VB
Public Declare Function SetActiveWindow Lib "user32" Alias "SetActiveWindow" _
(ByVal hwnd As Long) As Long
Declare Function keybd_event Lib "user32" Alias "keybd_event" _
(ByVal bVk As Byte, ByVal bScan _
As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) As Long


VB
Const VK_LBUTTON = &H1


And when i call:

VB
SetActiveWindow(8975651603260375040)
keybd_event(VK_LBUTTON, 0, 0, 0)
keybd_event(VK_LBUTTON, 0, KEYEVENTF_KEYUP, 0)


=>>NOT WORK
Please help me!:confused:
Posted
Updated 3-Mar-10 20:44pm
v2

1 solution

I have been looking at this, and trying various things, but get the same thing. I have noticed in the API docs that keybd_event has been replaced by SendInput in the newer OS's. I have even written some code with the newer API and it still doesn't work. It won't beat me.

In the mean time, you may want to have a try using SendInput. See the references on MSDN and these two links;

http://www.pinvoke.net/default.aspx/user32.SendInput[^]

http://forums.devx.com/archive/index.php/t-84391.html[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900