Jump to content

Script takes ages on startup


Recommended Posts

Hey everyone,

I have written a script which I want to start together with the booting operating system (Win7x64). Like proposed by wiki-FAQ (https://www.autoitscript.com/wiki/FAQ) I tried the following:
 

MsgBox(0,"TellMe",RegWrite("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "ATOSS-FavoritenManager", "REG_SZ", @ScriptFullPath)?"SUCCESS":"Error: " & @error)

It worked, just like putting a link into the windows autostart directory.

Thing is, every other program in there needs some seconds to start after booting. However, my script takes 3-5 minutes for no obvious reason, with the process visible in the task-manager. I tried a a smaller Autoit.exe script and it was way faster than mine.
My script is 1.1MB in size and needs 17.6MB of RAM when running. (maybe that's the problem?)

I set up a MsgBox at the start of my script to have something simple as first visible effect, so in my opinion it's nothing in my code causing the problem (like a loop).
My includes are:

#include-once
#include "Toast.au3"
#include <StructureConstants.au3>
#include <MsgBoxConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <FileConstants.au3>
#include <ListBoxConstants.au3>
#include <ButtonConstants.au3>
#include <Date.au3>
#include <GDIPlus.au3>
#include <ColorConstantS.au3>
#include <Misc.au3>
#include <ListViewConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <GuiToolbar.au3>
#include <GuiListBox.au3>
#include <Array.au3>
#include <Crypt.au3>
#include "_GuiListViewEx.au3"
#include "GUIHyperLink.au3"
#include "ATOSS-FavMan_start.au3" ;(my own)

That's quite some but I need those.

Any ideas? (Here is some code, that my script starts with. Altogether it's about 3500 lines of code.)
 

#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 6
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=FavManIcons\ATOSS-Fav-Man_32Black.ico
#AutoIt3Wrapper_Res_Fileversion=2.0.2.4
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_Language=1031
#AutoIt3Wrapper_Res_Icon_Add=D:\Programmierung\MyProjects\AutoIt\ATOSS_FavMan\FavManIcons\Help-ATOSS-FavMan_32Black.ico
#AutoIt3Wrapper_Res_Icon_Add=D:\Programmierung\MyProjects\AutoIt\ATOSS_FavMan\FavManIcons\Cancel.ico
#AutoIt3Wrapper_Res_Icon_Add=D:\Programmierung\MyProjects\AutoIt\ATOSS_FavMan\FavManIcons\PfeilObenBlue.ico
#AutoIt3Wrapper_Res_Icon_Add=D:\Programmierung\MyProjects\AutoIt\ATOSS_FavMan\FavManIcons\PfeilUntenBlue.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include-once


;Variablen Deklarierung erzwingen
Opt("MustDeclareVars", 1)
;Debugger
Opt("TrayIconDebug", 1)
;AutoItSetOption("GUIDataSeparatorChar" ,"###")

ConsoleWrite("Entered: FavoritenManager" & @CRLF)
MsgBox(0,"TellMe",RegWrite("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "ATOSS-FavoritenManager", "REG_SZ", @ScriptFullPath)?"SUCCESS":"Error: " & @error)

;Script kann nur einmal gleichzeitig ausgeführt werden
If _Singleton(@ScriptName, 1) = 0 Then
    WinActivate($GstrFavManName)
Else
;~  ;liest den arbeitsspeicher aus
;~  Local $x = 0
;~  Local $aMem  = MemGetStats()
;~  While($aMem[0] > 80)
;~      Sleep(1000)
;~      $x += 1
;~  WEnd
;~  MsgBox(0,"","Durchlaufen: " & $x)

    ;Die minimale Größe des FavMans
    Global Const $minSizeX = 820
    Global Const $minSizeY = 500

    If $GintGuiHeight < $minSizeY Then $GintGuiHeight = $minSizeY
    If $GintGuiWidth < $minSizeX Then $GintGuiWidth = $minSizeX
    ;Auf gespeicherte Einstellung Prüfen/Default-Einstellungen anlegen
    InitDialogVars()

    ;Array für alle Favoriten: Favoritenname, Aktion, Hauptprojekt, Projekt, Projektstatus, Bemerkung; Zeile 0 ist das 'Aktuelle Projekt'
    Global $GtstrFavFileCont[1][6] = [["", "", "", "", "", ""]]

    main()
EndIf


Func main()

    _log("ATOSS_FavMan start program************************************************")
    ;Favoritenverzeichnis erstellen
    DirCreate($GstrPathFavDir)

    Global $hGUIFavMan = GUICreate($GstrFavManName, $GintGuiWidth, $GintGuiHeight, -1, -1, $WS_SIZEBOX + $WS_CAPTION + $WS_SYSMENU + $WS_MINIMIZEBOX + $WS_MAXIMIZEBOX)

    Global $hFavListView = GUICtrlCreateListView("", 35, 10, $GintGuiWidth / 3, $GintGuiHeight - 40, BitOR($LVS_NOCOLUMNHEADER, $LVS_SHOWSELALWAYS, $WS_EX_CLIENTEDGE));, $LVS_LIST
    _GUICtrlListView_SetExtendedListViewStyle($hFavListView, BitOR($LVS_EX_INFOTIP, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES,$LVS_EX_DOUBLEBUFFER))
    GUICtrlSetBkColor($hFavListView, $GUI_BKCOLOR_LV_ALTERNATE)
    _GUICtrlListView_SetColumnWidth($hFavListView, 0, 0)

    Global $hPosUp      = GUICtrlCreateButton("Up", 2, 10, 24 + 6, 27+ 6, $BS_ICON)
    Global $hPosDown    = GUICtrlCreateButton("Dw", 2, 38+ 6, 24+ 6, 27+ 6, $BS_ICON)

    ;Button mit Images belegen (siehe Includes in Zeilen 1ff.)
    GUICtrlSetImage ($hPosUp, @ScriptFullPath,203) ; 203 ist laut "ResHacker.exe" (Resource Hacker) das Icon "PfeilOben.ico"
    GUICtrlSetImage ($hPosDown,@ScriptFullPath,204) ; 204 ist laut "ResHacker.exe" (Resource Hacker) das Icon "PfeilUnten.ico"

    Global $hBuchen     = GUICtrlCreateButton("Buchen", $GintGuiWidth / 3 + 50, 320, $GintGuiWidth * 2 / 3 - 60, 28)
    GUICtrlSetFont($hBuchen, Default, 800)
    Global $hCurProjLoad = GUICtrlCreateButton("Aktuelles Projekt", 50 + $GintGuiWidth / 3, $GintGuiHeight - 90, $GintGuiWidth * 2 / 3 - 60, 25)
    Global $hCurProjSet = GUICtrlCreateButton("Projekt 'Aktuell' Setzen", (50 + $GintGuiWidth / 3) + ($GintGuiWidth * 2 / 3 - 60) / 2, $GintGuiHeight - 60, ($GintGuiWidth * 2 / 3 - 60) / 2, 25)
    Global $hFavSpeichern = GUICtrlCreateButton("Favoriten speichern", (50 + $GintGuiWidth / 3), $GintGuiHeight - 60, ($GintGuiWidth * 2 / 3 - 60) / 2, 25)
    Global $menuDatei       = GUICtrlCreateMenu("&Datei")
    Global $menuBuchen      = GUICtrlCreateMenuItem("Buchen", $menuDatei)
    GUICtrlCreateMenuItem("", $menuDatei) ; separator
    Global $menuFavSpeichern = GUICtrlCreateMenuItem("Favoriten speichern", $menuDatei)
    Global $menuDelete      = GUICtrlCreateMenuItem("Favorit(en) Löschen" & @TAB & "[Strg + Entf]", $menuDatei)
    GUICtrlCreateMenuItem("", $menuDatei) ; separator
    Global $menuCurProjLoad = GUICtrlCreateMenuItem("Aktuelles Projekt", $menuDatei)
    Global $menuCurProjSet  = GUICtrlCreateMenuItem("Projekt 'Aktuell' setzen", $menuDatei)
    GUICtrlCreateMenuItem("", $menuDatei) ; separator
    Global $menuUpdate  = GUICtrlCreateMenuItem("Aktualisieren" & @TAB & "[F5]", $menuDatei)
    Global $menuExit    = GUICtrlCreateMenuItem("Beenden", $menuDatei)
    Global $menuExtras  = GUICtrlCreateMenu("&Extras")
    Global $menuOptions = GUICtrlCreateMenuItem("Optionen", $menuExtras)
    Global $menuHelp    = GUICtrlCreateMenuItem("Hilfe", $menuExtras)
    Global $menuSaveDir = GUICtrlCreateMenuItem("Speicherort öffnen", $menuExtras)
    Global $menuAbout   = GUICtrlCreateMenuItem("About", $menuExtras)


    Global $hContext = GUICtrlCreateContextMenu($hFavListView)
    Global $hContextFavSpeichern = GUICtrlCreateMenuItem("Favoriten speichern", $hContext)
    Global $hContextDelete      = GUICtrlCreateMenuItem("Favorit(en) Löschen" & @TAB & "[Strg + Entf]", $hContext)
    GUICtrlCreateMenuItem("", $menuDatei) ; separator
    Global $hContextCurProjLoad = GUICtrlCreateMenuItem("Aktuelles Projekt", $hContext)
    Global $hContextCurProjSet  = GUICtrlCreateMenuItem("Projekt 'Aktuell' setzen", $hContext)
    GUICtrlCreateMenuItem("", $hContext) ; separator
    Global $hContextUpdate      = GUICtrlCreateMenuItem("Aktualisieren" & @TAB & "[F5]", $hContext)
    Global $hContextExit        = GUICtrlCreateMenuItem("Beenden", $hContext)

    Global $hEditFavName = GUICtrlCreateInput("", $GintGuiWidth / 3 + 170, 30, 350, 20)
    Global $hEditFavNameLabel = GUICtrlCreateLabel("Favoritenname:", $GintGuiWidth / 3 + 50, 30, 100, 20)

    Global $hComboAktion = GUICtrlCreateCombo("", $GintGuiWidth / 3 + 170, 100, 350, 40, BitOR($CBS_DROPDOWNLIST, $CBS_DISABLENOSCROLL, $CBS_DROPDOWN, $CBS_AUTOHSCROLL, $WS_VSCROLL));,$CBS_SORT))
    Global $hComboAktionLabel = GUICtrlCreateLabel("Aktion:", $GintGuiWidth / 3 + 50, 100, 100, 20)

    Global $hComboHProjekt = GUICtrlCreateCombo("", $GintGuiWidth / 3 + 170, 140, 350, 40, BitOR($CBS_DROPDOWNLIST, $CBS_DISABLENOSCROLL, $CBS_DROPDOWN, $CBS_AUTOHSCROLL, $WS_VSCROLL));,$CBS_SORT))
    Global $hComboHProjektLabel = GUICtrlCreateLabel("Hauptprojekt:", $GintGuiWidth / 3 + 50, 140, 100, 20)

    Global $hComboProjekt = GUICtrlCreateCombo("", $GintGuiWidth / 3 + 170, 180, 350, 40, BitOR($CBS_DROPDOWNLIST, $CBS_DISABLENOSCROLL, $CBS_DROPDOWN, $CBS_AUTOHSCROLL, $WS_VSCROLL));,$CBS_AUTOHSCROLL));,$CBS_SORT))
    Global $hComboProjektLabel = GUICtrlCreateLabel("Projekt:", $GintGuiWidth / 3 + 50, 180, 100, 20)

    Global $hComboPStatus = GUICtrlCreateCombo("", $GintGuiWidth / 3 + 170, 220, 350, 40, BitOR($CBS_DROPDOWNLIST, $CBS_DISABLENOSCROLL, $CBS_DROPDOWN, $CBS_AUTOHSCROLL, $WS_VSCROLL));,$CBS_SORT))
    Global $hComboPStatusLabel = GUICtrlCreateLabel("Projektstatus:", $GintGuiWidth / 3 + 50, 220, 100, 20)

    Global $hEditBemerkung = GUICtrlCreateInput("", $GintGuiWidth / 3 + 170, 260, 350, 20, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL));,$CBS_SORT))
    Global $hEditBemerkungLabel = GUICtrlCreateLabel("Bemerkung:", $GintGuiWidth / 3 + 50, 260, 100, 20)

    ; Add columns zur ListView
    _GUICtrlListView_InsertColumn($hFavListView, 0, "Favoriten", $GintGuiWidth / 3)
    ;Spaltenbreite auf Maximum setzen

    ;Für die SelectionChange-Notification bei ListViews wird ein Dummy gebraucht (da nicht als Msg vorhanden)
    Global $hDummySelChange = GUICtrlCreateDummy()

    ;Die Hilfe wird deaktiviert, bis sie aktualisiert ist
    GUICtrlSetState($menuHelp, $GUI_DISABLE)
    
    ;Legt das Verhalten der Control-Elemente fest, wenn die Größe der GUI verändert wird
    GUICtrlSetResizing($hFavListView, $GUI_DOCKAUTO)
    GUICtrlSetResizing($hPosUp, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKSIZE)
    GUICtrlSetResizing($hPosDown, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKSIZE)
    GUICtrlSetResizing($hBuchen, $GUI_DOCKAUTO)
    GUICtrlSetResizing($hFavSpeichern, $GUI_DOCKAUTO)
    GUICtrlSetResizing($hCurProjLoad, $GUI_DOCKAUTO)
    GUICtrlSetResizing($hCurProjSet, $GUI_DOCKAUTO)
    GUICtrlSetResizing($hEditFavName, $GUI_DOCKAUTO)
    GUICtrlSetResizing($hComboAktion, $GUI_DOCKAUTO)
    GUICtrlSetResizing($hComboHProjekt, $GUI_DOCKAUTO)
    GUICtrlSetResizing($hComboProjekt, $GUI_DOCKAUTO)
    GUICtrlSetResizing($hComboPStatus, $GUI_DOCKAUTO)
    GUICtrlSetResizing($hEditBemerkung, $GUI_DOCKAUTO)
    GUICtrlSetResizing($hEditFavNameLabel, $GUI_DOCKAUTO)
    GUICtrlSetResizing($hComboAktionLabel, $GUI_DOCKAUTO)
    GUICtrlSetResizing($hComboHProjektLabel, $GUI_DOCKAUTO)
    GUICtrlSetResizing($hComboProjektLabel, $GUI_DOCKAUTO)
    GUICtrlSetResizing($hComboPStatusLabel, $GUI_DOCKAUTO)
    GUICtrlSetResizing($hEditBemerkungLabel, $GUI_DOCKAUTO)
    ;Default(Button) festlegen
    GUICtrlSetState($hFavListView, $GUI_FOCUS + $GUI_DEFBUTTON)
    GUISetBkColor($GhexBackgroundColor, $hGUIFavMan) ; Ändert die Hintergrundfarbe

    GUICtrlSetFont($hFavListView, $GintFONT, 550, -1, $GstrFontName)

    ;Message-Handler für Klicks und Funktionen bei LISTVIEW
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
    ;Window-Rezise-Handler
    GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")

    ;Window activation/deaktivation message handler
    GUIRegisterMsg($WM_ACTIVATEAPP, "WM_ACTIVATEAPP")
    Local $aAccelKeys[2][2] = [["^{Del}", $menuDelete], ["{F5}", $menuUpdate]]
    GUISetAccelerators($aAccelKeys)

    ;FavTerminal füllen
    FillGUIEditFav($hComboAktion, $hComboHProjekt, $hComboProjekt, $hComboPStatus)

    ;FavList füllen
    RefreshGUI()
    GUISetState(@SW_SHOW)

    ;Main-Program
    While 1
        ; We can only get messages from the first GUI
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $menuExit, $hContextExit ;, $hIdEXITFav
                Local $tintPositionSize = WinGetPos($hGUIFavMan)

                ;Aus bisher unbekannten Gründen wird das Fenster immer größer - hier wird ein Betrag wieder abgezogen, um diesen Effekt auszugleichen
                $GintGuiWidth = $tintPositionSize[2] - 16
                $GintGuiHeight = $tintPositionSize[3] - 38

                SaveSerial()

                GUIDelete($hGUIFavMan)
                ExitLoop

            Case $menuFavSpeichern, $hContextFavSpeichern, $hFavSpeichern

                ;Neuen Favoriten speichern
                DirCreate($GstrPathFavDir)

                ;Störende Funktionen für die Dauer des Speicherns deaktivieren
                EntrysDisable()
                SaveNewFav()
                EntrysEnable()

            Case $menuCurProjSet, $hCurProjSet, $hContextCurProjSet

                ;'Aktuelles Projekt' Favoriten anlegen
                DirCreate($GstrPathFavDir)
                SaveCurProj()

            Case $menuCurProjLoad, $hCurProjLoad, $hContextCurProjLoad

                ;'Aktuelles Projekt' in das FavMan-Terminal laden
                LoadCurProj()

            Case $menuBuchen, $hBuchen ;, $hContextBuchen
                _log("Case $menuBuchen, $hBuchen start")

                ;WENN höchstens 1 Favorit ausgewählt wurde UND das FavTerminal nicht leer ist, DANN buchen
                If 1 >= ControlListView($hGUIFavMan, "", $hFavListView, "GetSelectedCount") And CheckFavTermEntrys() Then
                    If LoadConstructList() Then
                        _log("Case $menuBuchen, $hBuchen end: success")
                    Else
                        _log("Case $menuBuchen, $hBuchen end: failure")
                    EndIf
                Else
                    _log("Case $menuBuchen, $hBuchen end: failure")
                EndIf

            Case $menuDelete, $hContextDelete ;, $hDelete
                DeleteFavorits()

            Case $menuUpdate, $hContextUpdate ;, $hUpdate
                RefreshGUI()

            Case $menuOptions ;, $hContextOptions ;, $hIdOptions
                GUISetState(@SW_HIDE, $hGUIFavMan)
                GUIGlobalOptions()

                GUISetState(@SW_SHOW, $hGUIFavMan)
                WinActive($hGUIFavMan)
                GUISwitch($hGUIFavMan)

            Case $menuSaveDir
                ShellExecute($GstrPathFavMan)

            Case $menuAbout
                ;Infos über FavMan anzeigen
                GUIAbout()

                GUISetState(@SW_SHOW, $hGUIFavMan)
                WinActive($hGUIFavMan)
                GUISwitch($hGUIFavMan)

            ;Für SelectionChange Notification bei ListView
            Case $hDummySelChange
                _log("Case $hDummySelChange start")
                Local $nGetSelDummy

                If 1 = ControlListView($hGUIFavMan, "", $hFavListView, "GetSelectedCount") Then
                    
                    $nGetSelDummy = ControlListView($hGUIFavMan, "", $hFavListView, "GetSelected")
                
                        If $nGetSelDummy == ControlListView($hGUIFavMan, "", $hFavListView, "GetSelected") Then
                            EntrysEnable()
                            Local $strGetSel
                            $strGetSel = ControlListView($hGUIFavMan, "", $hFavListView, "GetText", $nGetSelDummy)
                            ControlSetText($hGUIFavMan, "", $hEditFavName, $strGetSel)
                            LoadFav()
                        EndIf

                Else
                    EntrysDisable()
                    ClearFavTerm()
                EndIf
            
                _log("Case $hDummySelChange end")

            Case $hPosUp
                ChangeItemPos(True)

            Case $hPosDown
                ChangeItemPos(False)

            Case $hComboHProjekt
                ConsoleWrite("Case: $hComboHProjekt" & @CRLF)
                If Not $GbFavLaden Then
                    
                    Local $nGetSelHProjekt

                    $nGetSelHProjekt = ControlListView($hGUIFavMan, "", $hFavListView, "GetSelected")

                    ;Auslesen verzögern, um schnell aufeinanderfolgende Selektion zu ignorieren
                    Sleep(300 + $GintSleeper)

                    If $nGetSelHProjekt == ControlListView($hGUIFavMan, "", $hFavListView, "GetSelected") Then
                        ;Wenn ein Eintrag in 'Projekt' vorhanden war, dann wird versucht, ihn wieder zu schreiben
                        Local $strTempProjekt = ""
                        Local $strHauptprojekt = ""
                        Local $intSelHProjekt = 0

                        $strTempProjekt = GUICtrlRead($hComboProjekt)

                        If Not $GstrOldHProj == $strHauptprojekt Then
                        $strHauptprojekt = GUICtrlRead($hComboHProjekt)

                            GUICtrlSetData($hComboProjekt, "", 0)

                            $intSelHProjekt = ControlCommand($hGUIFavMan, "", $hComboHProjekt, "FindString", $strHauptprojekt)
                            GUICtrlSetData($hComboProjekt, $GstrtProjekt[$intSelHProjekt], 0)
                            Sleep($GintSleeper)
                            If $strTempProjekt Then
                                ControlCommand($hGUIFavMan, "", $hComboProjekt, "SelectString", $strTempProjekt)
                                $GstrOldHProj = $strTempProjekt
                            EndIf
                        EndIf
                        ;Eintrag bei Hauptprojekt in das ATOSS-Terminal übernehmen
                        ;FillTerminalHProjekt($strHauptprojekt)
                    EndIf
                Else
                    ;ConsoleWrite("Nicht" & @CRLF & @CRLF)
                    $GbFavLaden = False
                EndIf
                ;Die Daten werden erst bei "Buchen" übernommen
                
        EndSwitch

    WEnd

    ;Delete the previous GUI and all controls.
    GUIDelete($hGUIFavMan)

