Code : Tout sélectionner
#NoTrayIcon ; Include
#include <File.au3>
#include <ImageSearch.au3>
; -------------------------------------------------------
;Déclaration de variable
Global $vtimer, $Verif1, $Verif0, $Verif2 ; Fonction de debuguage du scripte
;Initialisation du script
$vtimer = TimerInit()
$Verif1 = -1
$Verif0 = 0
AdlibEnable("verif",1000)
; -------------------------------------------------------
$x1 = 0 ; Détéction des images
$y1 = 0
; -------------------------------------------------------
HotKeySet("{F2}", "My_Exit") ; Début de la fonction de fermeutur du script, touche F2
; -------------------------------------------------------
If FileExists($path) Then FileDelete($path) ; Netoyage des parametres
FileWrite($path,$Partie)
; -------------------------------------------------------
ShellExecute(@ProgramFilesDir & "\xxx_aplication.exe") ; Démarage de xxx aplication
WinWait("xxx_aplication")
WinSetState ("xxx_aplication", "", @SW_MAXIMIZE)
; --------------------------------------------------------
For $result = 1 To 999999 Step 1 ; Page 1
$result = _ImageSearch("page1.bmp", 0, $x1, $y1, 0)
If $result = 1 Then
_MouseClick("left", 300, 360)
send("phrase ecrite")
send("{ENTER}")
ExitLoop 1 ; On sort de la boucle
EndIf
Next
$Verif0 = 1
; ---------------------------------------------------------
For $result = 1 To 999999 Step 1 ; Page 2
$result = _ImageSearch("page2.bmp", 0, $x1, $y1, 0)
If $result = 1 Then
_MouseClick("left", 200, 400)
ExitLoop 1 ; On sort de la boucle
EndIf
Next
$Verif0 = 2
; ----------------------------------------------------------
For $result = 1 To 999999 Step 1 ; Page 3
$result = _ImageSearch("page3.bmp", 0, $x1, $y1, 0)
If $result = 1 Then
_MouseClick("left", 200, 450)
ExitLoop 1 ; On sort de la boucle
EndIf
Next
$Verif0 = 3
; -------------------------------------------------------
While 1 ; Debut de la boucle infini du scripte
; ------------------------------------------------------
If $Partie = 0 Or $Partie = 1 Then ; Patie 1
$Verif0 = 4
For $result = 1 To 999999 Step 1
$result = _ImageSearch("1.bmp", 0, $x1, $y1, 0)
If $result = 1 Then
_MouseClick("left", 545, 580)
ExitLoop 1 ; On sort de la boucle
EndIf
Next
If $Partie = 0 Or $Partie = 1 Then
EndIf
; ------------------------------------------------------
If $Partie = 0 Or $Partie = 2 Then ; Partie 2
$Verif0 = 5
For $result = 1 To 999999 Step 1
$result = _ImageSearch("2.bmp", 0, $x1, $y1, 0)
If $result = 1 Then
_MouseClick("left", 745, 578)
ExitLoop 1 ; On sort de la boucle
EndIf
Next
If $Partie = 0 Or $Partie = 2 Then
EndIf
; ----------------------------------------------------
If $Partie = 0 Or $Partie = 3 Then ; Partie 3
$Verif0 = 6
For $result = 1 To 999999 Step 1
$result = _ImageSearch("3.bmp", 0, $x1, $y1, 0)
If $result = 1 Then
_MouseClick("left", 60, 330)
ExitLoop 1 ; On sort de la boucle
EndIf
Next
If $Partie = 0 Or $Partie = 3 Then
EndIf
; ----------------------------------------------------
If $Partie = 0 Or $Partie = 4 Then ; Partie 4
$Verif0 = 7
For $result = 1 To 999999 Step 1
$result = _ImageSearch("4.bmp", 0, $x1, $y1, 0)
If $result = 1 Then
_MouseClick("left", 615, 578)
ExitLoop 1 ; On sort de la boucle
EndIf
Next
If $Partie = 0 Or $Partie = 4 Then
EndIf
; ----------------------------------------------------
WEnd ; Fin de la boucle infini du scripte.
; ----------------------------------------------------
Func My_Exit() ; Fin de la fonction de fermetur du script
Exit 0
EndFunc ;==>My_Exit
; ---------------------------------------------------
Func _MouseClick($Moc_buton,$Moc_x,$Moc_y,$Moc_clicks = 1,$Moc_speed = 0) ; Débugage des faux clique
For $Moc_i = 1 To $Moc_clicks
MouseMove($Moc_x,$Moc_y,$Moc_speed)
While MouseGetPos(0) <> $Moc_x And MouseGetPos(1) <> $Moc_y
Sleep(1)
MouseMove($Moc_x,$Moc_y,$Moc_speed)
WEnd
MouseDown($Moc_buton)
MouseDown($Moc_buton)
Sleep(1)
MouseDown($Moc_buton)
Sleep(1)
MouseUp($Moc_buton)
MouseUp($Moc_buton)
Sleep(1)
MouseUp($Moc_buton)
Next
EndFunc
; -------------------------------------------------
Func verif() ; Antit bug du script et procede au débugage du scripte
$Verif2 = $Verif0
If $Verif2 = $Verif1 then
If TimerDiff($vtimer) > 60000 then ; temps de la verif
WinClose("[REGEXPTITLE: xxx_Aplication]", "")
Sleep(10000)
$Verif2 = $Verif0
If Not @Compiled Then
ShellExecute(@AutoItExe, @ScriptFullPath & " " & $Verif0)
Else
ShellExecute(@ScriptFullPath, $Verif0)
EndIf
Exit
EndIf
Else
$vtimer = TimerInit()
$Verif1 = $Verif0
EndIf
EndFunc ;==>verif
; -------------------------------------------------
Func OnAutoItExit() ; Fonction du fichier log.
If @ExitCode = 4 then
If FileExists($path) Then FileDelete($path)
FileWrite($path,$Partie)
EndIf
Exit
EndFunc ;==>OnAutoItExit