Jump to content

Nothing happens after running my script


Recommended Posts

Hello :) ,

I've been experiencing some troubles since a few minutes. I have to develop an AutoIt script that first displays a GUI. It worked perfectly until, and I absolutely don't know why, nothing happens when I run my script. The GUI does not show up, whereas it should. Moreover, I checked that a process existed for my script in the Windows task manager. And in addition to this, I noticed that in the tray bar, a tray icon of my script noted it as "paused", I don't know if it has something to do with the bug I'm experiencing.

Could please help me finding the bug ? Thanks :)

 

Of course, here is my code :
 

; ##########
; INCLUSIONS
; ##########
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <FileConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <String.au3>
#include <TrayConstants.au3>
#include <WindowsConstants.au3>
#include "test_performance.au3"



; ##################
; PARAMETRES GLOBAUX
; ##################
Opt("SendKeyDownDelay",30) ; pas trop rapide pour éviter que des frappes soient perdues
Opt("WinTitleMatchMode", 3) ; noms des fenêtres correspondant exactement


; #################
; CODE DU PROGRAMME
; #################

#Region ### START Koda GUI section ### Form=d:\mes documents\jlslre\documents\scripts autoit\automatisation arcmap\gui.kxf
$LARGEUR_FENETRE = 400
$HAUTEUR_FENETRE = 354
$Fenetre = GUICreate("Tests de performance - ArcMap", $LARGEUR_FENETRE, $HAUTEUR_FENETRE, @DesktopWidth/2 - $HAUTEUR_FENETRE/2, @DesktopHeight/2 - $LARGEUR_FENETRE/2, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_TABSTOP))
$Demarrer = GUICtrlCreateButton("Démarrer", 295,310, 91, 33, $BS_DEFPUSHBUTTON)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Iterations = GUICtrlCreateGroup("Nombre de tests à effectuer", 88, 56, 201, 65)
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
$InputIterations = GUICtrlCreateInput("", 104, 80, 169, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER, $SS_RIGHT))
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Destination = GUICtrlCreateGroup("Destination du fichier de log", 10, 136, 380, 65)
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
$InputDestination = GUICtrlCreateInput("", 24, 160, 300, 24, $GUI_SS_DEFAULT_INPUT)
$BoutonSelectionDossier = GUICtrlCreateButton("", 340, 155, 33, 33, $BS_ICON)
GUICtrlSetImage(-1, "D:\Mes Documents\jlslre\Documents\scripts AutoIT\Automatisation ARCMAP\icones\dossier.ico", -1, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Titre = GUICtrlCreateLabel("Tests de performance pour ArcMap", 14, 14, 381, 35, $SS_CENTER)
GUICtrlSetFont($Titre, 18, 400, 0, "MS Sans Serif")
$MsgInfo = GUICtrlCreateLabel("Veuillez ne pas utiliser le clavier et la souris pendant l'exécution des tests afin d'assurer leur bon déroulement.", 10, 215, $LARGEUR_FENETRE-20, 80, $SS_CENTER)
GUICtrlSetFont($MsgInfo, 13, 400, 0, "MS Sans Serif")
#EndRegion ### END Koda GUI section ###


; Boucle évènementielle GUI
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg

        ; Fermeture de la fenêtre
        Case $GUI_EVENT_CLOSE
            Exit

        ; Ouverture explorateur de dossiers
        Case $BoutonSelectionDossier
            SelectionDossier()

        ; Bouton 'Démarrer'
        Case $Demarrer
           If CheckParametres() Then
              $NbIterations = Number(ControlGetText($Fenetre, "", "Edit1"))
              $DossierDestination = ControlGetText($Fenetre, "", "Edit2")
              DemarrerTests($NbIterations, $DossierDestination)
              ExitLoop
           EndIf

    EndSwitch
WEnd


Func CheckParametres()
   ; Vérifie la validité des paramètres
   ; Renvoie True si tout est OK; False sinon en affiant une MsgBox avec les erreurs

   ; Contenu de l'input des itérations
   $TexteIterations = ControlGetText("", "", $InputIterations)

   ; Contenu de l'input du dossier de destination
   $TexteDestination = ControlGetText("", "", $InputDestination)

   ; L'éventuel message d'erreur à afficher
   $MessageErreur = ""

   ; Champ 'itérations' vide
   If $TexteIterations = "" Then
      ; Info bulle
      $MessageErreur = "Vous devez saisir un nombre d'itérations." & @CRLF

   ; Valeur saisie <= 0
   ElseIf Number($TexteIterations) <= 0 Then
      $MessageErreur = "Le nombre d'itérations doit être au moins égal à 1." & @CRLF
   EndIf

   ; Champ 'destination' vide
   If $TexteDestination = "" Then
      $MessageErreur = $MessageErreur & "Vous devez choisir un dossier de destination."

   ; Dossier inexistant
   ElseIf Not FileExists($TexteDestination) Or (FileExists($TexteDestination) And Not StringInStr(FileGetAttrib($TexteDestination),"D")) Then
      $MessageErreur = $MessageErreur & "Le chemin du dossier de destination saisi est incorrect."
   EndIf

   ; Au moins 1 erreur
   If $MessageErreur <> "" Then
      MsgBox(BitOR($MB_OK, $MB_ICONERROR), "Paramètres incorrects", $MessageErreur)
      Return False
   Else
      Return True
   EndIf

EndFunc


Func SelectionDossier()
   ; Ouvre un explorateur pour sélectionner un dossier
   ; Si un dossier est choisi, met son chemin dans le champ de texte prévu
   ; Sinon, ne fait rien

   $dossier = FileSelectFolder("Sélectionnez un dossier de destination", @MyDocumentsDir)
   If @error <> 1 Then
      ControlSetText("", "", $InputDestination, $dossier)
   EndIf

EndFunc



Func DemarrerTests($NbTests, $DossierDest)
   ; Démarre la session de tests sur ArcMap
   ;
   ; Paramètres :
   ; NbTests     -- Le nombre de tests à réaliser
   ; DossierDest -- Le dossier de destination du fichier de log

   ; Le nom du fichier de log
   Local $nomFic = $dossierDest & "\tests_performance_arcmap_" & @MDAY & @MON & @YEAR & "_" & @HOUR & @MIN & @SEC & ".csv"

   ; Création et ouverture fichier de log en écriture
   Local $hFicLog = FileOpen($nomFic, $FO_OVERWRITE)

   ; La ligne en-tête du CSV
   $EnTeteCSV = "Session du " & @MDAY & "/" & @MON & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC
   For $i = 1 To 10
      ; Ajout d'1 colonne par tâche
      $EnTeteCSV = $EnTeteCSV & ";Tache " & $i
   Next

   ; Ecriture de l'en-tête dans le fichier
   FileWriteLine($hFicLog, $EnTeteCSV)

   ;FileWrite($hFicLog, "Session de test réalisée le " & @MDAY & "/" & @MON & "/" & @YEAR & " à " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF)

   ; Accord orthographique
   ;If $NbTests > 1 Then
    ;  FileWrite($hFicLog, $NbTests & " tests réalisés" & @CRLF)
   ;ElseIf $NbTests = 1 Then
    ;  FileWrite($hFicLog, "1 test réalisé" & @CRLF)
   ;EndIf

   ;FileWrite($hFicLog, _StringRepeat("=", 20) & @CRLF & @CRLF)


   For $i = 1 To $NbTests

      ; Info-bulle en bas à droite
      TrayTip("Exécution des tests de performance pour ArcMap en cours ...", "Test n° " & $i & "/" & $NbTests, 1000 & $i & "/" & $NbTests, $TIP_ICONASTERISK)

      ; On fait autant de tests que nécessaire
      Local $LigneTemps = FaireUnTest()

      ; On écrit une ligne avec le numéro de tests et les temps
      FileWriteLine($hFicLog, "Test " & $i & ";" & $LigneTemps)
      ;FileWrite($hFicLog, @CRLF & _StringRepeat("=", 20))
      ;FileWrite($hFicLog, "Fin du test numéro " & $i & @CRLF)
      ;FileWrite($hFicLog, _StringRepeat("=", 20) & @CRLF & @CRLF)

   Next

   ; Afficher un message à l'utilisateur à la fin des tests
   MsgBox(BitOR($MB_OK, $MB_ICONINFORMATION), "Exécution des tests terminée", "Les tests de performance pour ArcMap sont terminés. Les résultats sont visibles dans le fichier " & $nomFic)


EndFunc

Jules LARUE

Edited by Jules
Link to comment
Share on other sites

  • Moderators

Jules,

You are missing the GUISetState line which you need to show the GUI.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...