
En gros le script sert à créer d'autre script

En gros vous lancez le script , vous entrez l'url de départ
Vous remplissez les formulaire , naviguer sur le site, coché des case , choisissez des options et quand vous avez terminé vous fermer la fenêtre et la un jolie code autoit apparais et il reproduit les actions que vous venez d'effectuer
En théorie le script gère les liens,les input,les boutons,les checkbox,les select,les zones de textes mais bon aucun site n'est semblable et il se peut qu'il ne fonctionne pas sur tout les sites
Donc j'aimerais connaître les sites où le script buggais pour l'adapter et avoir vos commentaires
Si il y a de l'intérêt je le continue

► Afficher le texteversion 2.0
Code : Tout sélectionner
;==================================================================
;################# Déclaration des Includes #######################
;==================================================================
#include <IE.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <ComboConstants.au3>
;==================================================================
;################## Déclaration des Options #######################
;==================================================================
OnAutoItExitRegister("OnExit")
Opt("GUIOnEventMode",1)
_IEErrorHandlerRegister()
$url = InputBox("autoIE", "Quel est l'url?", "", "", 120, 150)
;==================================================================
;################# Déclaration des variables ######################
;==================================================================
Global $ie_get_obj_by_value = False
Global $script = '#include <IE.au3>' & @CRLF & @CRLF
$script &= '$oIE = _IECreate ("' & $url & '")' & @CRLF & @CRLF
Global $oIE = _IECreateEmbedded()
;==================================================================
;#################### Création de la Gui #########################
;==================================================================
$form = GUICreate("", 400, 200, -1, -1, $WS_OVERLAPPEDWINDOW)
GUICtrlSetResizing($form, $GUI_DOCKAUTO + $GUI_DOCKBOTTOM + $GUI_DOCKTOP)
$GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 400, 200)
GUICtrlSetResizing($GUIActiveX, $GUI_DOCKAUTO + $GUI_DOCKBOTTOM + $GUI_DOCKTOP)
_IENavigate($oIE, $url)
GUISetState(@SW_SHOW)
GUISetState(@SW_MAXIMIZE)
;==================================================================
;################# Déclaration des Events #######################
;==================================================================
GUISetOnEvent($GUI_EVENT_CLOSE, "Onexit")
Obj_event()
;==================================================================
;######################## Boucle infini ###########################
;==================================================================
While 1
Sleep(1000)
WEnd
;==================================================================
;########## Fonctions de déclarations d'events ####################
;==================================================================
Func Obj_event()
ConsoleWrite("a" & @CRLF)
$oElements = _IETagNameAllGetCollection($oIE)
For $oElement in $oElements
$tag = ""
Switch String($oElement.tagname)
Case "input"
Switch String($oElement.type)
Case "submit"
$tag = "Submit"
Case "button"
$tag = "Submit"
Case "Checkbox"
$tag = "Checkbox"
case "radio"
$tag = "Checkbox"
Case "text"
$tag = "Text"
case "password"
$tag = "Text"
EndSwitch
Case "textarea"
$tag = "Text"
Case "A"
$tag = "Link"
Case "Select"
$tag = "Select"
EndSwitch
If $tag <> "" Then ObjEvent($oElement, $tag & "_")
Next
EndFunc ;Obj_event
;==================================================================
;##################### Fonctions d'events #########################
;==================================================================
Func Select_OnChange()
$obj = @COM_EventObj
if String($obj.id) <> "0" and string($obj.id) <> "" Then
$check_name = string($obj.id)
$var_name = "Id"
ElseIf String($obj.name) <> "0" and string($obj.name) <> "" Then
$check_name = string($obj.name)
$var_name = "Name"
Else
Return
EndIf
$script &= '$Select_' & $var_name & ' = _IEGetObjById($oIE, "' & String($obj.id) & '")' & @CRLF
$script &= '$Select_' & $var_name & '.selectedindex = ' & number($obj.selectedIndex) & @CRLF
EndFunc
Func Link_OnFocus()
$obj = @COM_EventObj
$url = String($obj.href)
$script &= '_IENavigate ($oIE, "' & $url & '")' & @CRLF & @CRLF
_IENavigate($oIE, $url)
Obj_event()
EndFunc ;Link_onclick
Func Checkbox_Onclick()
$obj = @COM_EventObj
if String($obj.id) <> "0" and string($obj.id) <> "" Then
$check_name = string($obj.id)
$var_name = "Id"
ElseIf String($obj.name) <> "0" and string($obj.name) <> "" Then
$check_name = string($obj.name)
$var_name = "Name"
Else
Return
EndIf
$script &= '$check_' & $var_name & ' = _IEGetObjBy' & $var_name & '($oIE, "' & $check_name & '")' & @CRLF
If string($obj.type) = "Radio" Then
$checked = False
Else
$checked = $obj.checked
EndIf
If $checked Then
$script &= '$check_' & $var_name & '.checked = True' & @CRLF
ElseIf Not $checked Then
$script &= '$check_' & $var_name & '.checked = False' & @CRLF
EndIf
EndFunc ; checkbox
Func Text_Onblur()
$obj = @COM_EventObj
$text = String($obj.value)
if String($obj.id) <> "0" and string($obj.id) <> "" Then
$input_name = string($obj.id)
$var_name = "Id"
ElseIf String($obj.name) <> "0" and string($obj.name) <> "" Then
$input_name = string($obj.name)
$var_name = "Name"
Else
Return
EndIf
$script &= '$Input_' & $var_name & ' = _IEGetObjBy' & $var_name & '($oIE, "' & $input_name & '")' & @CRLF
$script &= '_IEFormElementSetValue($Input_' & $var_name & ', "' & $text & '")' & @CRLF
EndFunc ;text_onblur
Func Submit_Onclick()
$obj = @COM_EventObj
If String($obj.id) <> "0" and String($obj.id) <> "" Then
$submit_name = String($obj.id)
$var_name = "Id"
ElseIf String($obj.name) <> "0" and String($obj.name) <> "" Then
$submit_name = String($obj.name)
$var_name = "Name"
ElseIf String($obj.value) <> "0" and String($obj.value) <> "" Then
$submit_name = String($obj.value)
$var_name = "Value"
$ie_get_obj_by_value = True
Else
Return
EndIf
$script &= '$submit_' & $var_name &' = _IEGetObjBy' & $var_name & '($oIE, "' & $submit_name & '")' & @CRLF
$script &= '_IEAction($submit_' & $var_name & ', "Click")' & @CRLF & @CRLF
EndFunc ;submit_onclick
;==================================================================
;###################### Fonction de Fin ###########################
;==================================================================
Func OnExit()
OnAutoItExitUnregister("OnExit")
GUIDelete()
Opt("GUIOnEventMode",0)
If $ie_get_obj_by_value Then
$script &= 'Func _IeGetObjByValue($oIE, $value)' & @CRLF
$script &= ' $oElements = _IETagNameGetCollection($oIE, "INPUT")' & @CRLF
$script &= ' For $oElement in $oElements' & @CRLF
$script &= ' If string($oElement.value) = $value Then _' & @CRLF
$script &= ' Return $oElement' & @CRLF
$script &= ' Next' & @CRLF
$script &= 'EndFunc ;~ IeGetObjByValue' & @CRLF
EndIf
$Form2 = GUICreate("Code", 612, 436)
$Edit1 = GUICtrlCreateEdit("", 0, 0, 609, 409, BitOR($GUI_SS_DEFAULT_EDIT, $ES_READONLY))
GUICtrlSetData(-1, $script)
$Button1 = GUICtrlCreateButton("Copier", 0, 416, 611, 17)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $Button1
ClipPut($script)
Exit
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
EndFunc ;==>OnExit
► Afficher le texteversion 1.0
Code : Tout sélectionner
#include <IE.au3>
#Include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <ComboConstants.au3>
OnAutoItExitRegister("OnExit")
$ie_get_obj_by_value = False
$url = InputBox("autoIE", "Quel est l'url?","","",120,150)
Global $script = '#include <IE.au3>' & @CRLF & @CRLF
$script &= '$oIE = _IECreate ("' & $url & '")' & @CRLF & @CRLF
$oIE = _IECreateEmbedded ()
#Region ### START Koda GUI section ### Form=
$form = GUICreate("", 400, 200,-1,-1,$WS_OVERLAPPEDWINDOW)
GUICtrlSetResizing($Form, $GUI_DOCKAUTO + $GUI_DOCKBOTTOM + $GUI_DOCKTOP)
$GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 400, 200)
GUICtrlSetResizing($GUIActiveX, $GUI_DOCKAUTO + $GUI_DOCKBOTTOM + $GUI_DOCKTOP)
$MenuItem1 = GUICtrlCreateMenu("Menu")
$MenuItem2 = GUICtrlCreateMenuItem("Aide - F1", $MenuItem1)
$MenuItem3 = GUICtrlCreateMenuItem("Changer de site - F2", $MenuItem1)
$MenuItem4 = GUICtrlCreateMenuItem("Quitter - Esc", $MenuItem1)
GUICtrlSetState($MenuItem1,$GUI_DISABLE)
#EndRegion ### END Koda GUI section ###
_IENavigate($oIE, $url)
GUISetState(@SW_SHOW)
GUISetState(@SW_MAXIMIZE)
_readonly($oIE)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
If _IsPressed("01") And WinActive($form) Then
_onclick($oIE)
EndIf
WEnd
Func _readonly($oIE)
$inputs = _IETagNameGetCollection($oIE,"Input")
For $input in $inputs
If String($input.type) = "text" or "password" or "textarea" Then _
$input.readonly = True
Next
Send("{tab}")
EndFunc ; readonly
Func _onclick($oIE)
$active = $oIE.document.activeElement
Switch String($active.tagname)
Case "select"
_Select($active)
Case "a"
_link($oIE,$active)
Case "input" and StringInStr($active.outerhtml,"Type=submit")
_submit($active)
Case "input" and StringInStr($active.outerhtml,"Type=CheckBox") or StringInStr($active.outerhtml,"Type=Radio")
_checkbox($active)
Case "input"
If StringInStr($active.outerhtml,"Type=Password") Then
$mdp = "*"
Else
$mdp = ""
EndIf
If not string($active.value) Then
$text = string($active.value)
Else
$text = ""
EndIf
$text = InputBox("AutoIE", "Quel texte voulez-vous mettre?", $text, $mdp, 120,150)
If not @error Then _text($active,$text)
Case "textarea"
If not string($active.value) Then
$text = string($active.value)
Else
$text = ""
EndIf
$Form3 = GUICreate("Code", 612, 436)
$Edit1 = GUICtrlCreateEdit("", 0, 0, 609, 409)
GUICtrlSetData(-1, $text)
$Button2 = GUICtrlCreateButton("Confirmer", 0, 416, 611, 17)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $Button2
$text = GUICtrlRead($Edit1)
_text($active, $text)
GUIDelete()
Return
Case $GUI_EVENT_CLOSE
GUIDelete()
Return
EndSwitch
WEnd
EndSwitch
Do
Sleep(100)
Until not _IsPressed("01")
EndFunc ; On click
Func _text($active,$text)
$input_name = string($active.name)
$script &= '$Input_name = _IEGetObjByName($oIE, "' & $input_name & '")' & @CRLF
$script &= '_IEFormElementSetValue($Input_name, "' & $text & '")' & @CRLF
_IEFormElementSetValue($active, $text)
EndFunc ;text
Func _checkbox($active)
$check_name = $active.name
$script &= '$check_name = _IEGetObjByName($oIE, "' & $check_name & '")' & @CRLF
if StringInStr($active.outerhtml,"Type=Radio") Then
$checked = False
Else
$checked = $active.checked
EndIf
If $checked Then
$script &= '$check_name.checked = false' & @CRLF
ElseIf not $checked Then
$script &= '$check_name.checked = true' & @CRLF
EndIf
EndFunc ;checkbox
Func _submit($active)
$ie_get_obj_by_value = True
$submit_name = string($active.value)
$script &= '$submit_name = _IEGetObjByValue($oIE, "' & $submit_name & '")' & @CRLF
$script &= '_IEAction($submit_name, "Click")' & @CRLF & @CRLF
$submit_name = $active
_IEAction($submit_name, "Click")
EndFunc ;submit
Func _link($oIE,$active)
$url = String($active.href)
$script &= '_IENavigate ($oIE, "' & $url & '")' & @CRLF & @CRLF
_IENavigate($oIE, $url)
_readonly($oIE)
EndFunc ;link
Func _Select($active)
dim $Combo[1][2] = [[0,""]]
For $option In $active.options
$Combo[0][0] += 1
ReDim $Combo[$Combo[0][0]+1][2]
$Combo[$Combo[0][0]][0] = String($option.innertext)
$Combo[$Combo[0][0]][1] = String($option.index)
$Combo[0][1] &= "|" & String($option.innertext)
Next
$Form2 = GUICreate("", 221, 27)
$Combo1 = GUICtrlCreateCombo("", 0, 2, 145, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1,$Combo[0][1],$Combo[1][0])
$Button2 = GUICtrlCreateButton("Confirmer", 144, 0, 75, 25)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $Button2
$compare = GUICtrlRead($Combo1)
For $i=1 to $Combo[0][0]
If $compare = $Combo[$i][0] Then
$active.selectedIndex = Number($Combo[$i][1])
$script &= '$Select_id = _IEGetObjById($oIE, "' & String($active.id) & '")' & @CRLF
$script &= '$Select_id.selectedindex = ' & Number($Combo[$i][1]) & @CRLF
GUIDelete()
Return
EndIf
Next
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
EndFunc ;select
Func OnExit()
If $ie_get_obj_by_value Then
$script &= 'Func _IeGetObjByValue($oIE, $value)' & @CRLF
$script &= ' $oElements = _IETagNameGetCollection($oIE, "INPUT")' & @CRLF
$script &= ' For $oElement in $oElements' & @CRLF
$script &= ' If string($oElement.value) = $value Then _' & @CRLF
$script &= ' Return $oElement' & @CRLF
$script &= ' Next' & @CRLF
$script &= 'EndFunc ;~ IeGetObjByValue' & @CRLF
EndIf
GUIDelete()
$Form2 = GUICreate("Code", 612, 436)
$Edit1 = GUICtrlCreateEdit("", 0, 0, 609, 409, BitOR($GUI_SS_DEFAULT_EDIT,$ES_READONLY))
GUICtrlSetData(-1, $script)
$Button1 = GUICtrlCreateButton("Copier", 0, 416, 611, 17)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $Button1
ClipPut($script)
Exit
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
EndFunc ; Onexit