Page 1 sur 1

Problem avec un image en attente

Posté : lun. 25 avr. 2022 09:20
par YuChan
Bonjour a tous,

Je rencontre un petit soucis avec un code.
Le but du script est de détecter un fond noir

Voici mon code :

Code : Tout sélectionner

$bck =  waitForImage("IMG/blackscreen.png", 10)				

while True
	If $bck Then
		_journalMsg("IMAGE FOUND")
		MsgBox(0, '', $bck)
		ExitLoop 
		Else 
			MsgBox(0, "", "NOT FOUND")
			;ExitLoop 
	EndIf 

	ExitLoop 

WEnd 

Func waitForImage($imageFile, $waitSecs = 5)		
	Local $timeout = $waitSecs * 1000
	Local $startTime = TimerInit()
		
	;loop until image is found, or until wait time is exceeded
	While true 

		If _ImageSearch($imageFile, 1, 100) <> false Then
			Return true
		EndIf
		
		If $timeout > 0 And TimerDiff($startTime) >= $timeout Then
			ExitLoop
		EndIf
		sleep(50)	
	WEnd
	
	Return False
EndFunc

Mon probleme c'est a la première boucle il trouve mais pas dans un second passage de la boucle.

Pouvez vous m'aider SVP ?