Solved

about mouse click

Posted on 2000-05-17
3
146 Views
Last Modified: 2010-05-02
Private Sub Timer1_Timer()
    Dim lngForeGroundWindow As Long
    lngForeGroundWindow = GetForegroundWindow()
    SendMessage lngForeGroundWindow, WM_LBUTTONDOWN, 0, 0
End Sub

i wanted the mouse to click ,but failed.
what's the matter?
(the click message is sent to another application programe
0
Comment
Question by:bitsnake
3 Comments
 
LVL 1

Expert Comment

by:ofirg
ID: 2820035
Try

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_SETFOCUS = &H7

public sub my_click

    dim retval as long

    Retval = FindWindow(0&, "<the window caption>")
    call SendMessage(Retval, WM_SETFOCUS, 0&, 0&)

    SendMessage Retval, WM_LBUTTONDOWN, 0, 0

end sub
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2820110
try using the mouse_event instead. heres a sample and description

http://www.vbapi.com/ref/m/mouse_event.html
0
 
LVL 12

Accepted Solution

by:
pjknibbs earned 50 total points
ID: 2820161
bitsnake: In order to make sure the receiving application knows what's happening you should send a WM_LBUTTONDOWN followed by a WM_LBUTTONUP: most applications use the button-up message to do their click processing, and you should always pair these messages like this anyway.
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question