Option Explicit Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long Private x0 As Integer, y1 As Integer, y0 As Integer, x1 As Integer Private Sub Command1_Click() x0 = Image1.Left y0 = Image1.Top x1 = Int(((Me.Width - Image1.Width) * Rnd)) y1 = Int(((Me.Height - Image1.Height) * Rnd)) With Line1 .x1 = x0 .x2 = x1 .y1 = y0 .y2 = y1 End With Timer1.Interval = 1 'ne pas toucher à cet intervalle Timer1.Enabled = True End Sub Private Sub Timer1_Timer() Dim fract As Integer, pas As Integer, k As Integer, x2 As Integer, y2 As Integer, a As Single, b As Single, fin As Boolean ', i As Integer fract = 250 'ici la fraction à parcourir à chaque intervalle (influe donc sur la rapidité) 'plus fract est petit, plus la rapidité est grande Static i As Integer If x1 <> x0 Then a = (y1 - y0) / (x1 - x0) b = y1 - a * x1 k = IIf(x1 < x0, -1, 1) pas = Abs((x1 - x0) \ fract) x2 = x0 + (i * pas * k) y2 = (a * (x2)) + b If x2 > x1 And x1 > x0 Then fin = True If x2 < x1 And x1 < x0 Then fin = True Else k = IIf(y1 < y0, -1, 1) pas = Abs((y1 - y0) / fract) x2 = x0 y2 = y0 + (i * pas * k) If y2 > y1 And y1 > y0 Then fin = True If y2 < y1 And y1 < y0 Then fin = True End If If fin Then Timer1.Enabled False: i 0: fin = False: Exit Sub SetCursorPos ((x2 / 15) + Me.Left / 15), ((y2 / 15) + Me.Top / 15) SetCursorPos ScaleX(x2 + Me.Left, Me.ScaleMode, vbPixels), ScaleY(y2 + Me.Top, Me.ScaleMode, vbPixels) Image1.Move x2, y2 i = i + 1 End Sub
pour faire un déplacement à une certaine vitesse un peu de prog avec un timer.intervalle=lavitesse
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
If Parm1 = "Personnage" Then
NAM.Label15.FontSize = 14
NAM.Label15.Caption = vbCrLf & "Choisir son Personnage"
NAM.Label15.Visible = True
Call Pause(2)
I1 = 0
Tabb(I1) "Gauche": Tabx(I1) 920: Taby(I1) = 279: Tabk(I1) = 0: I1 = I1 + 1
Tabb(I1) "Gauche": Tabx(I1) 919: Taby(I1) = 437: Tabk(I1) = 0: I1 = I1 + 1
Tabb(I1) "Gauche": Tabx(I1) 920: Taby(I1) = 564: Tabk(I1) = 0: I1 = I1 + 1
Tabb(I1) "Gauche": Tabx(I1) 916: Taby(I1) = 705: Tabk(I1) = 0: I1 = I1 + 1
Tabb(I1) "Gauche": Tabx(I1) 922: Taby(I1) = 288: Tabk(I1) = 0: I1 = I1 + 1
Call Traitement
Exit Sub
End If
End Sub
'--------------------------------------------------------------------------------'
' '
' Simulation d'un Click Souris '
' '
'--------------------------------------------------------------------------------'
Sub Traitement()
Dim J1 As Integer
For J1 = 0 To UBound(Tabx)
If Tabx(J1) = 0 Then Exit For
SetCursorPos Tabx(J1), Taby(J1)
Call Pause(0.17)
Call mouse_event(&H2 Or &H4, Tabx(J1), Taby(J1), 0, 0)
Call Pause(1.5)
Next J1
End Sub
Option Explicit Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long Private x0 As Integer, y1 As Integer, y0 As Integer, x1 As Integer Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long Dim barre As Boolean, bords As Boolean, plusb As Integer, plusc As Integer Private Sub Command1_Click() Randomize Timer If Me.BorderStyle = 0 Then barre = False bords = False Else If ControlBox False Then barre False Else barre = True bords = True End If If barre Then plusb GetSystemMetrics(4) Else plusb 0 If bords Then plusc GetSystemMetrics(5) Else plusc 0 x0 = ScaleX(Int(Me.Width * Rnd), vbTwips, Me.ScaleMode) y0 = ScaleY(Int(Me.Height * Rnd), vbTwips, Me.ScaleMode) x1 = ScaleX(Int((Me.Width) * Rnd), vbTwips, Me.ScaleMode) y1 = ScaleY(Int((Me.Height * Rnd)), vbTwips, Me.ScaleMode) With Line1 .x1 = x0 .x2 = x1 .y1 = y0 .y2 = y1 End With Timer1.Interval = 1 'ne pas toucher à cet intervalle Timer1.Enabled = True End Sub Private Sub Timer1_Timer() Dim fract As Integer, pas As Integer, k As Integer, x2 As Integer, y2 As Integer, a As Single, b As Single, fin As Boolean ', i As Integer fract = 250 'ici la fraction à parcourir à chaque intervalle (influe donc sur la rapidité) 'plus fract est petit, plus la rapidité est grande If Me.ScaleMode vbPixels Then fract fract / 2 If Me.ScaleMode vbPoints Then fract fract / 4 Static i As Integer If x1 <> x0 Then a = (y1 - y0) / (x1 - x0) b = y1 - a * x1 k = IIf(x1 < x0, -1, 1) pas = Abs((x1 - x0) \ fract) If pas 0 Then pas 1 x2 = x0 + (i * pas * k) y2 = (a * (x2)) + b If x2 >= x1 And x1 > x0 Then fin = True ElseIf x2 <= x1 And x1 < x0 Then fin = True ElseIf y2 <= y1 And y1 < y0 Then fin = True ElseIf y2 >= y1 And y1 > y0 Then fin = True End If Else k = IIf(y1 < y0, -1, 1) pas = Abs((y1 - y0) / fract) x2 = x0 y2 = y0 + (i * pas * k) If y2 >y1 And y1 > y0 Then fin True If y2 <y1 And y1 < y0 Then fin True End If If fin Then Timer1.Enabled False: i 0: fin = False: Exit Sub SetCursorPos ScaleX(x2, Me.ScaleMode, vbPixels) + ScaleX(Me.Left, vbTwips, vbPixels) + plusc, ScaleY(y2, Me.ScaleMode, vbPixels) + ScaleY(Me.Top, vbTwips, vbPixels) + plusb + (2 * plusc) i = i + 1 End Sub
il va falloir que je la décortique pour la comprendre