Re: [Ex] Retrouver la ligne d'erreur d'un script compilé
Posté : mer. 23 mars 2016 22:31
Merci Yle pour ta collaboration, problème résolu
Voilà le code définitif
Voilà le code définitif
Code : Tout sélectionner
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
Global Const $__LISTVIEWCONSTANT_WM_SETREDRAW = 0x000B
Opt("GUIDataSeparatorChar", ChrW(9617))
$gui = GUICreate("test", 520, 360, -1, 150)
$listview = GUICtrlCreateListView("Lignes", 10, 50, 500, 300)
GUICtrlSetFont($listview, 8.5, 0, 0, "Tahoma")
GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 0, 480)
GuiCtrlCreateLabel("Ligne à chercher :", 20, 17, 100, 20)
$Input = GUICtrlCreateInput("", 110, 15, 40, 20)
$Vazi = GUICtrlCreateButton("Charger le script", 180, 15, 120, 20)
GUISetState(@SW_SHOW)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $Vazi
$n = GuiCtrlRead($Input)
; If $n = "" Then ContinueLoop
$au3 = FileOpenDialog("Sélectionner le script à analyser", @scriptdir, "Scripts (*.au3)", 0, "", $gui)
If @error Then ContinueLoop
$Au3Stripper = _SetAu3Stripper(@tempdir)
If @error Then Exit Msgbox(48, "error", "Impossible de charger Au3Stripper")
RunWait('"' & $Au3Stripper & '" "' & $au3 & '" /mergeonly', "", @SW_HIDE)
$stripped = StringTrimRight($au3, 4) & "_stripped" & ".au3"
$stripped_txt = StringRegExpReplace(FileRead($stripped), '(?m)^\s*#(pragma|include).*\R', "")
$lines = StringSplit($stripped_txt, @crlf, 1)
GuiCtrlSendMsg($listview, $LVM_DELETEALLITEMS, 0, 0)
If $n > $lines[0] Then
GUICtrlCreateListViewItem("Le fichier complet n'a que " & $lines[0] & " lignes", $listview)
ContinueLoop
EndIf
GuiCtrlSendMsg($listview, $__LISTVIEWCONSTANT_WM_SETREDRAW, False, 0)
For $i = 1 to $lines[0]
GUICtrlCreateListViewItem($i & " : " & $lines[$i], $listview)
If $i = $n Then GuiCtrlSetColor(-1, 0xdd0000)
Next
GuiCtrlSendMsg($listview, $__LISTVIEWCONSTANT_WM_SETREDRAW, True, 0)
Local $tPoint = DllStructCreate("long X;long Y")
GUICtrlSendMsg($listview, $LVM_GETITEMPOSITION, $n-6, DllStructGetPtr($tPoint))
GUICtrlSendMsg($listview, $LVM_SCROLL, DllStructGetData($tPoint, "X"), DllStructGetData($tPoint, "Y"))
EndSwitch
WEnd
Func _SetAu3Stripper($path)
Local $exe = $path & "\Au3Stripper.exe" ; v. 16.306.1237.1
If not FileExists($exe) Then
GUICtrlCreateListViewItem("Chargement de Au3Stripper ...", $listview)
;; Local $url = "https://www.autoitscript.com/autoit3/scite/download/beta_SciTE4AutoIt3/Au3Stripper.exe"
Local $url = "http://affz.free.fr/Au3Stripper/Au3Stripper.exe"
InetGet($url, $exe)
If @error Then Return SetError(1, 0, 0)
_DatFile($path)
EndIf
Return $exe
EndFunc
Func _DatFile($path)
Local $datfile = $path & "\Au3Stripper.dat"
If not FileExists($datfile) Then
Local $data = "Functionname,Parameter to check,0=check for function/1=check for Variable;adlibenable,1,0;" & _
"adlibregister,1,0;adlibunregister,1,0;call,1,0;dllcallbackregister,1,0;eval,1,1;guictrlregisterlistviewsort,2,0;" & _
"guictrlsetonevent,2,0;guiregistermsg,2,0;guisetonevent,2,0;hotkeyset,2,0;isdeclared,1,1;objevent,2,0;" & _
"onautoitexitregister,1,0;onautoitexitunregister,1,0;opt,2,0;traysetonevent,2,0;trayitemsetonevent,2,0;"
FileWrite($datfile, StringReplace($data, ";", @crlf))
EndIf
EndFunc