Solved

about mouse click

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

705 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