Natulux

Script takes ages on startup

31 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
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
 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

In SciTE, Click on Tools> Trace: Add Trace Lines. Run the script in SciTE with the trace lines and watch the console log and see where it is lagging at. When you are done debugging, click on Tools> Trace: Remove ALL Trace Lines. 


False Positive Reporter - Mass email all anti virus vendors with an attachment of your program for fast and easy whitelisting.

PortableApps.com App Creation Wizard  - A simple GUI-based Wizard for creating PortableApps.

SoundBoard - Play any song or sound you want at the press of a hotkey.

My GitHub Page: https://github.com/BetaLeaf

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
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

1 person likes this

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)

Share this post


Link to post
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
 

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Thank you for helping me Surya,

I am running a Windows 7 64-Bit OS here.
Now I'm quite excited about how you do that. :-)

Sincerely
Natulux

Share this post


Link to post
Share on other sites

That's a small one:

scripts.ini:

[Startup]
0CmdLine=FavMan.bat
0Parameters=

Regards
Natulux

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

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)

Share this post


Link to post
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

  • Similar Content

    • LOWLIFE
      By LOWLIFE
      This is a personal project to log into several facebook accounts and send a message to a specific person on their birthday. I need to stop a script in a few different ways for several different reasons. For example, it might start sending the email to the wrong account, it might do something other than send a message, it might fail to logout of one account, etc. 
      1) Pause the script at it's exact location with a resume feature in case I need to put it on hold while I do another task. 
      2) Pause the script at it's current location with the option to start over or execute another part of the script (example in GUI with multiple buttons). 
      Also, is there a way to interact with menus? If I log into facebook how can I force it to go straight to sending a message to the proper person? I tried automating a mouseclick but the window opens in different places. I also tried searching for specific text and I couldn't get any information from the windows info tool on the facebook page. 
      Also, how do I get my code in here to show like it does in my editor? (scite)
      Thanks for looking at it, and any help/suggestions I sgreatly appreciated!
      <snip>
    • Simpel
      By Simpel
      Hi,
      I do recognize bad behaviour at this snippet:
      #include <AutoItConstants.au3> Global $g_sSD = @ScriptDir & "\" Global $g_sBurstPath = $g_sSD & "Burst\" DirCreate($g_sBurstPath) Local $sFileName = "Test_mit_3_Seiten.pdf" ; any PDF with more than 1 page inside @ScriptDir FileCopy($g_sSD & $sFileName, $g_sBurstPath & $sFileName, 1) ;~ Sleep(13000) Local $hTimer = TimerInit() ConsoleWrite("Start" & @CRLF) _Burst($g_sBurstPath & $sFileName) ; bursts PDF into single pages ;~ While _FileInUse($g_sBurstPath & $sFileName) ;~ WEnd ConsoleWrite("End: " & Round(TimerDiff($hTimer)) & "ms" & @CRLF) Exit Func _quotePath($sPath) ; because of possible "spaces" inside pathes $sPath = '"' & $sPath & '"' Return $sPath EndFunc Func _Burst($sFile) Local $sPDFtk = $g_sSD & "pdftk.exe" ; path to pdftk.exe (and libiconv2.dll) Local $sCurrWorkingDir = @WorkingDir FileChangeDir($g_sBurstPath) ; it has to change for reasons Local $iPID = Run(_quotePath($sPDFtk) & ' ' & _quotePath($sFile) & ' burst', "", @SW_SHOW, $STDOUT_CHILD + $STDERR_CHILD) ; @SW_SHOW just to see "PDFtk is working" Local $sOutput, $sError While 1 $sOutput &= StdoutRead($iPID) $sError &= StderrRead($iPID) If @error Then ExitLoop Sleep(10) WEnd FileChangeDir($sCurrWorkingDir) ; back to normal EndFunc Func _FileInUse($sFilename) ; by Siao Local $aRet, $hFile $aRet = DllCall("Kernel32.dll", "hwnd", "CreateFile", _ "str", $sFilename, _ ;lpFileName "dword", 0x80000000, _ ;dwDesiredAccess = GENERIC_READ "dword", 0, _ ;dwShareMode = DO NOT SHARE "dword", 0, _ ;lpSecurityAttributes = NULL "dword", 3, _ ;dwCreationDisposition = OPEN_EXISTING "dword", 128, _ ;dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL "hwnd", 0) ;hTemplateFile = NULL $hFile = $aRet[0] If $hFile = -1 Then ;INVALID_HANDLE_VALUE = -1 $aRet = DllCall("Kernel32.dll", "int", "GetLastError") SetError($aRet[0]) Return 1 ; file in use (@error contains system error code) Else ;close file handle DllCall("Kernel32.dll", "int", "CloseHandle", "hwnd", $hFile) Return 0 ; file not in use EndIf EndFunc This bursting took about 15000ms. If I activate line 8 "Sleep(13000)" then the bursting itself never needed more than 1000ms. Round about 13000ms delay is needed until bursting is acting very fast, otherwise needing about 15000ms.
      Then I tested _FileInUse() instead of _Burst() w/o Sleep(13000). This runs in 3ms. It seemes to me that FileCopy() and Burst() are interacting in a way I can't see.
      Any ideas? Regards, Conrad
      P.S. You need pdftk.exe and libiconv2.dll at @ScriptDir. This you can get free here: https://www.pdflabs.com/tools/pdftk-server/ (I'm not sure whether I'm allowed to attach it here).
       
    • Simpel
      By Simpel
      Hi,
      after I recognized that some of my scripts fail if they are at windows startup I researched for a solution. Problem could be fixed if I wait about 120 seconds after login. So how to measure this?
      #include-once #include <AD.au3> #include <Date.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _SecondsAfterLogin ; Description ...: Returns how many seconds are gone since last login ; Syntax ........: _SecondsAfterLogin() ; Parameters ....: None ; Return values .: Success - Integer of seconds ; Failure - 0, sets @error to 1 ; Author ........: Conrad Zelck ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _SecondsAfterLogin() Local $sDate Local $iSec $sDate = __GetLogonTime() ; UTC If @error Then $sDate = __GetLogonTime_AD() ; local time If @error Then Return SetError(1, 0, 0) Else $sDate = __LocalTime($sDate) ; UTC to local time EndIf $iSec = __TimeDifference($sDate) Return $iSec EndFunc #region - INTERNAL_USE_ONLY Func __GetLogonTime($sUserName = @UserName, $sComputerName = @ComputerName) ; Idea by trancexx: http://www.autoitscript.com/forum/topic/113611-if-isadmin-not-detected-as-admin/ Local $aRet = DllCall("netapi32.dll", "long", "NetUserGetInfo", "wstr", $sComputerName, "wstr", $sUserName, "dword", 11, "ptr*", 0) If @error Or $aRet[0] Then Return SetError(1, 0, 0) Local $sSeconds = DllStructGetData(DllStructCreate("ptr;ptr;ptr;ptr;dword;dword;dword;ptr;ptr;dword;dword;dword;dword;ptr;dword;ptr;dword;dword;byte;dword", $aRet[4]), 10) DllCall("netapi32.dll", "long", "NetApiBufferFree", "ptr", $aRet[4]) Local $sLastLogon = _DateAdd('s', Number($sSeconds), "1970/01/01 00:00:00") Return $sLastLogon EndFunc Func __GetLogonTime_AD() Local $iSuccess = _AD_Open() If $iSuccess = 1 Then Local $sDate = _AD_GetLastLoginDate() $sDate = __NumberDate_StringDate($sDate) _AD_Close() Return $sDate Else Return SetError(1, 0, 0) EndIf EndFunc Func __NumberDate_StringDate($sDate) Local $y, $m, $d, $h, $min, $s $y = StringMid($sDate,1, 4) $m = StringMid($sDate,5, 2) $d = StringMid($sDate,7, 2) $h = StringMid($sDate,9, 2) $min = StringMid($sDate,11, 2) $s = StringMid($sDate,13, 2) $sDate = $y & "/" & $m & "/" & $d & " " & $h & ":" & $min & ":" & $s Return $sDate EndFunc Func __LocalTime($sDate) Local $aTimeZone = _Date_Time_GetTimeZoneInformation() If $aTimeZone[0] <> 2 Then $iTimeZoneOffset = ($aTimeZone[1]) * -1 Else $iTimeZoneOffset = ($aTimeZone[1] + $aTimeZone[7]) * -1 EndIf $iTimeZoneOffset /= 60 ; in hours Local $sHour = StringMid($sDate, 12, 2) $sHour += $iTimeZoneOffset $sDate = StringLeft($sDate, 11) & $sHour & StringRight($sDate, 6) Return $sDate EndFunc Func __TimeDifference($sDate) Local $sNow = _NowCalc() Local $sDiff = _DateDiff("s", $sDate, $sNow) Local $iDiff = Number($sDiff) Return $iDiff EndFunc #endregion - INTERNAL_USE_ONLY I had to look what kind of login it is. Some of my computers are logging in with active directory and other not.
      Here is an example:
      #include <SecondsAfterLogin.au3> Local $iSec = _SecondsAfterLogin() MsgBox(0, '', "Time since last login: " & _HHMMSS($iSec, "s")) Exit Func _HHMMSS($iTime, $sType = "ms") If $sType = "s" Then Local $sHHMMSS = StringFormat("%.2d:%.2d:%.2d", (Floor($iTime / 3600)), (Floor(Mod($iTime,3600) / 60)), (Mod(Mod($iTime,3600),60))) Else Local $sHHMMSS = StringFormat("%.2d:%.2d:%.2d", (Floor($iTime / 3600000)), (Floor(Mod($iTime,3600000) / 60000)), (Mod(Mod($iTime,3600000),60000) / 1000)) EndIf Return $sHHMMSS EndFunc I hope someone find it useful.
      Regards, Conrad
      P.S. Review is welcome.
    • computergroove
      By computergroove
      I am trying to start my script on Windows startup and it doesn't run. I have disabled defender and smartscreen with no luck. There is no antivirus on this machine. I have added the script to shell:startup, shell:common startup and HKLM\Software\Microsoft\Windows\Current Version\Run all with no luck. Im at a loss. Please help.
    • Trolleule
      By Trolleule
      Hi,
      i try to simulate the $LVS_EDITLABELS behaviour so by clicking twice the item can be edited but the second mouse click has to be a little bit delayed to trigger the editing. The editing has to be done in other columns too, so i can't use $LVS_EDITLABELS.
      So
      - one click selects an item
      - double click performs a specific function
      - one click + another 800ms delayed click performs an editing
      Does someone have an idea?
      #AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Global $Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work Global $aClick_Info[2] Global $hListView, $hTmp_Edit Global $GUI, $hImage $GUI = GUICreate("(UDF Created) ListView Create", 400, 300) $hListView = _GUICtrlListView_Create($GUI, "", 2, 2, 394, 268) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ; Load images $hImage = _GUIImageList_Create() _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16)) _GUICtrlListView_SetImageList($hListView, $hImage, 1) ; Add columns _GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100) _GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100) _GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 100) ; Add items _GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0) _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1) _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2) _GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1) _GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1) _GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $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 Local $iIndex, $iSubItem, $sTmp_Text, $aRect, $aPos $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $iIndex = DllStructGetData($tInfo, "Index") $iSubItem = DllStructGetData($tInfo, "SubItem") _DebugPrint("$NM_CLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode & @LF & _ "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _ "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _ "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags")) ; make sure user clicks on the listview & only the activate If $iIndex <> -1 Then GUICtrlDelete($hTmp_Edit) $aClick_Info[0] = $iIndex $aClick_Info[1] = $iSubItem ;~ GUISetAccelerators($aAccelKeys) $sTmp_Text = _GUICtrlListView_GetItemText($hWndListView, $iIndex, $iSubItem) ConsoleWrite("item: " & $iIndex & " subitem: " & $iSubItem & " text: " & $sTmp_Text & @CRLF) If $iSubItem = 0 Then $aRect = _GUICtrlListView_GetItemRect($hWndListView, $iIndex, 2) Else $aRect = _GUICtrlListView_GetSubItemRect($hWndListView, $iIndex, $iSubItem) EndIf $aPos = ControlGetPos("", "", $hWndListView) ConsoleWrite("Information :" & StringFormat("Item 2 Rectangle : [%d, %d, %d, %d]", $aRect[0]+ $aPos[0], $aRect[1]+ $aPos[1], $aRect[2], $aRect[3]) & @CRLF) $hTmp_Edit = GUICtrlCreateEdit($sTmp_Text, $aRect[0] + $aPos[0], $aRect[1] + $aPos[1], $aRect[2] - $aRect[0], $aRect[3] - $aRect[1], 0) GUICtrlSetState($hTmp_Edit, $GUI_FOCUS) EndIf Case $NM_DBLCLK ; Sent by a list-view control when the user clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) _DebugPrint("$NM_DBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode & @LF & _ "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _ "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _ "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags")) Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) _DebugPrint("$NM_RCLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode & @LF & _ "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _ "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _ "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags")) Return 0 ; allow the default processing Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key _DebugPrint("$NM_RETURN" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _DebugPrint($s_text, $line = @ScriptLineNumber) ConsoleWrite( _ "!===========================================================" & @LF & _ "+======================================================" & @LF & _ "-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _ "+======================================================" & @LF) EndFunc ;==>_DebugPrint