[EX] Auto_connect Wolrd of Warcraft
Posté : ven. 28 mars 2008 23:03
par Git
Tout d'abord bonjour à tous !
voici mon petit code (clickeur) pour se connecter a wow, il évite de clické sur le boutton "ok" et de retaper son login, rien d'extraordinaire mais sur certain serveur l'opération peut se répéter énormément de fois..
Je met la source en ligne pour plusieurs raisons:
- le code fait appel au fichier "ini" sa pourait aider certaine personne
- aussi je voudrait avoir un peu d'aide pour réduire la taille du code ( ya beaucoup pour se que c'est je trouve..
)
PS: c'est mon premier code AutoIt, je voudrais avoir vos avis..
voici mon petit code (clickeur) pour se connecter a wow, il évite de clické sur le boutton "ok" et de retaper son login, rien d'extraordinaire mais sur certain serveur l'opération peut se répéter énormément de fois..
Je met la source en ligne pour plusieurs raisons:
- le code fait appel au fichier "ini" sa pourait aider certaine personne
- aussi je voudrait avoir un peu d'aide pour réduire la taille du code ( ya beaucoup pour se que c'est je trouve..

PS: c'est mon premier code AutoIt, je voudrais avoir vos avis..
► Afficher le texte
Code : Tout sélectionner
hotkeyset("{ESC}", "Quit") ; Press "Echap" pour quitter
Global $Identifiant, $Mdp, $Redcolor, $Calibrage, $Pause
Global $WoW_Xresol, $WoW_Yresol
Global $Xresol, $Yresol
Global $variance
Global $colorok = $Redcolor
Global $stepok = 1
Global $leftok, $topok, $rightok, $bottomok
Global $leftoL, $topoL, $rightoL, $bottomoL
Global $leftini, $topini
Global $Xresol = @DesktopWidth
Global $Yresol = @DesktopHeight
Global $Dir_ini = @ScriptDir &"\rss"
Global $Val1, $Val2, $Val3, $Val4, $Val5, $Val6
Global $Profils
Const $My_Xresol= 1024
Const $My_Yresol= 768
Const $crd_leftok= 630
Const $crd_topok= 400
Const $crd_rightok= 655
Const $crd_bottomok= 405
Const $crd_leftini = 635
Const $crd_topini = 450
Const $crd_leftoL= 570
Const $crd_topoL= 710
Const $crd_rightoL = 590
Const $crd_bottomoL= 720
Const $coloroL = $Redcolor
Const $stepoL = 1
Dim $coord_ok, $result_coordx_ok, $result_coordy_ok
Dim $coord_oL
Dim $Online
#include <array.au3>
#include <GUIConstants.au3>
#Region ### START Koda GUI section ###
$Form1 = GUICreate("Auto connect - v1.0a", 450, 178, 209, 170)
$Group1 = GUICtrlCreateGroup(" Profil : ", 8, 16, 201, 153)
$Label1 = GUICtrlCreateLabel("Identifiant :", 16, 32, 56, 17)
$Label2 = GUICtrlCreateLabel("Mot de passe :", 16, 72, 74, 17)
$Input1 = GUICtrlCreateInput("", 16, 48, 177, 21)
$Input2 = GUICtrlCreateInput("", 16, 88, 177, 21)
$Button2 = GUICtrlCreateButton("Sauvegarder", 112, 136, 81, 25, 0)
$Combo1 = GUICtrlCreateCombo("", 80, 24, 113, 25)
$Button5 = GUICtrlCreateButton("Charger", 16, 136, 89, 25, 0)
$Checkbox1 = GUICtrlCreateCheckbox("Charger ce Profil au démarage", 16, 112, 177, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup(" Réglage : ", 216, 16, 225, 113)
$Label3 = GUICtrlCreateLabel("Couleur Boutton :", 224, 40, 86, 17)
$Input3 = GUICtrlCreateInput("58000", 320, 40, 73, 21)
$Label4 = GUICtrlCreateLabel("Sensibilitée de detection :", 224, 72, 125, 17)
$Combo3 = GUICtrlCreateCombo("", 352, 72, 49, 25)
GUICtrlSetData(-1, "10|20|30|40|50|60|70|80|90|100", "10")
$Label5 = GUICtrlCreateLabel("%", 408, 72, 17, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Label6 = GUICtrlCreateLabel("Temps de chargement :", 224, 104, 116, 17)
$Combo4 = GUICtrlCreateCombo("", 352, 104, 49, 25)
GUICtrlSetData(-1, "5|10|15|20|25|30|35|40|45|50|55|60", "10")
$Label8 = GUICtrlCreateLabel("sec", 408, 104, 24, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label9 = GUICtrlCreateLabel("Hex", 400, 40, 26, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button3 = GUICtrlCreateButton("Quitter", 224, 136, 73, 33, 0)
$Button4 = GUICtrlCreateButton("Lancer Wow", 312, 136, 121, 33, 0)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label7 = GUICtrlCreateLabel("Edited by: Git - tous droit reserves", 8, 0, 198, 17)
GUICtrlSetFont(-1, 6, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xC0C0C0)
$Button1 = GUICtrlCreateButton("Defaut", 368, 0, 73, 17, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
If Not FileExists($Dir_ini &"\" &"sav.ini") Then
DirCreate($Dir_ini)
IniWrite($Dir_ini &"\" &"sav.ini", "Load", "Autoload", "none")
Else
$Val1 = IniRead($Dir_ini &"\" &"sav.ini", "Load", "Autoload", "NotFound")
If $Val1 <> "none" Then
$Val2 = IniRead($Dir_ini &"\" &$Val1 &".ini", $Val1, "Login", "NotFound")
$Val3 = IniRead($Dir_ini &"\" &$Val1 &".ini", $Val1, "Mot de passe", "NotFound")
$Val4 = IniRead($Dir_ini &"\" &$Val1 &".ini", $Val1, "Couleur", "NotFound")
$Val5 = IniRead($Dir_ini &"\" &$Val1 &".ini", $Val1, "Sensibilitée", "NotFound")
$Val6 = IniRead($Dir_ini &"\" &$Val1 &".ini", $Val1, "Pause", "NotFound") /1000
sleep(100)
GUICtrlSetData ($Input1,$Val2)
GUICtrlSetData ($Input2,$Val3)
GUICtrlSetData ($Input3,$Val4)
GUICtrlSetData ($Combo3, "10|20|30|40|50|60|70|80|90|100", $Val5)
GUICtrlSetData ($Combo4, "5|10|15|20|25|30|35|40|45|50|55|60", $Val6)
GUICtrlSetState($Checkbox1,$gui_checked)
EndIf
$tmp = ""
$Profils = IniReadSection($Dir_ini &"\" &"sav.ini","Profils")
For $i = 1 To $Profils[0][0]
GUICtrlSetData ($Combo1,$Profils[$i][0],$Profils[$i][0])
Next
EndIf
While 1 ; Interface
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
SplashTextOn("", "Fermeture du script en cours, Veuillez patienter ...", 450, 70, -1, -1, 0 + 1 + 16 + 32, "Times New Roman", 12, 800)
Exit
Case $Button1
GUICtrlSetData ($Input1,"")
GUICtrlSetData ($Input2,"")
GUICtrlSetData ($Input3,"58000")
GUICtrlSetData ($Combo3, "10|20|30|40|50|60|70|80|90|100", "10")
GUICtrlSetData ($Combo4, "5|10|15|20|25|30|35|40|45|50|55|60", "10")
Case $Button2
$Identifiant = GUICtrlRead($Input1)
$Mdp = GUICtrlRead($Input2)
$Redcolor = GUICtrlRead($Input3)
$variance = GUICtrlRead($Combo3,1)
$Pause = GUICtrlRead($Combo4,1) *1000
If BitAND(GUICtrlRead($Checkbox1),$gui_checked) Then
IniWrite($Dir_ini &"\" &"sav.ini", "Load", "Autoload", $Identifiant)
IniWrite($Dir_ini &"\" &"sav.ini", "Profils", $Identifiant, $Identifiant)
IniWrite($Dir_ini &"\" &$Identifiant &".ini", $Identifiant, "Login", $Identifiant)
IniWrite($Dir_ini &"\" &$Identifiant &".ini", $Identifiant, "Mot de passe", $Mdp)
IniWrite($Dir_ini &"\" &$Identifiant &".ini", $Identifiant, "Couleur", $Redcolor)
IniWrite($Dir_ini &"\" &$Identifiant &".ini", $Identifiant, "Sensibilitée", $variance)
IniWrite($Dir_ini &"\" &$Identifiant &".ini", $Identifiant, "Pause", $Pause)
Else
IniWrite($Dir_ini &"\" &"sav.ini", "Load", "Autoload", "none")
IniWrite($Dir_ini &"\" &"sav.ini", "Profils", $Identifiant, $Identifiant)
IniWrite($Dir_ini &"\" &$Identifiant &".ini", $Identifiant, "Login", $Identifiant)
IniWrite($Dir_ini &"\" &$Identifiant &".ini", $Identifiant, "Mot de passe", $Mdp)
IniWrite($Dir_ini &"\" &$Identifiant &".ini", $Identifiant, "Couleur", $Redcolor)
IniWrite($Dir_ini &"\" &$Identifiant &".ini", $Identifiant, "Sensibilitée", $variance)
IniWrite($Dir_ini &"\" &$Identifiant &".ini", $Identifiant, "Pause", $Pause)
EndIf
MsgBox ("","Sauvegarde","le Profil " &" [" &$Identifiant &"] " &"a été sauvegarder avec succes !")
Case $Button3
SplashTextOn("", "Fermeture du script en cours, Veuillez patienter ...", 450, 70, -1, -1, 0 + 1 + 16 + 32, "Times New Roman", 12, 800)
Sleep(3000)
Quit ()
Case $Button4
$Identifiant = GUICtrlRead($Input1)
$Mdp = GUICtrlRead($Input2)
$Redcolor = GUICtrlRead($Input3)
$variance = GUICtrlRead($Combo3,1)
$Pause = GUICtrlRead($Combo4,1) *1000
sleep (200)
Start ()
Case $Button5
$Val1 = GUICtrlRead($Combo1,1)
$Val2 = IniRead($Dir_ini &"\" &$Val1 &".ini", $Val1, "Login", "NotFound")
$Val3 = IniRead($Dir_ini &"\" &$Val1 &".ini", $Val1, "Mot de passe", "NotFound")
$Val4 = IniRead($Dir_ini &"\" &$Val1 &".ini", $Val1, "Couleur", "NotFound")
$Val5 = IniRead($Dir_ini &"\" &$Val1 &".ini", $Val1, "Sensibilitée", "NotFound")
$Val6 = IniRead($Dir_ini &"\" &$Val1 &".ini", $Val1, "Pause", "NotFound") /1000
sleep(100)
GUICtrlSetData ($Input1,$Val2)
GUICtrlSetData ($Input2,$Val3)
GUICtrlSetData ($Input3,$Val4)
GUICtrlSetData ($Combo3, "10|20|30|40|50|60|70|80|90|100", $Val5)
GUICtrlSetData ($Combo4, "5|10|15|20|25|30|35|40|45|50|55|60", $Val6)
EndSwitch
WEnd
Func Calcul ()
sleep(200)
$coeffx=$My_Xresol/$Xresol
$coeffy=$My_Yresol/$Yresol
sleep(200)
$leftok = $crd_leftok/$coeffx
$topok = $crd_topok/$coeffy
$rightok = $crd_rightok/$coeffx
$bottomok = $crd_bottomok/$coeffy
$leftoL = $crd_leftoL/$coeffx
$topoL = $crd_topoL/$coeffy
$rightoL = $crd_rightoL/$coeffx
$bottomoL = $crd_bottomoL/$coeffy
$leftini = $crd_leftini/$coeffx
$topini = $crd_topini/$coeffy
sleep(100)
EndFunc
Func Start () ; Bot
Run ( "Wow.exe" ) ;Lance wow
WinWaitActive ( "World of Warcraft" ) ; Focus Fenetre Wow
sleep($Pause)
Login ()
MouseMove($leftini,$topini,1)
Online_search ()
While 1 ; core
If $Online = 0 Then
OK_search ()
Online_search ()
EndIf
If $Online = 1 Then
Quit ()
EndIf
WEnd
EndFunc
Func OK_search () ; cherche le boutton "OK" lors de l'echec
sleep(100)
Calcul ()
Do
sleep(100)
$coord_ok = PixelSearch ($leftok, $topok, $rightok, $bottomok, $colorok, $variance, $stepok)
if Not @error = 1 then
$result_coordx_ok = $coord_ok[0]
$result_coordy_ok = $coord_ok[1]
mouseclick("left", $result_coordx_ok, $result_coordy_ok, 1,1)
Sleep(100)
MouseMove($leftini,$topini,1)
Relogin ()
EndIf
Until (@error)
EndFunc
Func Online_search() ; cherche si connecté
sleep(100)
$coord_oL = PixelSearch ($leftoL, $topoL, $rightoL, $bottomoL, $coloroL, $variance, $stepoL)
if Not @error = 1 then
$Online = 1
Else
$Online = 0
EndIf
sleep(200)
EndFunc
Func Login () ; Login
sleep (2000)
send($Identifiant) ; Login
sleep(200)
send("{TAB}")
sleep(500)
send ($Mdp) ; Mot de passe
sleep(200)
send ("{ENTER}")
EndFunc
Func Relogin () ; Relogin
sleep(200)
send ($Mdp)
sleep(200)
send ("{ENTER}")
sleep (200)
EndFunc
Func Quit () ; Fin
Exit
EndFunc