EndFunc   ;==>main

;Inhalte des FavMan aktivieren
Func EntrysEnable()
    ;Buchen
    GUICtrlSetState($menuBuchen, $GUI_ENABLE)
    GUICtrlSetState($hBuchen, $GUI_ENABLE)
EndFunc   ;==>EntrysEnable

;Inhalte des FavMan deaktivieren
Func EntrysDisable()
    ;Buchen
    GUICtrlSetState($menuBuchen, $GUI_DISABLE)
    GUICtrlSetState($hBuchen, $GUI_DISABLE)
EndFunc   ;==>EntrysDisable

;Message Handler für ListView
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iCode, $tNMHDR, $hWndListView
    $hWndListView = $hFavListView
    If Not IsHWnd($hFavListView) Then $hWndListView = GUICtrlGetHandle($hFavListView)

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                
                Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
                    _log("Case $NM_CLICK start")
                    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    Local $Index = DllStructGetData($tInfo, "Index")
                    
                    ;Timer, der schnelles Klicken abfängt
                    $GdCountClickTimer = TimerDiff($GhBeginClickTimer)

                    ; make sure user clicks on the listview & only the activate
                    If $Index <> -1 Then

                        $GnLineSel = $Index
                        Local $strFavName = _GUICtrlListView_GetItemTextString($hFavListView, $Index)


                        ;Lässt nur nach 500ms oder bei der Auswahl eines neuen Favs den Klick zu
                        If $GstrSelTxt <> $strFavName Or $GdCountClickTimer > 500 Then
                            _log("Click: '" & $strFavName & "'")
                            $GstrSelTxt = $strFavName
                            GUICtrlSendToDummy($hDummySelChange)

                            $GhBeginClickTimer = TimerInit()
                            $GdCountClickTimer = 0

                        EndIf
                    EndIf

                    _log("Case $NM_CLICK end")

            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

