Hystic
Messages postés10Date d'inscriptionvendredi 6 juin 2008StatutMembreDernière intervention 7 juin 2014
-
18 avril 2011 à 13:22
Hystic
Messages postés10Date d'inscriptionvendredi 6 juin 2008StatutMembreDernière intervention 7 juin 2014
-
18 avril 2011 à 17:53
Bonjour,
j'ai un petit problème ....
j'essaye de simuler un click souris via une macro excel et donc j'utilise ce petit bout de code trouvé sur un forum :
Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
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)
Public Const MOUSEEVENTF_MOVE = &H1
Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Public Const MOUSEEVENTF_RIGHTDOWN = &H8
Public Const MOUSEEVENTF_RIGHTUP = &H10
Public Const MOUSEEVENTF_MIDDLEDOWN = &H20
Public Const MOUSEEVENTF_MIDDLEUP = &H40
Public Const MOUSEEVENTF_ABSOLUTE = &H8000
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Public Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Public Type POINTAPI
x As Long
y As Long
End Type
Public dstX As Long
Public dstY As Long
Public Function GetX() As Long
Dim n As POINTAPI
GetCursorPos n
GetX = n.x
End Function
Public Function GetY() As Long
Dim n As POINTAPI
GetCursorPos n
GetY = n.y
End Function
Public Sub Clic(PosX As Integer, PosY As Integer)
'placer la souris par sécurité (pour processeurs lents)
Call SetCursorPos(PosX, PosY)
mouse_event MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_LEFTUP, PosX, PosY, 0, 0
End Sub
lorsque je fait ma fonction sur office 2007 en 32bits ça marche niquel...
En revanche lorsque je lance ma macro sur Office 2010 64 bits j'ai un beau petit message d'erreur .... du fait que je soit en 64 bits
cs_loulou69
Messages postés672Date d'inscriptionmercredi 22 janvier 2003StatutMembreDernière intervention 2 juin 20161 18 avril 2011 à 17:05
Bonjour
mouse_event est une instruction qui doit etre encore accessible en 32 bits tout du moins.
je pense qu'il faut déclarer correctement la fonction pour l'utiliser avec Office 64 bits ou utiliser une options de windows pour faire tourner Office 2010 64 bits comme s'il s'agissait d'une application 32 bits.
Toutefois l'accessibilité de Office depuis Office 2007 a changé , l'automation n'est normalement disponible qu'au tyravers de MSAA.