bourny Posted August 4, 2009 Posted August 4, 2009 I have a gui with a simple list box that lists names of applications awaiting delivery. This is updated by the program once the requested applications arrive from the server pushing them out. My list box is updated by an internal adlib that advises the user of the status of the package being sent. The user does not need to update or click on the lists but they can as my script does not prevent them. My issue is in testing if I click loads of times on the list boxes (inc right clicking) the program crashes. I guess this is because I am not telling the script what to do if a user clicks on the control as I am wanting to ignore any user input. I can use the $ws_disabled which does the job and stops the user from clicking the controls therefore crashing the window. This however has an undesired affect on the colour and changes the listbox to be greyed out. What I would like to achieve is to ignore any user input without disabling the listbox gui. OR disable and beable to change the colour. I have omitted the script at this point as it is quite lengthy but I can include if someone wishes to trawl thru it ... Thanks
bourny Posted August 5, 2009 Author Posted August 5, 2009 Still struggling with this one. The only way I can get the window to stop crashing is to use the WS_disabled for the list box however this gives the undesired greyed out colour . I have attached the code ... expandcollapse popup;Stop 2 occurances of the script running _Singleton(@ScriptName) ;¬¬¬¬¬¬¬¬¬ ;INCLUDES > --------------------------- > ;¬¬¬¬¬¬¬¬¬ #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <Misc.au3> #include <WinAPI.au3> #include <Array.au3> #include <GUIConstants.au3> #Include <GuiListView.au3> #include <Constants.au3> #include <ListviewConstants.au3> #include <ListboxConstants.au3> #include <StaticConstants.au3> #Include <GuiEdit.au3> #Include <File.au3> #Include <../NEW UDFs/_StringSize.au3> ;¬¬¬¬¬¬¬¬¬ ;HOTKEYS > --------------------------- > ;¬¬¬¬¬¬¬¬¬ HotKeySet("!x", "HotKey") ;Alt + x - Terminate and remove HotKeySet("!a", "HotKey2") ;Alt + a - just abort ;¬¬¬¬¬¬¬¬¬¬¬ ;VARIABLES > --------------------------- > ;¬¬¬¬¬¬¬¬¬¬¬ ;Array Variables Global $3dNetworkInstallArray Global $MulticastArrayPositions Global $ArrayOfMulticastApps Global $ArrayOfNetOnlyInstalls ;--------------- ;Animated Gif Variables Global $GifSpeed Global $Time = 31 Global $GifStop ;Variables belonging to First animated Gif example Global $Gif = "c:\MonkeyAni.gif" Global $i = 0, $ApX, $ApY, $ApW, $ApH, $eX, $eY Global $hImage, $hBitmap, $hScrDC, $hMemDC, $tSize, $pSize, $tSource, $pSource, $tBlend, $pBlend Global $GFC, $GFDC, $pDimensionIDs, $tDL Global $Pause Global $hGUI ;Variables belonging to second Gif example ;Const $GIF_guiHWND = 0 ;Const $GIF_hwnd = 1 ;Const $GIF_Num_Of_Frames = 9 ;Const $GIF_Current_Frame = 8 ;Global $Data_Gifs[101][14] ;$Data_Gifs[0][0] = 0 ;Count of how many Gifs there are in existance currently. ;--------------- ;Main Gui window variables Global $gui Global $GuiWidth = 500 Global $GuiHeight = 500 ;--------------- ;Table Variables Global $listView Global $ColumnTitles = "Application Name|Progress" ;--------------- ;Multicast Variables Global $LocalMulticastFolder = @HomeDrive & "\Multicasts" ;--------------- ;Adlib Variables Global $EnableAdlibMulticastsTracking ;--------------- ;Misc Variables Global $PackageFailures Global $UpdatesLocation = "c:\updates\" & @ScriptName Global $Log = $UpdatesLocation & "\" & @ScriptName & ".log" ;¬¬¬¬¬¬¬¬¬¬¬¬¬ ;GLOBAL ARRAY DESCRIPTIONS > --------------------------- > ;¬¬¬¬¬¬¬¬¬¬¬¬¬ ;--------- ;$3dNetworkInstallArray ;------------------------------------- ARRAY ----------------------------------------------- ; 0 1 2 3 4 ;---- Friendly Name --- Full Exe Path --- Completion State ---List View Row Lookup ID---JOB--- ;------------------------------------- ARRAY ----------------------------------------------- ;Description ;Main array containing all the main information of the work to be done. ;$3dNetworkInstallArray ;--------- ;$ArrayOfMulticastApps ;-------------ARRAY--------------- ; 0 ;---- Friendly Name : ExeName ---- ;-------------ARRAY--------------- ;Description ;----------- ; This array will be updated continuously by the Adlib manager CheckMulticastProgress() ; The array will have the friendly names of all the applications requiring multicast and add a : then the name of the exe ; this array will be used to update / replace the multicast Multi sz with the names of the exes to allow reruns to be aware if the applicaltion has already multicasted ;$ArrayOfMulticastApps ;--------- ;$MulticastArrayPositions ;------ARRAY------- ; 0 ;---- Position ---- ;------ARRAY------- ;Position in Main $3dNetworkInstallArray of each multicast application ;$MulticastArrayPositions ;--------- ;¬¬¬¬¬¬¬¬¬¬¬¬¬ ;SCRIPT CORE > --------------------------- > ;¬¬¬¬¬¬¬¬¬¬¬¬¬ ReadAppsToInstallList() ; Creates a master array with Multicast / Net only flags $3dNetworkInstallArray CreateMainGUI() Local $NeverEnd DO Sleep(2000) Until $NeverEnd = 1 Func ReadAppsToInstallList() Dim $yPlace = 1 Dim $y = 0 Global $3dNetworkInstallArray[$yPlace][5] ;1.-------------------------------------- ;PROCESS NETWORK ONLY INSTALLATIONS ARRAY ;---------------------------------------- $ListofNetOnlyAppsFullPaths = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Test", "PostAppConfig_NetworkOnlyInstalls") If $ListofNetOnlyAppsFullPaths <> "" Then $ArrayOfNetOnlyInstalls = StringSplit($ListofNetOnlyAppsFullPaths, @lf) ;Create 3D array of Network only applications ;------------------------------------- ARRAY ----------------------------------------------- ;---- Friendly Name --- Full Exe Path --- Completion State ---List View Row Lookup ID---JOB--- ;------------------------------------- ARRAY ----------------------------------------------- For $Element in $ArrayOfNetOnlyInstalls If $y <> 0 Then $yPlace = $yPlace + 1 redim $3dNetworkInstallArray[$yPlace][5] EndIf $SplitUp = StringSplit($Element, "=") If IsArray($SplitUp) Then $SizeOfArray = Ubound($SplitUp) If $SizeOfArray <> 3 Then ContinueLoop $3dNetworkInstallArray[$y][0] = $SplitUp[1] $3dNetworkInstallArray[$y][1] = $SplitUp[2] ;Will contain the full path to the package provded by AppConfig utility If Not FileExists($SplitUp[2]) Then $3dNetworkInstallArray[$y][2] = "Package Missing" Else $3dNetworkInstallArray[$y][2] = "Qued for Installation" EndIf $3dNetworkInstallArray[$y][4] = "NetOnly" $y = $y + 1 EndIf Next EndIf ;================================================================= ;2.----------------------------------- ;PROCESS MULTICAST INSTALLATIONS ARRAY ;------------------------------------- $ListofMcastApps = "Test Package 1" & @lf & "Test Package 2" & @lf & "Test Package 3" If $ListofMcastApps <> "" Then $ArrayOfMulticastApps = StringSplit($ListofMcastApps, @lf) ;Create 3D array of Network only applications ;------------------------------------- ARRAY ----------------------------------------------- ;---- Friendly Name --- Full Exe Path --- Completion State ---List View Row Lookup ID---JOB--- ;------------------------------------- ARRAY ----------------------------------------------- For $Element in $ArrayOfMulticastApps $DetectFirstPos = Ubound($ArrayOfMulticastApps) - 1 If $Element = $DetectFirstPos Then ContinueLoop If $y <> 0 Then $yPlace = $yPlace + 1 redim $3dNetworkInstallArray[$yPlace][5] EndIf ; Look for exes piped into the registry multi SZ - this indicates the package has already been multicasted on a previous run. If StringInStr($Element, "=") Then $SplitUp = StringSplit($Element, "=") If IsArray($SplitUp) Then $SizeOfArray = Ubound($SplitUp) If $SizeOfArray <> 3 Then ContinueLoop $3dNetworkInstallArray[$y][0] = $SplitUp[1] $3dNetworkInstallArray[$y][1] = $SplitUp[2] $3dNetworkInstallArray[$y][2] = "???" $3dNetworkInstallArray[$y][4] = "Multicast" EndIf Else $3dNetworkInstallArray[$y][0] = $Element $3dNetworkInstallArray[$y][2] = "???" $3dNetworkInstallArray[$y][4] = "Multicast" EndIf $y = $y + 1 Next EndIf EndFunc ;--------------------------------- Func CreateMainGUI() Global $gui, $background, $pic ;--------------- ;CREATE MAIN GUI ;--------------- $gui = GUICreate("Delayed Application Installations", $GuiWidth, $GuiHeight ) $background = GUICtrlCreatePic("c:\CD_stack.jpeg", 0, 0, 600, 600, $WS_CLIPSIBLINGS); background picture GUISetBkColor (0xCCCCCC) ; will change background color GUISetState(@SW_SHOW) ;------------------------- ;CREATE MAIN GUI TITLE BOX ;------------------------- ;Create Title for GUI Window $TitleWording = "TEST Software Delivery" $FontSize = 20 $FontWeight = 400 $fontName = "Verdana" ;Get the dimensions the title box should be depending on the size of the wording ;UDF provided by http://www.autoitscript.com/forum/index.php?showtopic=89610&view=findpost&p=644078 $ArrayOfTitleSizes = _StringSize($TitleWording, $FontSize, $FontWeight, 0, $fontName) $WidthOfTitleBox = $ArrayOfTitleSizes[2] $HeightOfTitleBox = $ArrayOfTitleSizes[3] ;Work out the central point to float the title in the Main Gui Window $PadLeft = $GuiWidth - $WidthOfTitleBox $PadLeft = $PadLeft / 2 ;Create the Title box and setup $Title = GUICtrlCreateLabel ( $TitleWording, $PadLeft, 20 , $WidthOfTitleBox, $HeightOfTitleBox , $SS_CENTER,$WS_EX_CLIENTEDGE) GUICtrlSetFont(-1, $FontSize, 500, 0, $fontName) GUICtrlSetBkColor ( -1, 0xFFFFFF) ;------------------------------------------- ;------------ ;ADD LIST BOX ;------------ PopulateGuiList() ;----------- ;ADD GRAPHIC ;----------- ;Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\logo4.gif" ; transparent MDI child window ;$pic = GUICreate("", 169, 68, 200, 200, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $gui) ; transparent pic ;$basti_stay = GUICtrlCreatePic($sFile, 0, 0, 169, 68) ;GUISetState(@SW_SHOW) ;The following are 2 different Gif generation scripts. Rem out the one you dont want to test and rem out its corresponding functions below ;------------- ;ADD ANIMATION ;------------- ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ;EXAMPLE 1 ;Initialise the Gif with first gif example ;Gif Animation Example 1 ;$hGUI = GUICreate("", 0, 0, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST), $Gui) ;$hGUI = GUICreate("", 0, 0, -1, -1, $WS_BORDER, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST), $gui) ;GUISetState() ;GifInit() ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ;EXAMPLE 2 ;Initialise the Gif using second Gif script sample ;$hGUI = GUICreate("", 0, 0, -1, -1, $WS_BORDER, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW), $Gui) ;GUISetState() ;GifInit($Gif, 1 ) ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx EndFunc ;--------------------------------- Func PopulateGuiList() ;CREATE THE LIST BOX ;------------------- ;Set the List Boxes Styles and layout as an external variable $StandardListStyle = BitOr($WS_BORDER, $LVS_NOSORTHEADER, $ws_disabled) ;$ExtendedListStyle = BitOR($LVS_EX_FLATSB, $WS_EX_LAYERED,$WS_EX_WINDOWEDGE, $WS_HSCROLL, $WS_EX_CLIENTEDGE ) $ExtendedListStyle = BitOR($WS_HSCROLL, $WS_EX_CLIENTEDGE ) ;Create the ListBox using the above syles $listview = GuiCtrlCreateListView ($ColumnTitles,10,100,300,200, $StandardListStyle, $ExtendedListStyle) GuiCtrlSetState(-1,$GUI_ONTOP) GUICtrlSetBkColor ( $listview, 0xccffff) GUISetState(@SW_SHOW) ;POPULATE THE LIST BOX WITH THE ARRAY VALUES ;------------------------------------------- $NumOfRows = ubound($3dNetworkInstallArray) Dim $y = 0 Dim $counter Dim $ControlID = 1 Dim $Item Dim $StartID = 0 Do GuiCtrlCreateListViewItem($3dNetworkInstallArray[$y][0] & "|" & $3dNetworkInstallArray[$y][2], $listview) ;GuiCtrlCreateListViewItem($StartID & "|" & $3dNetworkInstallArray[$y][0] & "|" & $3dNetworkInstallArray[$y][2], $listview) $3dNetworkInstallArray[$y][3] = $StartID $StartID = $StartID + 1 $y = $y + 1 $counter = $counter + 1 Until $counter = $NumOfRows ;-------------------------- ;RESIZE THE POLULATED LIST BOX TO MAKE IT LOOK NEAT ;-------------------------------------------------- _GUICtrlListView_SetColumnWidth($ListView, 0, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($ListView, 1, $LVSCW_AUTOSIZE_USEHEADER) $iY = _GUICtrlListView_ApproximateViewHeight($listview) $iX = _GUICtrlListView_ApproximateViewWidth($listview) + 4 ;Control the table growing past the size of the main GUI window if the rezize value is to big for the main gui - ;This will calculate if the New size is above the MainGui width and reduce it to within 10 pixels dim $XResizeMaxed dim $YExtendedDueToXMaxed dim $YExtendAmmount = 0 If $iX > $GuiWidth Then $iX = $GuiWidth - 20 $XResizeMaxed = 1 EndIf ;Calculate the height auto resize and reduce if the Width has maxed out to avoid a unnecessary vertical scrollbar If $XResizeMaxed = 1 and $YExtendedDueToXMaxed <> 1 Then $YExtendAmmount = 10 $iY = _GUICtrlListView_ApproximateViewHeight($listview) + $YExtendAmmount ;Work out how to keep the list box in the center of the gui window $DifferenceBetweenGuiAndListBoxLength = $GuiWidth - $iX $PadLeft = $DifferenceBetweenGuiAndListBoxLength / 2 ;Work out how to place the listbox at the bottom half of the GUI $GuiHalf = $GuiHeight / 2 If $iY < $GuiHalf Then ;Set the vertical Pad height to at least half way down as the List box is small $PadHeight = $GuiHalf Else ;List box is relativly large so calulate the best place for the List Box $ListBoxTotalAllowedHeight = $GuiHalf - 10 $PadHeight = $GuiHalf $iY = $ListBoxTotalAllowedHeight ;$HeightOfListBoxFromBottomOfGui = $GuiHeight - $iY - 10 ;$StartHeightOfListBox = $GuiHeight - $HeightOfListBoxFromBottomOfGui ;$PadHeight = $StartHeightOfListBox EndIf GUICtrlSetPos ( $listview,$PadLeft, $PadHeight , $iX , $iY ) ;Sleep(20000) EndFunc ;--------------------------------- Func UpdateGUI($Package, $StatusOfPackage) $Result = _ArraySearch($3dNetworkInstallArray, $Package, 0, 0, 0, 1, 1) _GUICtrlListView_SetItemText($listView, $3dNetworkInstallArray[$Result][3], $StatusOfPackage, 1) ;Resize Table to cater for length of new text _GUICtrlListView_SetColumnWidth($ListView, 0, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($ListView, 1, $LVSCW_AUTOSIZE_USEHEADER) ;Get the new size the rows should be to see all the information on the screen $iX = _GUICtrlListView_ApproximateViewWidth($listview) + 4 ;Control the table growing past the size of the main GUI window if the rezize value is to big for the main gui - ;This will calculate if the New size is above the MainGui width and reduce it to within 10 pixels dim $XResizeMaxed ;Global $YExtendedDueToXMaxed Global $YExtendAmmount = 0 If $iX > $GuiWidth Then $iX = $GuiWidth - 20 $XResizeMaxed = 1 EndIf ;If $XResizeMaxed = 1 and $YExtendedDueToXMaxed <> 1 Then $YExtendAmmount = 10 If $XResizeMaxed = 1 and $YExtendAmmount = 0 Then $YExtendAmmount = 10 ;Calculate the height auto resize and reduce if the Width has baxed out to avoid a unnecessary vertical scrollbar $iY = _GUICtrlListView_ApproximateViewHeight($listview) + $YExtendAmmount ;Work out how to keep the list box in the center of the gui window $DifferenceBetweenGuiAndListBoxwidth = $GuiWidth - $iX $PadLeft = $DifferenceBetweenGuiAndListBoxwidth / 2 $GuiHalf = $GuiHeight / 2 If $iY < $GuiHalf Then ;Set the vertical Pad height to at least half way down as the List box is small $PadHeight = $GuiHalf Else ;List box is relativly large so calulate the best place for the List Box ;Work out how to place the listbox at the bottom half of the GUI $PadHeight = $GuiHalf $ListBoxTotalAllowedHeight = $GuiHalf - 10 $iY = $ListBoxTotalAllowedHeight ;Look at extending X also if the Y value has increased creating a scroll bar $ExtendXDueToMaxedY = $iX + 16 If $ExtendXDueToMaxedY > $GuiWidth Then $iX = $GuiWidth - 10 Else $iX = $ExtendXDueToMaxedY EndIf ;Recalculate the Padding again due to vertical and horizontal changes $DifferenceBetweenGuiAndListBoxwidth = $GuiWidth - $iX $PadLeft = $DifferenceBetweenGuiAndListBoxwidth / 2 ;$HeightOfListBoxFromBottomOfGui = $GuiHeight - $iY - 10 ;$StartHeightOfListBox = $GuiHeight - $HeightOfListBoxFromBottomOfGui ;$PadHeight = $StartHeightOfListBox EndIf GUICtrlSetPos ($listview,$PadLeft, $PadHeight , $iX , $iY) EndFunc ;--------------------------------- Func HotKey() TrayTip("TERMINATING APPLICATION CONFIGURATION", "Stopping Post App Config and removing Rerun", 5, 17) Sleep(5000) RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "PostAppConfigInstalls") $LogType = "ForceTermination_NoRerun" TrayTip("","",0) Exit EndFunc ;--------------------------------- Func HotKey2() TrayTip("TERMINATING APPLICATION CONFIGURATION", "Stopping Post App Config", 5, 17) Sleep(5000) TrayTip("","",0) Exit EndFunc ;---------------------------------
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now