上級68回のコード

Declare PtrSafe Sub mouse_event Lib "user32" ( _
ByVal dwFlags As Long, _
Optional ByVal dx As Long, _
Optional ByVal dy As Long, _
Optional ByVal dwDate As Long, _
Optional ByVal dwExtraInfo As Long)
Declare PtrSafe Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long

#If VBA7 Then
Private Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal ms As LongPtr)
#Else
Private Declare Sub Sleep Lib "kernel32" (ByVal ms As Long)
#End If

Sub test68_1()
Dim driver As New ChromeDriver
   
driver.Start "chrome"
driver.Window.SetPosition 200, 200

SetCursorPos 206, 325
Stop

End Sub
Sub test68_2()
Dim driver As New ChromeDriver
Dim bx As Integer
Dim by As Integer
bx = 206
by = 325
   
driver.Start "chrome"
driver.Window.SetPosition 200, 200

SetCursorPos bx, by
Stop

End Sub

Sub test68_3()
Dim driver As New ChromeDriver
Dim bx As Integer
Dim by As Integer
bx = 206
by = 325
   
driver.Start "chrome"
driver.Window.SetPosition 200, 200

driver.Get "https://rakuten.co.jp/"
Stop
driver.ExecuteScript "scrollTo(0, 1150);"
SetCursorPos bx + 100, by + 350

Stop

End Sub

Sub test68_4()
Dim driver As New ChromeDriver
Dim bx As Integer
Dim by As Integer
bx = 206
by = 325
   
driver.Start "chrome"
driver.Window.SetPosition 200, 200
driver.Get "https://rakuten.co.jp/"
driver.ExecuteScript "scrollTo(0, 1150);"
SetCursorPos bx + 100, by + 350
Sleep 500
SetCursorPos bx + 420, by + 350
Sleep 500
SetCursorPos bx + 420, by + 115
Sleep 500
mouse_event &H2, 0, 0, 0, 0
mouse_event &H4, 0, 0, 0, 0

Stop
End Sub
Sub test68_5()

SetCursorPos 100, 400
mouse_event &H2, 0, 0, 0, 0
Sleep 500
SetCursorPos 100, 600
Sleep 500
SetCursorPos 300, 600
Sleep 500
SetCursorPos 300, 400
Sleep 500
SetCursorPos 100, 400
Sleep 500
SetCursorPos 300, 600
mouse_event &H4, 0, 0, 0, 0
End Sub

いいなと思ったら応援しよう!