bourny Posted July 2, 2009 Share Posted July 2, 2009 I have built a gui to do various tasks and output the results into a listview that is updated by the program. The users never interact with this gui however I found that I can still select things in the listview and if I keep clicking on areas of the Gui or listox the Gui eventually crashes with Dr watson errors. My theory is Guis are disigned to grab input from the user so I need to find a way to tell the gui to ignore any clicking done on the gui or tell it to do nothing if someone clicks on the GUI. I would have included my script but I thought I will see if anyone knows why this happens as I will need to strip down the script to provide an example as this script operates using other external scripts. Many Thanks Link to comment Share on other sites More sharing options...
Andreik Posted July 2, 2009 Share Posted July 2, 2009 Can we see your script, to can fix your problem well? When the words fail... music speaks. Link to comment Share on other sites More sharing options...
bourny Posted July 2, 2009 Author Share Posted July 2, 2009 I have stripped out all my script and added in just the basics of the gui to allow easy troubleshooting. To get the issue simply double click on the test packages in the list and it will eventually error out. I have to kill the Dr watson processes to get rid of the gui ;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 #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) ;$ExtendedListStyle = BitOR($LVS_EX_FLATSB, $WS_EX_LAYERED,$WS_EX_WINDOWEDGE, $WS_HSCROLL, $WS_EX_CLIENTEDGE ) $ExtendedListStyle = BitOR($WS_HSCROLL, $WS_EX_CLIENTEDGE, $WS_EX_LAYERED ) ;Create the ListBox using the above syles $listview = GuiCtrlCreateListView ($ColumnTitles,10,100,300,200, $StandardListStyle, $ExtendedListStyle) GuiCtrlSetState(-1,$GUI_ONTOP) GUICtrlSetBkColor ( -1, 0xFFFFFF) 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 ;--------------------------------- Link to comment Share on other sites More sharing options...
bourny Posted July 2, 2009 Author Share Posted July 2, 2009 apologies - used wrong tags for my script Link to comment Share on other sites More sharing options...
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