le sujet n'est peut être pas le plus adéquat... mais là est le problème (je suppose).
J'ai un script qui choisi des fichier au hasard et enregistre le chiffre (random) dans un fichier .ini pour éviter qu'il n'apparaisse 2 fois. Or, la boucle continue même une fois que le fichier est choisi ce qui fait que je me retrouve avec des fichiers qui s'ouvrent toutes les 5 secondes...
► Afficher le texte
Code : Tout sélectionner
Global $str,$str1,$str2,$str3,$str4,$str5,$str6,$str7,$r,$c,$d,$s,$numbers = 6,$numbers1 = 1276,$numbers2 = 498,$numbers3 = 194,$numbers4 = 170,$numbers5 = 115,$numbers6 = 81,$numbers7 = 19,$bla,$bla1,$bla2,$bla3,$bla4,$bla5,$bla6,$bla7,$results
#include <GUIConstantsEx.au3>
If Not FileExists("bc34p.ini") Then
IniWrite("bc34p.ini", "section2", "key", "")
Else
$str = IniRead("bc34p.ini", "section2", "key", "default" )
EndIf
If Not FileExists("cc3314.ini") Then
IniWrite("cc3314.ini", "section2", "key", "")
Else
$str1 = IniRead("cc3314.ini", "section2", "key", "default" )
EndIf
If Not FileExists("cc3315.ini") Then
IniWrite("cc3315.ini", "section2", "key", "")
Else
$str2 = IniRead("cc3315.ini", "section2", "key", "default" )
EndIf
If Not FileExists("cc3316.ini") Then
IniWrite("cc3316.ini", "section2", "key", "")
Else
$str3 = IniRead("cc3316.ini", "section2", "key", "default" )
EndIf
If Not FileExists("cc3317.ini") Then
IniWrite("cc3317.ini", "section2", "key", "")
Else
$str4 = IniRead("cc3317.ini", "section2", "key", "default" )
EndIf
If Not FileExists("cc3318.ini") Then
IniWrite("cc3318.ini", "section2", "key", "")
Else
$str5 = IniRead("cc3318.ini", "section2", "key", "default" )
EndIf
If Not FileExists("cc3319.ini") Then
IniWrite("cc3319.ini", "section2", "key", "")
Else
$str6 = IniRead("cc3319.ini", "section2", "key", "default" )
EndIf
$bla = StringSplit($str,";;",1)
$bla1 = StringSplit($str1,";;",1)
$bla2 = StringSplit($str2,";;",1)
$bla3 = StringSplit($str3,";;",1)
$bla4 = StringSplit($str4,";;",1)
$bla5 = StringSplit($str5,";;",1)
$bla6 = StringSplit($str6,";;",1)
$bla7 = StringSplit($str7,";;",1)
$G_1 = GUICreate("random", 350, 130)
$B_1 = GUICtrlCreateButton("EtuLicPro", 10, 50, 100)
$B_2 = GUICtrlCreateButton("Reset", 10, 80, 100)
$B_3 = GUICtrlCreateButton("All Etu", 120, 50, 100)
$B_4 = GUICtrlCreateButton("Reset All Etu", 120, 80, 100)
$L_1 = GUICtrlCreateLabel("Randomizator :", 10, 10)
$L_2 = GUICtrlCreateLabel("NONE", 120, 10)
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ProcessClose("WinRAR.exe")
ExitLoop
Case $msg = $B_2
$6 = MsgBox(4,"RESET ?","Are you sure to reset pics file memory ?")
If $6 = 1276 Then
IniWrite("bc34p.ini", "section2", "key", "")
$str = IniRead("bc34p.ini", "section2", "key", "default" )
EndIf
;pour $B_1 cela fonctionne sans erreur
Case $msg = $B_1
$file = randomnum()
GUICtrlSetData($L_2,$file)
ShellExecute("E:\etu\etulicpro.rar")
Sleep(800)
Send("pass{ENTER}")
Sleep(2000)
For $i = 1 to StringReplace($file,";","")
Send("{down}")
Next
Send("{ENTER}")
Sleep(1000)
IniWrite("bc34p.ini", "section2", "key", $str)
$c = 0
If $bla[0] = $numbers1 Then
reset()
EndIf
;c'est là où ça se complique car le but est de choisir 1 fichier au hasard parmi 6 dossiers (choisis aussi au hasard) et c'est là où ça ne fonctionne pas "of course". c'est comme si la boucle continuait à tourner
Case $msg = $B_3
$results = Random(1,$numbers,1)
$file = randomnum2()
GUICtrlSetData($L_2,$results)
If $results = 1 Then
ShellExecute("E:\etu\L1.rar")
Sleep(800)
Send("pass{ENTER}")
Sleep(2000)
Send("{DOWN}{ENTER}")
Sleep(1500)
Send("{DOWN}{ENTER}")
EndIf
For $i = 1 to StringReplace($file,";","")
Send("{down}")
Next
Send("{ENTER}")
Sleep(1000)
IniWrite("cc3314.ini", "section2", "key", $str1)
$c = 0
If $bla1[0] = $numbers2 Then
reset()
EndIf
If $results = 2 Then
ShellExecute("E:\etu\L2.rar")
Sleep(800)
Send("pass{ENTER}")
Sleep(2000)
Send("{DOWN}{ENTER}")
Sleep(1500)
Send("{DOWN}{ENTER}")
EndIf
For $i = 1 to StringReplace($file,";","")
Send("{down}")
Next
Send("{ENTER}")
Sleep(1000)
IniWrite("cc3315.ini", "section2", "key", $str2)
$c = 0
If $bla2[0] = $numbers3 Then
reset()
EndIf
If $results = 3 Then
ShellExecute("E:\etu\L3.rar")
Sleep(800)
Send("pass{ENTER}")
Sleep(2000)
Send("{DOWN}{ENTER}")
EndIf
For $i = 1 to StringReplace($file,";","")
Send("{down}")
Next
Send("{ENTER}")
Sleep(1000)
IniWrite("cc3316.ini", "section2", "key", $str3)
$c = 0
If $bla3[0] = $numbers4 Then
reset()
EndIf
If $results = 4 Then
ShellExecute("E:\etu\M1r.rar")
Sleep(800)
Send("pass{ENTER}")
Sleep(2000)
EndIf
For $i = 1 to StringReplace($file,";","")
Send("{down}")
Next
Send("{ENTER}")
Sleep(1000)
IniWrite("cc3317.ini", "section2", "key", $str4)
$c = 0
If $bla4[0] = $numbers5 Then
reset()
EndIf
If $results = 5 Then
ShellExecute("E:\etu\M2r.rar")
Sleep(800)
Send("pass{ENTER}")
Sleep(2000)
EndIf
For $i = 1 to StringReplace($file,";","")
Send("{down}")
Next
Send("{ENTER}")
Sleep(1000)
IniWrite("cc3318.ini", "section2", "key", $str5)
$c = 0
If $bla5[0] = $numbers6 Then
reset()
EndIf
If $results = 6 Then
ShellExecute("E:\etu\M1p.rar")
Sleep(800)
Send("pass{ENTER}")
Sleep(2000)
EndIf
For $i = 1 to StringReplace($file,";","")
Send("{down}")
Next
Send("{ENTER}")
Sleep(1000)
IniWrite("cc3319.ini", "section2", "key", $str6)
$c = 0
If $bla6[0] = $numbers7 Then
reset()
EndIf
EndSelect
WEnd
Func randomnum()
While $c <> 1
$r = String(";"&Random(1,$numbers1,1)&";")
If Not StringInStr($str,$r,1) Then
$str = $str&$r
$bla = StringSplit($str,";;",1)
$c = 1
IniWrite("bc34p.ini", "section2", "key", $str)
Return $r
EndIf
WEnd
EndFunc
Func randomnum2()
If $results = 1 Then
While $c <> 1
$r = String(";"&Random(1,$numbers2,1)&";")
If Not StringInStr($str1,$r,1) Then
$str1 = $str1&$r
$bla1 = StringSplit($str1,";;",1)
$c = 1
IniWrite("cc3314.ini", "section2", "key", $str1)
Return $r
EndIf
WEnd
EndIf
If $results = 2 Then
While $c <> 1
$r = String(";"&Random(1,$numbers3,1)&";")
If Not StringInStr($str2,$r,1) Then
$str2 = $str2&$r
$bla2 = StringSplit($str2,";;",1)
$c = 1
IniWrite("cc3315.ini", "section2", "key", $str2)
Return $r
EndIf
WEnd
EndIf
If $results = 3 Then
While $c <> 1
$r = String(";"&Random(1,$numbers4,1)&";")
If Not StringInStr($str3,$r,1) Then
$str3 = $str3&$r
$bla3 = StringSplit($str3,";;",1)
$c = 1
IniWrite("cc3316.ini", "section2", "key", $str3)
Return $r
EndIf
WEnd
EndIf
If $results = 4 Then
While $c <> 1
$r = String(";"&Random(1,$numbers5,1)&";")
If Not StringInStr($str4,$r,1) Then
$str4 = $str4&$r
$bla4 = StringSplit($str4,";;",1)
$c = 1
IniWrite("cc3317.ini", "section2", "key", $str4)
Return $r
EndIf
WEnd
EndIf
If $results = 5 Then
While $c <> 1
$r = String(";"&Random(1,$numbers6,1)&";")
If Not StringInStr($str5,$r,1) Then
$str5 = $str5&$r
$bla5 = StringSplit($str5,";;",1)
$c = 1
IniWrite("cc3318.ini", "section2", "key", $str5)
Return $r
EndIf
WEnd
EndIf
If $results = 6 Then
While $c <> 1
$r = String(";"&Random(1,$numbers7,1)&";")
If Not StringInStr($str6,$r,1) Then
$str6 = $str6&$r
$bla6 = StringSplit($str6,";;",1)
$c = 1
IniWrite("cc3319.ini", "section2", "key", $str6)
Return $r
EndIf
WEnd
EndIf
EndFunc
Func reset()
If $bla1[0] >= $numbers1 Then
$6 = MsgBox(4,"THE END","RESET???")
If $6 = 1276 Then
IniWrite("bc34p.ini", "section2", "key", "")
$str1 = IniRead("bc34p.ini", "section2", "key", "default" )
Else
Exit
EndIf
EndIf
EndFunc



