Hi everyone,
I've been self studying VBA for a few months (I had no programming experience before that) and am stuck on a project I tried to do for fun / as a test for myself. Any help or guidance in the right direction would be much appreciated.
Basically I wanted to make a spreadsheet that would automate basic mouse clicks and keyboard inputs (not limited to within excel), but I cant get the keyboard input part to work.
The problem seems to be that the VBA window becomes active after each line is executed, so the sendkeys function sends the keys to VBA (is that right?)
If that is the issue, is there a way to stop the VBA window from becoming active?
If not, can anyone recommend an alternative way I could do this?
Here is what I have:
Example sheet structure:
VBA Code:
Public Sub RunInputSheet()
Dim Action_Type As String
Dim wait_time As Date
Dim Xposition As Long
Dim Yposition As Long
Dim clicks As Long
Dim KeysString As String
Worksheets("Inputs").Range("B2").Select
Action_Type = ActiveCell.Text
wait_time = ActiveCell.Offset(0, 1).Value
Xposition = ActiveCell.Offset(0, 2).Value
Yposition = ActiveCell.Offset(0, 3).Value
clicks = ActiveCell.Offset(0, 4).Value
KeysString = ActiveCell.Offset(0, 5).Text
Do Until IsEmpty(ActiveCell.Value)
Application.wait (Now + TimeValue(wait_time))
Select Case Action_Type
Case "Mouse Click"
Call Set_Cursor_Pos2(Xposition, Yposition)
Call ClickXAmountsOfTimes(clicks)
Case "Send Keys"
SendKeys KeysString, 10000
End Select
ActiveCell.Offset(1, 0).Select
Loop
MsgBox ("Macro Complete")
End Sub
I've been self studying VBA for a few months (I had no programming experience before that) and am stuck on a project I tried to do for fun / as a test for myself. Any help or guidance in the right direction would be much appreciated.
Basically I wanted to make a spreadsheet that would automate basic mouse clicks and keyboard inputs (not limited to within excel), but I cant get the keyboard input part to work.
The problem seems to be that the VBA window becomes active after each line is executed, so the sendkeys function sends the keys to VBA (is that right?)
If that is the issue, is there a way to stop the VBA window from becoming active?
If not, can anyone recommend an alternative way I could do this?
Here is what I have:
Example sheet structure:
VBA Code:
Public Sub RunInputSheet()
Dim Action_Type As String
Dim wait_time As Date
Dim Xposition As Long
Dim Yposition As Long
Dim clicks As Long
Dim KeysString As String
Worksheets("Inputs").Range("B2").Select
Action_Type = ActiveCell.Text
wait_time = ActiveCell.Offset(0, 1).Value
Xposition = ActiveCell.Offset(0, 2).Value
Yposition = ActiveCell.Offset(0, 3).Value
clicks = ActiveCell.Offset(0, 4).Value
KeysString = ActiveCell.Offset(0, 5).Text
Do Until IsEmpty(ActiveCell.Value)
Application.wait (Now + TimeValue(wait_time))
Select Case Action_Type
Case "Mouse Click"
Call Set_Cursor_Pos2(Xposition, Yposition)
Call ClickXAmountsOfTimes(clicks)
Case "Send Keys"
SendKeys KeysString, 10000
End Select
ActiveCell.Offset(1, 0).Select
Loop
MsgBox ("Macro Complete")
End Sub