Solved

about mouse click

Posted on 2000-05-17
3
147 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

856 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