×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Move the mouse from VB

Move the mouse from VB

Move the mouse from VB

(OP)
Hello

I need ideas to move the mouse to specific locations of the screen (not only my programm), and click over there.

Thanks a lot!

RE: Move the mouse from VB

(OP)
After a long wait, I solved this problem on my own.

In a module, you have to declare

Public Declare Function GetTickCount Lib "kernel32" () As Long

Public Sub wait(ByVal dblMilliseconds As Double)
    Dim dblStart As Double
    Dim dblEnd As Double
    Dim dblTickCount As Double
    
    dblTickCount = GetTickCount()
    dblStart = GetTickCount()
    dblEnd = GetTickCount + dblMilliseconds
    
    Do
    DoEvents
    dblTickCount = GetTickCount()
    Loop Until dblTickCount > dblEnd Or dblTickCount < dblStart
       
    
End Sub



all what you kave to do now is to call wait(num), when num in the amount of miliseconds that the program waits to continue in the next line.

Thanks to me!

RE: Move the mouse from VB

(OP)
Again, i solved the problem before someone replys me.

In a module, declare:

Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Public Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Public Const mouse_eventC = &H2     '  Event contains mouse event record
Public Const MOUSE_MOVED = &H1
Public Const MOUSEEVENTF_ABSOLUTE = &H8000 '  absolute move
Public Const MOUSEEVENTF_LEFTDOWN = &H2 '  left button down
Public Const MOUSEEVENTF_LEFTUP = &H4 '  left button up
Public Const MOUSEEVENTF_MIDDLEDOWN = &H20 '  middle button down
Public Const MOUSEEVENTF_MIDDLEUP = &H40 '  middle button up
Public Const MOUSEEVENTF_MOVE = &H1 '  mouse move
Public Const MOUSEEVENTF_RIGHTDOWN = &H8 '  right button down
Public Const MOUSEEVENTF_RIGHTUP = &H10 '  right button up
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

Public Type POINTAPI
    X As Long
    Y As Long
End Type

Public Function GetX() As Long
    Dim n As POINTAPI
    GetCursorPos n
    GetX = n.X
End Function

Public Function GetY() As Long
    Dim n As POINTAPI
    GetCursorPos n
    GetY = n.Y
End Function

-------------------------------------------

Now to move the mouse to a certain location, and clic there, you have to call in this way

SetCursorPos X, Y
    mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
    mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
---------------------------------------------
Thaks to me.!

RE: Move the mouse from VB

Good work, and thanks for posting the solution for the rest of us!

RE: Move the mouse from VB

'Add attachment(s) - ALL .PDF files within app.path directory - destroy file after adding as attachment and copying to fileserver
Dim g_AttPass% '// Attacment Index
Dim New_File3$ '// File string
g_AttPass = -1
Do while dir(app.path & "\*.PDF") > ""
    New_File3 = Dir(App.Path & "\*.PDF")
    FileCopy App.Path & "\" & New_File3, "\\Fileserver1\FILESER1_E\web solidworks dwg_pdf\" & New_File3
    Kill App.Path & "\" & New_File3
    g_AttPass = g_AttPass + 1 'Increment attachment index
    MAPIMessages1.AttachmentIndex = MAPIMessages1.AttachmentCount
    MAPIMessages1.AttachmentPosition = g_AttPass
    MAPIMessages1.AttachmentPathName = "\\Fileserver1\FILESER1_E\web solidworks dwg_pdf\" & New_File3
Loop

RE: Move the mouse from VB

SORRY - POSTED IN WRONG THREAD!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close