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!
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
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
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
RE: Move the mouse from VB
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