[VBS] Librairie VBExcel exportable vers vbs ?

Fermé
rikki - 5 févr. 2008 à 13:55
 rikki - 5 févr. 2008 à 19:34
Bonjour a toos et a toutes..

Voila , j'utilise dans excel une librairie qui me permet de faire bouger ma souris et cliquer.
Cela marche tres bien :-)

Aujourdhui je souhaite savoir si je peux exporter ce script vers un fichier vbs et le lancer sous cscript.exe ??



Quand je le fais il me marque une erreur
C:\test2.vbs(1, 17) Erreur de compilation Microsoft VBScript: Fin d'instruction attendue

je ne sais pas si on peut appeler une librairie dans vbs..
Je vous fournis mon script, mon but est de lancer Sub PositionneEtClick()

Voila le script qui permet de faire bouger la souris et cliquer dans une macro excel :

-------------------------------------------------------------------------------

Private Declare Function SetCursorPos Lib "user32" ( _
ByVal x As Long, ByVal y As Long) As Long

' ' '
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, _
ByVal dX As Long, _
ByVal dY As Long, _
ByVal dwData As Long, _
ByVal dwExtraInfo As Long)
Private Declare Sub Sleep Lib "kernel32" _
(ByVal dwMilliseconds As Long)
Private Const MOUSEEVENTF_ABSOLUTE = &H8000& ' absolute move
Private Const MOUSEEVENTF_LEFTDOWN = &H2 ' left button down
Private Const MOUSEEVENTF_LEFTUP = &H4 ' left button up
Private Const MOUSEEVENTF_MIDDLEDOWN = &H20 ' middle button down
Private Const MOUSEEVENTF_MIDDLEUP = &H40 ' middle button up
Private Const MOUSEEVENTF_MOVE = &H1 ' mouse move
Private Const MOUSEEVENTF_RIGHTDOWN = &H8 ' right button down
Private Const MOUSEEVENTF_RIGHTUP = &H10 ' right button up
Private Const MOUSEEVENTF_WHEEL = &H800 ' wheel button rolled
' ' '
Public Sub leftClick()
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub
' ' ' '
Sub PositionneEtClick()
Dim x As Long, y As Long
x = 967
y = 17
Call SetCursorPos(x, y)
Call leftClick
End Sub

--------------------------------------------------------------------------

Merci pour votre aide !
A voir également:

1 réponse

Une petite aide Sil vous plait ??
Merci !
0