?
Solved

about mouse click

Posted on 2000-05-17
3
Medium Priority
?
150 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 150 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month9 days, 13 hours left to enroll

762 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