;Überprüft Minimum und Maximum der Fenstergröße und setzt die Größen wenn nötig
Func WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam)
    Local $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
    DllStructSetData($minmaxinfo, 7, $minSizeX) ; min X
    DllStructSetData($minmaxinfo, 8, $minSizeY) ; min Y

    ;Stellt die Größe der Spalte automatisch auf die Größe des ListView, bzw. des größten EIntrags
    ColumnSizeSet()

    Return "GUI_RUNDEFMSG"
EndFunc   ;==>WM_GETMINMAXINFO

Thanks and have a great weekend!
Natulux

Edited by Natulux
Link to comment
Share on other sites

Is there anything in "ATOSS-FavMan_start.au3" that might be causing it?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Hey KingBob, thanks for your reply.

That's basically good thinking. "ATOSS-FavMan_start.au3" provides the starting routine for another program, which is needed for my script.
But I checked with a ConsoleWrite command at the very beginning of every file which of them comes first. At least in Debug mode the first file is the one I posted the code of and it's the one I start with a MsgBox to check on my .exe when it starts.

You see, the problem is that I can't even tell the user, that the program is beeing loaded. Noone waits several minutes for a tool to load without getting feedback about it's action of doing so. I thought of writing a smaller scipt which informs the user and handles the starting of the real script...

