'VBA like AutoHotKeys Features
OK, revised my old question better:: deleted the other one. I am still new to coding and have kinda put this together from other things I found online. I am trying to make a AHK style mouse mover and clicker. The moving and clicking works, but I can't get it to click and drag (to highlight things) and can't get the copy/paste to work. This is on work computer and I can not use AHK so making it in VBA.
NOT CODE BUT Stack made me indent!!! Spreadsheet layout:
ColA = x coordinates
Cold = y coordinates
ColC = Sleep
ColD = Click down only. (to highlight something)
ColE = Click up only. (to highlight something)
ColF = copy
ColG = Paste
ColJ = Enter
It keeps giving me an error on j = Range(theAddressJ).Value But I don't know why.
Private Declare PtrSafe Function SetCursorPos Lib "user32"
(ByVal X As Long, ByVal Y As Long) As Long
Private Declare PtrSafe 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)
Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
Private Const MOUSEEVENTF_RIGHTDOWN As Long = &H8
Private Const MOUSEEVENTF_RIGHTUP As Long = &H10
Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Declare PtrSafe Function GetCursorPos Lib "user32" (lpPoint As
POINTAPI) As Long
Public Type POINTAPI
X As Long
Y As Long
End Type
Sub Move()
Dim LastRow As Long
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
Dim i As Integer
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim d As String
Dim e As String
Dim f As String
Dim g As String
Dim j As String
Dim theAddressA As String
Dim theAddressB As String
Dim theAddressC As String
Dim theAddressD As String
Dim theAddressE As String
Dim theAddressF As String
Dim theAddressG As String
Dim theAddressJ As String
i = 2
Do While i <= LastRow
theAddressA = "A" & CStr(i)
theAddressB = "B" & CStr(i)
theAddressC = "C" & CStr(i)
theAddressD = "D" & CStr(i)
theAddressE = "E" & CStr(i)
theAddressF = "F" & CStr(i)
theAddressG = "G" & CStr(i)
theAddressG = "J" & CStr(i)
a = Range(theAddressA).Value
b = Range(theAddressB).Value
c = Range(theAddressC).Value
d = Range(theAddressD).Value
e = Range(theAddressE).Value
f = Range(theAddressF).Value
g = Range(theAddressG).Value
j = Range(theAddressJ).Value
SetCursorPos a, b
If Not Range(theAddressD) = "" Then
Application.Wait Now + TimeSerial(0, 0, 1)
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
End If
If Not Range(theAddressE) = "" Then
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
Application.Wait Now + TimeSerial(0, 0, 1)
End If
Sleep c
If Not Range(theAddressF) = "" Then
SendKeys "^(C)"
End If
If Not Range(theAddressG) = "" Then
SendKeys "^(V)"
End If
If Not Range(theAddressJ) = "" Then
SendKeys "(ENTER)"
End If
Sleep 700
i = i + 1
Loop
End Sub
I also want to know if someone can help me with a click recorder so I don't have to keep manually finding the pixels and writing them down to input in cells, maybe something that just recorded the clicks like AHK can do to make these things faster. Any help is appreciated.
Wish I could just download AHK but not worth risking it with this company
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
