Solved

about mouse click

Posted on 2000-05-17
3
144 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

763 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now