I might add, that this problem only occurs right after booting the system. At any other given time it starts within a sec.
So I was guessing, maybe I include something, that windows is loading at the end of the booting process?

Have a nice weekend
Natulux
 

Link to comment
Share on other sites

Your main script will start first, but then it loads all the include files in the order that you included them. So if there is anything inside an include that delays the start up of the whole script you have to check for that. Depending on where you place your consolewrites/msgboxes, that will tell you where it's being delayed.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Hey you two,

KingBob: In that case you might be right. I think I could comment it out to see, if it still has a major delay (in which case I'm forced to accept it).
I'll try that in time.

BetaLeaf: As said above: "I might add, that this problem only occurs right after booting the system. At any other given time it starts within a sec."
So I fear I am unable to debug my script in the console. For that case I started the logging file, in which I couldn't track the problem yet.

Thank you and have a nice day
Natulux

EDIT: I tried to comment out the "ATOSS-FavMan_start.au3" but that didn't cause the problem. It still needs about 3 minutes to start, after every other program has been loaded, no more processes in the task manager changed for these 3 minutes with a cpu usage of 10% and RAM of about 20%. I can't really figure out, why the pc is waiting, because the resources seem available...

EDIT2: I just had another idea. Maybe the computer isn't waiting to fulfill the process, maybe it just needs that long to start it (because it has to load to much data in the RAM or something like that)? However, that wouldn't explain, why the pc is repeatedly able to start my software right away after maybe 5 minutes.

Edited by Natulux
Link to comment
Share on other sites

I am just making an opinion that i wouldnt recommend too much .exe files during startup but i would recommend to run  a batch script during startup as it does not take up much time to load you have many command line options available if you want to run a .exe file scripted in autoit then you should add your program to the local policy editor as the scripts in the policy editor will start first with windows explorer

No matter whatever the challenge maybe control on the outcome its on you its always have been.

MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition)

