Curseur

Résolu
jnbrunet Messages postés 258 Date d'inscription samedi 25 décembre 2004 Statut Membre Dernière intervention 13 novembre 2012 - 9 févr. 2005 à 00:27
Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 - 9 févr. 2005 à 01:45
Comment puis-je faire pour que lorsque je pars mon programme, ma souris se place a tel positon et que apres une pause de 1 secconde, il se place a tel position et tous sa meme si la form est cacher derriere une autre fenetre...

Jn

5 réponses

Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 34
9 févr. 2005 à 01:06
Option Explicit


Private Type POINTAPI
x As Long
y As Long
End Type


Dim xx As Long
Dim yy As Long


Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)


Private Sub Command1_Click()
Dim P As POINTAPI
Dim Z As POINTAPI

GetCursorPos Z

xx = 0
yy = 0
P.x = ScaleX(xx, vbTwips, vbPixels)
P.y = ScaleY(yy, vbTwips, vbPixels)
ClientToScreen& Me.hwnd, P
SetCursorPos P.x, P.y
Sleep 1000

xx = Me.ScaleWidth - 15
yy = 0
P.x = ScaleX(xx, vbTwips, vbPixels)
P.y = ScaleY(yy, vbTwips, vbPixels)
ClientToScreen& Me.hwnd, P
SetCursorPos P.x, P.y
Sleep 1000

xx = Me.ScaleWidth - 15
yy = Me.ScaleHeight - 15
P.x = ScaleX(xx, vbTwips, vbPixels)
P.y = ScaleY(yy, vbTwips, vbPixels)
ClientToScreen& Me.hwnd, P
SetCursorPos P.x, P.y
Sleep 1000

xx = 0
yy = Me.ScaleHeight - 15
P.x = ScaleX(xx, vbTwips, vbPixels)
P.y = ScaleY(yy, vbTwips, vbPixels)
ClientToScreen& Me.hwnd, P
SetCursorPos P.x, P.y
Sleep 1000

xx = 0
yy = 0
P.x = ScaleX(xx, vbTwips, vbPixels)
P.y = ScaleY(yy, vbTwips, vbPixels)
ClientToScreen& Me.hwnd, P
SetCursorPos P.x, P.y
Sleep 1000

SetCursorPos Z.x, Z.y

End Sub

Daniel
3
Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 34
9 févr. 2005 à 01:19
Pour le simuler le Click de la souris:

Const MOUSEEVENTF_LEFTDOWN = &H2
Const MOUSEEVENTF_LEFTUP = &H4
Const MOUSEEVENTF_MIDDLEDOWN = &H20
Const MOUSEEVENTF_MIDDLEUP = &H40
Const MOUSEEVENTF_MOVE = &H1
Const MOUSEEVENTF_ABSOLUTE = &H8000
Const MOUSEEVENTF_RIGHTDOWN = &H8
Const MOUSEEVENTF_RIGHTUP = &H10

Private Declare 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)

mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0&, 0&, 0&, 0&
DoEvents

Daniel
3
jnbrunet Messages postés 258 Date d'inscription samedi 25 décembre 2004 Statut Membre Dernière intervention 13 novembre 2012
9 févr. 2005 à 00:57
Hmm..une toute petite chose...juste avant la pause, je veux que le programme execute un click gauche et apres le 2ieme déplacement, un click droit, si possible. Merci pour vos réponses.
0
jnbrunet Messages postés 258 Date d'inscription samedi 25 décembre 2004 Statut Membre Dernière intervention 13 novembre 2012
9 févr. 2005 à 01:17
Super sa marche à merveille! Mais es-tu capable de réponde à ma 2eme question, si tu le veux biensur.. sa me serais très utile..

Jn
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 34
9 févr. 2005 à 01:45
si tu veux détecter une inactivité pendant un temps déterminé, ici une minute dans l'exemple, il faut mettre un Timer.

Private Sub Timer1_Timer()
Static Tp As Date
Static X1 As POINTAPI
Dim X2 As POINTAPI

GetCursorPos X2
If X2.x <> X1.x Or X2.y <> X1.y Then
Tp = Now
X1 = X2
End If
If DateDiff("s", Tp, Now) > 60 Then
Tp = Now
' déclencher une action
End If
End Sub

Daniel
0
Rejoignez-nous