|
Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
MOUSE TRACKER
Information sur la source
Description
Bon voila un ptit prog vite fait qui indique la position du curseur en le faisant suivre pas des lignes, attention sa vous paraitra peut etre faut les mesure mais c'est pk en fait il y a un cdre qui en vrai delimite les borts du curseur.
Donc il vous faut :
1 Form (Form1)
1 Module (Module1)
4 lignes (line1, line2, line3, line4)
1 label (label1)
1 timer (timer1)
2 frame l'une dans l'autre (frame1, frame2)
6 option butons (option1(0), option1(1), option1(2) (dans la frame1), option2(0), option2(1), option2(2) (dans la frame2))
2 checkbox (check1 (dans la frame2), check2 (dans la frame1))
Bon vous foutez tout sa en vrac sur la form et sa s'organize tout seul !!
Si vous voulez pas telecharger le zip
Par contre il y a une partie a metre dans un module et une autre dans la form
Source
- 'A METRE DANS UN MODULE :
- Option Explicit
-
- Declare Function ClipCursor Lib "user32" (lpRect As RECT) As Long
- Declare Function GetCursorPos Lib "user32" (lpPoint As POINT_TYPE) As Long
- Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
-
- Public Type RECT
- Left As Long
- Top As Long
- Right As Long
- Bottom As Long
- End Type
- Type POINT_TYPE
- X As Long
- Y As Long
- End Type
-
- Public Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
- Public Declare Function OpenDriver Lib "winmm.dll" Alias "OpenDriverA" (ByVal DriverName As String) As Long
-
- 'A METRE DANS LA FORM
- Option Explicit
- Dim p As POINT_TYPE
- Dim i As Variant
- Dim OK As Boolean
- Dim XX, YY As Long
- Private Sub Form_Load()
- 'Positionement et configuration des objets
- Me.Height = 6825
- Me.Width = 8640
- Me.Left = (Screen.Width - Me.Width) / 2
- Me.Top = (Screen.Height - Me.Height) / 2
- Label1.AutoSize = True
- Label1.Top = 0
- Label1.Left = (Me.Width - Label1.Width) / 2
- Label1.BackColor = vbWhite
- Label1.ForeColor = vbRed
- Option1(0).Caption = "Contours"
- Option1(2).Caption = "Pointeur"
- Option1(1).Caption = "Milieu"
- For i = 0 To 2
- Option1(i).Top = 240
- Option2(i).Caption = Option1(i).Caption
- Option2(i).Enabled = False
- Option2(i).Top = 240
- Next i
- Option1(0).Left = 120
- Option1(1).Left = 1080
- Option1(2).Left = 1920
- Option2(0).Left = 120
- Option2(1).Left = 1200
- Option2(2).Left = 2040
- Timer1.Enabled = True
- Timer1.Interval = 1
- Frame1.Height = 1575
- Frame1.Width = 3735
- Frame1.Left = 4800
- Frame1.Top = 5160
- Frame1.Caption = "Options"
- Frame2.Height = 615
- Frame2.Width = 3495
- Frame2.Left = 120
- Frame2.Top = 480
- Check1.Caption = "Bords"
- Check1.Top = 0
- Check1.Left = 120
- Check2.Caption = "Lignes en pointiés"
- Check2.Top = 1200
- Check2.Left = 120
- Command1.Caption = "x"
- Command1.Left = 8400
- Command1.Top = 0
- Command1.Width = 135
- Command1.Height = 135
- End Sub
- '!
- '!Code de Deplacement d'une Form a partir d'un objet, par OverDarck
- Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
- OK = True
- XX = X
- YY = Y
- End Sub
- Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
- If OK = True Then
- Call mov(X, Y, Button)
- End If
- End Sub
- Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
- OK = False
- If Me.Top < 0 Then Me.Top = 0
- If Me.Left < 0 Then Me.Left = 0
- If Me.Top > Screen.Height - Me.Height Then Me.Top = Screen.Height - Me.Height
- If Me.Left > Screen.Width - Me.Width Then Me.Left = Screen.Width - Me.Width
- XX = 0
- YY = 0
- End Sub
- Private Sub mov(X As Single, Y As Single, Button As Integer)
- If Not Button = 1 Then Exit Sub
- Form1.Move X + Form1.Left - XX, Y + Form1.Top - YY
- End Sub
- '!Fin du code
- '!
- Private Sub Check2_Click()
- If Check2.Value = 0 Then
- Line1.BorderStyle = 1
- Line2.BorderStyle = 1
- Line3.BorderStyle = 1
- Line4.BorderStyle = 1
- ElseIf Check2.Value = 1 Then
- Line1.BorderStyle = 3
- Line2.BorderStyle = 3
- Line3.BorderStyle = 3
- Line4.BorderStyle = 3
- End If
- End Sub
- Private Sub Option1_Click(Index As Integer)
- Timer1.Enabled = False
- If Option1(Index).Value = True Then
- Check1.Value = 0
- For i = 0 To 2
- Option2(i).Enabled = False
- Next i
- End If
- Timer1.Enabled = True
- End Sub
- Private Sub Timer1_Timer()
- Select Case Check1.Value
- Case 0
- With Line1
- .Y1 = -240
- .Y2 = 7560
- End With
- With Line3
- .Y1 = -240
- .Y2 = 7560
- End With
- With Line2
- .X1 = 0
- .X2 = 12360
- End With
- With Line4
- .X1 = 0
- .X2 = 12360
- End With
- '!!
- Case 1
- '!!
- With Line1
- .Y1 = -7320
- .Y2 = 480
- End With
- With Line3
- .Y1 = 6600
- .Y2 = 14400
- End With
- With Line2
- .X1 = -12120
- .X2 = 240
- End With
- With Line4
- .X1 = 8400
- .X2 = 20760
- End With
- For i = 0 To 2
- Option1(i).Value = False
- Option2(i).Enabled = True
- Next i
- End Select
-
-
-
- 'Position relative au deplacement du pointeur enregistre pas windob
- GetCursorPos p
-
- Label1.Caption = "Position X : " & p.X * 15 & " Y : " & p.Y * 15
-
- If Option1(0).Value = True Then
- If Line1.Visible = False Then Line1.Visible = True
- If Line2.Visible = False Then Line2.Visible = True
- If Line3.Visible = False Then Line3.Visible = True
- If Line4.Visible = False Then Line4.Visible = True
- With Line1
- .X1 = p.X * 15 - Form1.Left
- .X2 = p.X * 15 - Form1.Left
- End With
- With Line2
- .Y1 = p.Y * 15 - Form1.Top
- .Y2 = p.Y * 15 - Form1.Top
- End With
- With Line3
- .X1 = Line1.X1 + 465
- .X2 = Line1.X2 + 465
- End With
- With Line4
- .Y1 = Line2.Y1 + 470
- .Y2 = Line2.Y1 + 470
- End With
- ElseIf Option1(1).Value = True Then
- If Line3.Visible = True Then Line3.Visible = False
- If Line4.Visible = True Then Line4.Visible = False
- With Line1
- .X1 = p.X * 15 - Form1.Left + (465 / 2)
- .X2 = p.X * 15 - Form1.Left + (465 / 2)
- End With
- With Line2
- .Y1 = p.Y * 15 - Form1.Top + (470 / 2)
- .Y2 = p.Y * 15 - Form1.Top + (470 / 2)
- End With
- ElseIf Option1(2).Value = True Then
- If Line3.Visible = True Then Line3.Visible = False
- If Line4.Visible = True Then Line4.Visible = False
- With Line1
- .X1 = p.X * 15 - Form1.Left
- .X2 = p.X * 15 - Form1.Left
- End With
- With Line2
- .Y1 = p.Y * 15 - Form1.Top
- .Y2 = p.Y * 15 - Form1.Top
- End With
- ElseIf Option2(0).Value = True Then
- If Line3.Visible = False Then Line3.Visible = True
- If Line4.Visible = False Then Line4.Visible = True
- With Line1
- .X1 = p.X * 15 - Form1.Left
- .X2 = p.X * 15 - Form1.Left
- End With
- With Line2
- .Y1 = p.Y * 15 - Form1.Top
- .Y2 = p.Y * 15 - Form1.Top
- End With
- With Line3
- .X1 = Line1.X1 + 465
- .X2 = Line1.X2 + 465
- End With
- With Line4
- .Y1 = Line2.Y1 + 470
- .Y2 = Line2.Y1 + 470
- End With
- ElseIf Option2(1).Value = True Then
- If Line3.Visible = False Then Line3.Visible = True
- If Line4.Visible = False Then Line4.Visible = True
- With Line1
- .X1 = p.X * 15 - Form1.Left + (465 / 2)
- .X2 = p.X * 15 - Form1.Left + (465 / 2)
- End With
- With Line2
- .Y1 = p.Y * 15 - Form1.Top + (470 / 2)
- .Y2 = p.Y * 15 - Form1.Top + (470 / 2)
- End With
- With Line3
- .X1 = p.X * 15 - Form1.Left + (465 / 2)
- .X2 = p.X * 15 - Form1.Left + (465 / 2)
- End With
- With Line4
- .Y1 = p.Y * 15 - Form1.Top + (470 / 2)
- .Y2 = p.Y * 15 - Form1.Top + (470 / 2)
- End With
- ElseIf Option2(2).Value = True Then
- If Line3.Visible = True Then Line3.Visible = False
- If Line4.Visible = True Then Line4.Visible = False
- With Line1
- .X1 = p.X * 15 - Form1.Left
- .X2 = p.X * 15 - Form1.Left
- End With
- With Line2
- .Y1 = p.Y * 15 - Form1.Top
- .Y2 = p.Y * 15 - Form1.Top
- End With
- End If
- End Sub
- Private Sub Command1_Click()
- End
- End Sub
'A METRE DANS UN MODULE :
Option Explicit
Declare Function ClipCursor Lib "user32" (lpRect As RECT) As Long
Declare Function GetCursorPos Lib "user32" (lpPoint As POINT_TYPE) As Long
Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Type POINT_TYPE
X As Long
Y As Long
End Type
Public Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Public Declare Function OpenDriver Lib "winmm.dll" Alias "OpenDriverA" (ByVal DriverName As String) As Long
'A METRE DANS LA FORM
Option Explicit
Dim p As POINT_TYPE
Dim i As Variant
Dim OK As Boolean
Dim XX, YY As Long
Private Sub Form_Load()
'Positionement et configuration des objets
Me.Height = 6825
Me.Width = 8640
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2
Label1.AutoSize = True
Label1.Top = 0
Label1.Left = (Me.Width - Label1.Width) / 2
Label1.BackColor = vbWhite
Label1.ForeColor = vbRed
Option1(0).Caption = "Contours"
Option1(2).Caption = "Pointeur"
Option1(1).Caption = "Milieu"
For i = 0 To 2
Option1(i).Top = 240
Option2(i).Caption = Option1(i).Caption
Option2(i).Enabled = False
Option2(i).Top = 240
Next i
Option1(0).Left = 120
Option1(1).Left = 1080
Option1(2).Left = 1920
Option2(0).Left = 120
Option2(1).Left = 1200
Option2(2).Left = 2040
Timer1.Enabled = True
Timer1.Interval = 1
Frame1.Height = 1575
Frame1.Width = 3735
Frame1.Left = 4800
Frame1.Top = 5160
Frame1.Caption = "Options"
Frame2.Height = 615
Frame2.Width = 3495
Frame2.Left = 120
Frame2.Top = 480
Check1.Caption = "Bords"
Check1.Top = 0
Check1.Left = 120
Check2.Caption = "Lignes en pointiés"
Check2.Top = 1200
Check2.Left = 120
Command1.Caption = "x"
Command1.Left = 8400
Command1.Top = 0
Command1.Width = 135
Command1.Height = 135
End Sub
'!
'!Code de Deplacement d'une Form a partir d'un objet, par OverDarck
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
OK = True
XX = X
YY = Y
End Sub
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If OK = True Then
Call mov(X, Y, Button)
End If
End Sub
Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
OK = False
If Me.Top < 0 Then Me.Top = 0
If Me.Left < 0 Then Me.Left = 0
If Me.Top > Screen.Height - Me.Height Then Me.Top = Screen.Height - Me.Height
If Me.Left > Screen.Width - Me.Width Then Me.Left = Screen.Width - Me.Width
XX = 0
YY = 0
End Sub
Private Sub mov(X As Single, Y As Single, Button As Integer)
If Not Button = 1 Then Exit Sub
Form1.Move X + Form1.Left - XX, Y + Form1.Top - YY
End Sub
'!Fin du code
'!
Private Sub Check2_Click()
If Check2.Value = 0 Then
Line1.BorderStyle = 1
Line2.BorderStyle = 1
Line3.BorderStyle = 1
Line4.BorderStyle = 1
ElseIf Check2.Value = 1 Then
Line1.BorderStyle = 3
Line2.BorderStyle = 3
Line3.BorderStyle = 3
Line4.BorderStyle = 3
End If
End Sub
Private Sub Option1_Click(Index As Integer)
Timer1.Enabled = False
If Option1(Index).Value = True Then
Check1.Value = 0
For i = 0 To 2
Option2(i).Enabled = False
Next i
End If
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Select Case Check1.Value
Case 0
With Line1
.Y1 = -240
.Y2 = 7560
End With
With Line3
.Y1 = -240
.Y2 = 7560
End With
With Line2
.X1 = 0
.X2 = 12360
End With
With Line4
.X1 = 0
.X2 = 12360
End With
'!!
Case 1
'!!
With Line1
.Y1 = -7320
.Y2 = 480
End With
With Line3
.Y1 = 6600
.Y2 = 14400
End With
With Line2
.X1 = -12120
.X2 = 240
End With
With Line4
.X1 = 8400
.X2 = 20760
End With
For i = 0 To 2
Option1(i).Value = False
Option2(i).Enabled = True
Next i
End Select
'Position relative au deplacement du pointeur enregistre pas windob
GetCursorPos p
Label1.Caption = "Position X : " & p.X * 15 & " Y : " & p.Y * 15
If Option1(0).Value = True Then
If Line1.Visible = False Then Line1.Visible = True
If Line2.Visible = False Then Line2.Visible = True
If Line3.Visible = False Then Line3.Visible = True
If Line4.Visible = False Then Line4.Visible = True
With Line1
.X1 = p.X * 15 - Form1.Left
.X2 = p.X * 15 - Form1.Left
End With
With Line2
.Y1 = p.Y * 15 - Form1.Top
.Y2 = p.Y * 15 - Form1.Top
End With
With Line3
.X1 = Line1.X1 + 465
.X2 = Line1.X2 + 465
End With
With Line4
.Y1 = Line2.Y1 + 470
.Y2 = Line2.Y1 + 470
End With
ElseIf Option1(1).Value = True Then
If Line3.Visible = True Then Line3.Visible = False
If Line4.Visible = True Then Line4.Visible = False
With Line1
.X1 = p.X * 15 - Form1.Left + (465 / 2)
.X2 = p.X * 15 - Form1.Left + (465 / 2)
End With
With Line2
.Y1 = p.Y * 15 - Form1.Top + (470 / 2)
.Y2 = p.Y * 15 - Form1.Top + (470 / 2)
End With
ElseIf Option1(2).Value = True Then
If Line3.Visible = True Then Line3.Visible = False
If Line4.Visible = True Then Line4.Visible = False
With Line1
.X1 = p.X * 15 - Form1.Left
.X2 = p.X * 15 - Form1.Left
End With
With Line2
.Y1 = p.Y * 15 - Form1.Top
.Y2 = p.Y * 15 - Form1.Top
End With
ElseIf Option2(0).Value = True Then
If Line3.Visible = False Then Line3.Visible = True
If Line4.Visible = False Then Line4.Visible = True
With Line1
.X1 = p.X * 15 - Form1.Left
.X2 = p.X * 15 - Form1.Left
End With
With Line2
.Y1 = p.Y * 15 - Form1.Top
.Y2 = p.Y * 15 - Form1.Top
End With
With Line3
.X1 = Line1.X1 + 465
.X2 = Line1.X2 + 465
End With
With Line4
.Y1 = Line2.Y1 + 470
.Y2 = Line2.Y1 + 470
End With
ElseIf Option2(1).Value = True Then
If Line3.Visible = False Then Line3.Visible = True
If Line4.Visible = False Then Line4.Visible = True
With Line1
.X1 = p.X * 15 - Form1.Left + (465 / 2)
.X2 = p.X * 15 - Form1.Left + (465 / 2)
End With
With Line2
.Y1 = p.Y * 15 - Form1.Top + (470 / 2)
.Y2 = p.Y * 15 - Form1.Top + (470 / 2)
End With
With Line3
.X1 = p.X * 15 - Form1.Left + (465 / 2)
.X2 = p.X * 15 - Form1.Left + (465 / 2)
End With
With Line4
.Y1 = p.Y * 15 - Form1.Top + (470 / 2)
.Y2 = p.Y * 15 - Form1.Top + (470 / 2)
End With
ElseIf Option2(2).Value = True Then
If Line3.Visible = True Then Line3.Visible = False
If Line4.Visible = True Then Line4.Visible = False
With Line1
.X1 = p.X * 15 - Form1.Left
.X2 = p.X * 15 - Form1.Left
End With
With Line2
.Y1 = p.Y * 15 - Form1.Top
.Y2 = p.Y * 15 - Form1.Top
End With
End If
End Sub
Private Sub Command1_Click()
End
End Sub
Conclusion
Je tient a preciser que l'optention de la position du curseur se fait grace a un bout de code d'ulysse donc Merci a ThunderGun, et le reste de mon prog sert juste a interprter cette position.
Ptetre que certain veron cette source inutile mais je pense que sa servira a certain.
Bonne Prog A tous quand même @+
OverDarck
Fichier Zip
Pour les "Membres Club", vous pouvez télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !
Télécharger le zip
Sources du même auteur
Sources de la même categorie
Sources en rapport avec celle ci
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Simuler le CLICK de la souris [ par Gabriel ]
Comment simuler le click + dblclick dse souris?Mouse.ClickMouse.DblClickMERCI
mouse over [ par trastaroot ]
Salut,je vous explique mon pb! j'ai un histogramme dans excel et je voudrais au passage de la souris sur chaque barre de l'histogramme un commentaire
utilisation de SetCursorPos et Mouse_Event [ par nazzguhl ]
Bonjour,j'ai trouvé dans le forum plusieurs exemples de SetCursorPos et Mouse_Event, je les ai essayés, mais ça ne fonctionne pas comme je l'espérais.
move mouse to x y clic [ par simosif ]
bonjour,j'ai une application que je dois exécuter(suivre une séquence de clic sur des menus) toutes les 15 miniutes.je veux développer un programme qu
msflexgrid:Mouse Move [ par FASH ]
Bonjour à tous, Est-ce que quelqu'un aurait une idée pour mettre tout une ligne de la Msflexgrid en bleu quand le pointeur de la souris passe sur cett
Mouse move [ par Jocelynmorrissette ]
Je ne suis pas sur de comment utiliser la commande mouse move... Mon but est de faire bouger un objet a l'aide de la souris. Est-ce qu'il y a quelqu'u
UserControl et event Mouse [ par renocmoa ]
Bonsoir,Je voudrais savoir comment obtenir que les evenements souris (leav, hover...) soit utilisable avec un user control. En effet, par exemple avec
Simulation souris [ par didieraucun ]
Bonsoir et bonne année 2008 J'ai trouvé ce code sur ce site qui simule le mouvement et les différents clic d'une souris.Mais je ne sait pas comment l'
MOUSE EVENEMENT [ par GHGFSJD ]
Bonsoir, voila je possede un programme qui m'affiche un plugin en jouant un MP3, j'ai constaté que le plugin céssé de s'afficher si la souris cesser
Enregistrement et retranscription mouvements souris [ par pulpul74 ]
Bonjour.Je créé actuellement un programme qui me permet d'enregistrer les mouvement de la souris et de les retranscrire par la suite.Mais j'ai quelque
|
Téléchargements
Logiciels à télécharger sur le même thème :
|