Link to comment
Share on other sites

Hey Surya, thanks for your reply!

I have to admit that I'm not familiar with the 'local policy editor'. I gave it a look and found it quite huge. Can I even 'add' a '.bat' somewhere here without disturbing the other scripts? If these are going to be sensitive changes, my admin is not going to let me use that for starting a script of mine. ;-)

Cheers,
Natulux
 

Link to comment
Share on other sites

Natulux then you should remove large programs that cause load during startup

you can get the list of startup program in task manager and disable them or entering wmic startup into the command prompt

that would increase your system boot up speed

No matter whatever the challenge maybe control on the outcome its on you its always have been.

MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition)

Link to comment
Share on other sites

Hello again.

I just added a 'start.bat' for my script in the local policy editor and rebooted. Indeed, my script now starts right in time as I would like it. I would like to use your suggestion, but eventually I am going to have to give my tool to others and therefor need to automatically make this entry. Is it possible via batch or similar to edit the policy editor?

Thanks!
Natulux

EDIT: I might try using autoit again to accomplish this I guess. ;-)

Edited by Natulux
Link to comment
Share on other sites

Hey Surya,

that is indeed the batch I wrote, which at the moment does nothing else but start my exe script. I don't need that batch personaly, if the exe can be loaded in time.

@echo off

start "" "E:\FavMan_AktuellesRelease\ATOSS-FavoritenManager.exe"

exit

Greetings
Natulux

Link to comment
Share on other sites

okay natulux try this function i have written i have included the exe file not the .bat file:

#RequireAdmin
#include <Array.au3>
#include <String.au3>

Local Const $GOP_SHUTDOWN = False
Local Const $GOP_STARTUP = True
;the first parameter defines to start the script when in startup or shutdown
;second parameter is the file and third is its parameters
;------------

_RegisterGOP($GOP_SHUTDOWN,"E:\FavMan_AktuellesRelease\ATOSS-FavoritenManager.exe")


Func _RegisterGOP($varx,$file,$param = "") 
$fini = "C:\Windows\System32\GroupPolicy\Machine\Scripts\scripts.ini"
If FileExists($fini) Then
If $varx = $GOP_STARTUP Then
$ini = IniReadSection($fini,"Startup")
If @error Then
   Local $ini[1][1]
   $ini[0][0] = -1
EndIf
ElseIf $varx = $GOP_SHUTDOWN Then
$ini = IniReadSection($fini,"Shutdown")
If @error Then
   Local $ini[1][1]
   $ini[0][0] = -1
EndIf
EndIf
$last = UBound($ini)-1
$num = _StringBetween ($ini[$last][0],"","P")
If @error Then Local $num[1] = [-1]
$num = $num[0] + 1
MsgBox ("","",$num)
If $varx = $GOP_STARTUP Then
IniWrite($fini,"Startup",$num &"CmdLine",$file)
IniWrite($fini,"Startup",$num &"Parameters",$param)
ElseIf $varx = $GOP_SHUTDOWN Then
IniWrite($fini,"Shutdown",$num &"CmdLine",$file)
IniWrite($fini,"Shutdown",$num &"Parameters",$param)
EndIf
Else
If $varx = $GOP_STARTUP Then
IniWrite($fini,"Startup","0CmdLine",$file)
IniWrite($fini,"Startup","0Parameters",$param)
ElseIf $varx = $GOP_SHUTDOWN Then
IniWrite($fini,"Shutdown","0CmdLine",$file)
IniWrite($fini,"Shutdown","0Parameters",$param)
EndIf
EndIf
Return "Sucess"
endfunc

I am sorry to keep you waiting but the code works great if you have any doubts or want any more help feel free to ask glad i could help

Edited by Surya

No matter whatever the challenge maybe control on the outcome its on you its always have been.

MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition)

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

×
×
  • Create New...