Sign in to follow this  
Followers 0
Speleologist

Problem with Pic and Label controls

5 posts in this topic

I have an analysis application which has a number of GUI front ends to various results files. I am experiencing a strange problem with the secondary GUI's.

All the GUI's have the same graphics and labels in what is effectively a header. With all of these (which are set up from within a function) I see the following issue:

If I load the GUI from within another function, the first GIF file and the Label do not load. All other components of the GUI load correctly.

If I load exactly the same function as an action from a button in another GUI, then they load correctly.

If I take the single GUI and required variables into a small subsidiary application for testing, the controls also load correctly.

I can't see anything that would cause this, any suggestions? (Problem is with hcc_weblogo.gif and the label "HCC Workstations in the code below.

Func EdirNameReport ()

$eDirResultWindow = GUICreate ( $strTitle, 800 , 600, $strWidth/2-400, $strHeight/2-300 )
GUISetBkColor(0xFFFFFF)
GUISetIcon(@SystemDir & "\sysdm.cpl", 0)

GUICtrlCreatePic ( @ScriptDir & "\hcc_weblogo.gif", $strHeaderMarginLeft , $strHeaderMarginTop, 95, 61 )
GUISetFont ( 12, 800, 0, $Font )
GUICtrlCreateLabel ( "HCC Workstations", $strHeaderMarginLeft*2 + 95, $strHeaderMarginTop + 10 )
GUISetFont ( 10, 400, 0, $Font )
GUICtrlCreateLabel ( "Analysis of eDirectory and ZfDAgentCheck reports", $strHeaderMarginLeft*2 + 95, $strHeaderMarginTop + 10 + 25 )
GUICtrlCreatePic ( @ScriptDir & "\header_home_image.gif", 800 - $strHeaderMarginLeft - 354 , 0, 354, 100 )
GUICtrlCreateLabel ( "", $strHeaderMarginLeft, 94, 800 - $strHeaderMarginLeft - $strHeaderMarginRight - 354, 6 )
GUICtrlSetBkColor(-1,0xADBE10)

GUISetFont ( 8.5, 400, 0, $font )
GUICtrlCreateLabel ( $strDisplayDate , 800 - $strHeaderMarginLeft - 80, 80, 80, 20, $SS_CENTER )
GUICtrlSetBkColor(-1,0xADBE10)
;GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1,0xFFFFFF)

GUISetState (@SW_SHOW)

EndFunc

Share this post


Link to post
Share on other sites



Speleologist,

it is almost impossible to debug a problem from a single function - one needs to see the context in which the function was called, how the variables are set, etc. So I suggest you post the whole script. ;)

One immediate thought: Have you checked the $strHeaderMarginLeft and $strHeaderMarginTop values as you enter the function to make sure that they hold sensible values and you are not creating the controls outside the GUI? :huh:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

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

 

Share this post


Link to post
Share on other sites

Hi M23,

Thanks for that. Yes, the variables do make sense. They are effectively constant in this script. The whole script is long, but here it is. (It's also not that tidy, but then I'm learning as I go along)

The exact same problem exists with the GUI's in EdirNameReport(), AgentCheckReport(), and ComparisonReport(). It does not occur in AllReport() or the Main GUI. It only occurs when they are called from the functions eDirCheck(), AgentCheck(0 and Comparison(). It does not occur when the GUI buttons in AllReport() are used to call AlleDirCheck(), AllAgentCheck() and AllComparison(). However the GUI that is being called is exactly the same either way.

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.3.8.1
Author: Robin Sermon

Script Function:
Perform a series of workstation data analysis tasks based on information from
eDirectory and ZfDAgentCheck. Functions include the following:

1. Check eDirectory to identify workstations where the wmNameComputer (NETBIOS
name) and eDirectory name do not match or the wmNameComputer is missing.

2. Compare the files in the "Installed", "Not Installed" and "Process" folders
for ZfdAgentCheck. When a workstation has results in more than one, delete
all but the most recent

3. Compare the list of workstations from eDirectory and from the ZfdAgentCheck
and identify those that have run the agent check but are not in eDirectory
and vice versa

#ce ----------------------------------------------------------------------------

; Included Scripts
#include 
#include 
#include 
#Include 
#Include 
#Include 
#Include 
#Include 
#include 
#include 
#include 

; Define global variables
Global $workpath = "\\Nwc-chazenworks01\Chazendata01\Scriptlog\ZfDAgent\Working\"
Global $eDirList = "\\Nwc-chazenworks01\Chazendata01\Scriptlog\ZfDAgent\Working\cleanexport.csv"
Global $ResultsPath = "\\Nwc-chazenworks01\Chazendata01\Scriptlog\ZfDAgent\Reporting\"
Global $NotRegisteredFile = "notregistered.csv"
Global $RegisteredFile = "registered.csv"
Global $NotSeenFile = "notseen.csv"
Global $SeenFile = "seen.csv"
Global $eDirWorkstationsFile = "\\Nwc-chazenworks01\Chazendata01\Scriptlog\ZfDAgent\Working\eDirWorkstations.csv"
Global $copydate = @MDAY & "/" & @MON & "/" & @YEAR
Global $copytime = @HOUR & ":" & @MIN & ":" & @SEC
Global $logdate = StringReplace ($copydate , "/" , "_" , 0)
Global $logtime = StringReplace ($copytime , ":" , "_" , 0)
Global $RightNameFile = "rightname.csv" ; Log file of correctly named workstations
Global $WrongNameFile = "wrongname.csv" ; Log file of incorrectly named workstations
Global $NoNameFile = "noname.csv" ; Log file of workstations with no wMMAMEComputer atribute
Global $aeDirWorkstations ; Array containing all the eDirectory workstations in 3 columns
Global $aeDirWorkstations2
Global $aeDirWorkstationsClean
Global $RightLogLive
Global $WrongLogLive
Global $NoNameLogLive
Global $LogFilePath = "\\nwc-chazenworks01\CHAZENDATA01\Scriptlog\ZfDAgent"
Global $aFileList[3][2] ; Array to hold duplicate file details
Global $aInstalled
Global $aNotInstalled
Global $aProcess
Global $aCheckList
Global $aCheckList2
Global $WSList = "workstations.csv"
Global $font = "Ariel"
Global $a_a
Global $aDuplicates
Global $rightsheetname
Global $wrongsheetname
Global $nosheetname
Global $aRightName
Global $aWrongName
Global $aNoName
Global $aAgentUnique ; List of unique workstation names from the agent check
Global $aEdirUnique ; List of unique workstation NETBIOS names from eDirectory (Does not include workstations with no wmNAMEComputer attribute)
Global $aNotSeen
Global $aNotRegistered
Global $aSeen
Global $aRegistered
Global $eDirRightButton = 9999
Global $eDirWrongButton = 9999
Global $eDirNonameButton = 9999
Global $EdirAllFilesButton = 9999
Global $EdirClosebutton = 9999
Global $eDirResultWindow = 9999
Global $eDirCheckButton = 9999
Global $AgentCheckButton = 9999
Global $ComparisonButton = 9999
Global $AllButton = 9999
Global $exitbutton = 9999
Global $AgentResultWindow = 9999
Global $AgentCheckText = 9999
Global $eAgentCheckButton = 9999
Global $eDirRegText = 9999
Global $eDirRegButton = 9999
Global $NotSeenText = 9999
Global $NotSeenButton = 9999
Global $NotRegisteredText = 9999
Global $NotRegisteredButton = 9999
Global $ComparisonAllFilesButton = 9999
Global $ComparisonClosebutton = 9999
Global $ComparisonResultWindow = 9999
Global $SeenLogLive
Global $seensheetname
Global $nosheetname
Global $agentchecksheetname
Global $RegisteredLogLive
Global $registeredsheetname
Global $NotRegisteredLogLive
Global $notregisteredsheetname
Global $NotSeenLogLive
Global $notseensheetname
Global $eDirCheckButton = 9999
Global $AgentCheckButton = 9999
Global $ComparisonButton = 9999
Global $AllButton = 9999
Global $AppWindow = 9999
Global $AgentCheckOutputFile = "deletions.csv"
Global $AgentCheckOutputFileLive
Global $aAgentDeletions
Global $eAgentCheckClosebutton = 9999
Global $eAgentCheckButton = 9999
Global $eAgentCheckResultWindow = 9999
Global $DupeCount ; The number of duplicate agent check files
Global $InstalledCount
Global $NotInstalledCount
Global $ProcessCount
Global $AllResultsWindow = 9999
Global $AllEdirectoryButton = 9999
Global $AllAgentCheckButton = 9999
Global $AllComparisonButton = 9999
Global $AllClosebutton = 9999

; GUI Variables

$strTitle = "Workstation Analysis"
$strHeight = @DesktopHeight
$strWidth = @DesktopWidth
Global $edirgoodbutton

; Global GUI Controls
Global $Progressicon
Global $Progresstext
Global $CoffeeIcon
Global $CoffeeLabel

; Identify Date and Time

; ...Short Format Date
$Date = _DateTimeFormat ( _NowCalc(), 2 )

; ...Create Date Array
$Date_Array = StringSplit ( $Date, '/', 1 )
;_ArrayDisplay ($Date_Array)

; ...24-Hour Time
$Time = _DateTimeFormat ( _NowCalc(), 4 )

; ...Create Time Array
$Time_Array = StringSplit ( $Time, ':', 1 )

; ...Identify Day of the Week
$iWeekday = _DateToDayOfWeek (@YEAR, @MON, @MDAY)
$strWeekDay = StringLeft ( _DateDayOfWeek($iWeekday), 3)

If $Date_Array[1] < 10 Then
$strMonthDay = StringTrimLeft ( $Date_Array[1], 1)
Else
$strMonthDay = $Date_Array[1]
EndIf

Dim $arrDateSuffix[32]
$arrDateSuffix[0]="th"
$arrDateSuffix[1]="st"
$arrDateSuffix[2]="nd"
$arrDateSuffix[3]="rd"
$arrDateSuffix[4]="th"
$arrDateSuffix[5]="th"
$arrDateSuffix[6]="th"
$arrDateSuffix[7]="th"
$arrDateSuffix[8]="th"
$arrDateSuffix[9]="th"
$arrDateSuffix[10]="th"
$arrDateSuffix[11]="th"
$arrDateSuffix[12]="th"
$arrDateSuffix[13]="th"
$arrDateSuffix[14]="th"
$arrDateSuffix[15]="th"
$arrDateSuffix[16]="th"
$arrDateSuffix[17]="th"
$arrDateSuffix[18]="th"
$arrDateSuffix[19]="th"
$arrDateSuffix[20]="th"
$arrDateSuffix[21]="st"
$arrDateSuffix[22]="nd"
$arrDateSuffix[23]="rd"
$arrDateSuffix[24]="th"
$arrDateSuffix[25]="th"
$arrDateSuffix[26]="th"
$arrDateSuffix[27]="th"
$arrDateSuffix[28]="th"
$arrDateSuffix[29]="th"
$arrDateSuffix[30]="th"
$arrDateSuffix[31]="st"

$strDaySuffix = $arrDateSuffix[$strMonthDay]

$strMonth = _DateToMonth(@MON, 1)
$strDisplayDate = $strWeekDay & " " & $strMonthDay & $strDaySuffix &" " & $strMonth

; Determine Morning/Afternoon
If $Time_Array[1] < 12 Then

$TimeOfDay = "Morning"

Else

$TimeOfDay = "Afternoon"

EndIf

;MsgBox (0, "Screen Resolution", $strWidth & "x" & $strHeight )

Global $strHeaderMarginLeft = 10
Global $strHeaderMarginRight = 10
Global $strHeaderMarginTop = 15

Global $strSercoMarginRight = 10
Global $strSercoMarginBottom = 10

; Clean up from previous runs

Cleanup ()

; Master GUI Definition

$AppWindow = GUICreate ( $strTitle, 800 , 600, $strWidth/2-400, $strHeight/2-300 )
GUISetBkColor(0xFFFFFF)
GUISetIcon(@SystemDir & "\sysdm.cpl", 0)

GUICtrlCreatePic ( @ScriptDir & "\hcc_weblogo.gif", $strHeaderMarginLeft , $strHeaderMarginTop, 95, 61 )
GUISetFont ( 12, 800, 0, $Font )
GUICtrlCreateLabel ( "HCC Workstations", $strHeaderMarginLeft*2 + 95, $strHeaderMarginTop + 10 )
GUISetFont ( 10, 400, 0, $Font )
GUICtrlCreateLabel ( "Analysis of eDirectory and ZfDAgentCheck reports", $strHeaderMarginLeft*2 + 95, $strHeaderMarginTop + 10 + 25 )

GUICtrlCreatePic ( @ScriptDir & "\header_home_image.gif", 800 - $strHeaderMarginLeft - 354 , 0, 354, 100 )
GUICtrlCreateLabel ( "", $strHeaderMarginLeft, 94, 800 - $strHeaderMarginLeft - $strHeaderMarginRight - 354, 6 )
GUICtrlSetBkColor(-1,0xADBE10)

GUISetFont ( 8.5, 400, 0, $font )
GUICtrlCreateLabel ( $strDisplayDate , 800 - $strHeaderMarginLeft - 80, 80, 80, 20, $SS_CENTER )
GUICtrlSetBkColor(-1,0xADBE10)
;GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1,0xFFFFFF)

; GUI Header Labels
GUISetFont ( 12, 800, 0, $Font )
GUICtrlCreateLabel ( "Good " & $TimeOfDay & " " & @UserName & ", Please choose an option below.", 20, 115, 700, 20 )

GUICtrlCreatePic ( @ScriptDir & "\askus.jpg", 800 - $strSercoMarginRight - 150, 600 - $strSercoMarginBottom - 150 - 33 - 16 - 20, 150, 150 )
GUICtrlCreatePic ( @ScriptDir & "\sercologo_tcm3-13101.jpg", 800 - $strSercoMarginRight - 106, 600 - $strSercoMarginBottom - 33 - 16, 106, 33 )
GUICtrlCreatePic ( @ScriptDir & "\strapline_tcm3-13100.gif", 800 - $strSercoMarginRight - 152, 600 - $strSercoMarginBottom - 16, 152, 16 )

$eDirCheckButton = GUICtrlCreateButton ("eDirectory Check" , 20 ,165 ,180 )
GUICtrlSetBkColor (-1, 0xADBE10)
GUICtrlSetTip (-1, "Checks eDirectory for workstations with no Netbios name or the wrong Netbios name" , "eDirectory Check" , 1 , 1)

$AgentCheckButton = GUICtrlCreateButton ("Agent Check" , 20 ,215 ,180 )
GUICtrlSetBkColor (-1, 0xADBE10)
GUICtrlSetTip (-1, "Checks all Agent Check ouptput files and deletes duplicates, saving only the most recent" , "Agent Check" , 1 , 1)

$ComparisonButton = GUICtrlCreateButton ("Comparison" , 20 ,265 ,180 )
GUICtrlSetBkColor (-1, 0xADBE10)
GUICtrlSetTip (-1, "Compares workstation names from eDirectory and Agent Check and reports discrepancies" , "Comparison" , 1 , 1)

$AllButton = GUICtrlCreateButton ("All Checks" , 20 ,315 ,180 )
GUICtrlSetBkColor (-1, 0xADBE10)
GUICtrlSetTip (-1, "Performs all the above checks" , "All Checks" , 1 , 1 )

$exitbutton = GUICtrlCreateButton ("Exit" , 20 ,365, 180 )
GUICtrlSetBkColor (-1, 0xADBE10)
GUICtrlSetTip (-1, "Exits this program" , "Exit" ,1 ,1 )

GUISetState (@SW_SHOW)


;GUI Loop

While 1
$msg = GUIGetMsg (1)
Switch $msg[1]
Case $AppWindow
Switch $msg[0]
Case $msg[0] = $exitbutton AND $msg[1] = $AppWindow
ExitLoop
Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $AppWindow
ExitLoop
Case $msg[0] = $eDirCheckButton And $msg[1] = $AppWindow
MaineDirCheck()
Case $msg[0] = $AgentCheckButton And $msg[1] = $AppWindow
MainAgentCheck()
Case $msg[0] = $ComparisonButton And $msg[1] = $AppWindow
MainComparison()
Case $msg[0] = $AllButton And $msg[1] = $AppWindow
AllChecks()
EndSwitch
Case $eDirResultWindow
Switch $msg[0]
Case $msg[0] = $eDirRightButton And $msg[1] = $eDirResultWindow
LoadEdirRightFile ()
Case $msg[0] = $eDirWrongButton AND $msg[1] = $eDirResultWindow
LoadEdirWrongFile()
Case $msg[0] = $eDirNonameButton AND $msg[1] = $eDirResultWindow
LoadEdirNoFile()
Case $msg[0] = $EdirAllFilesButton And $msg[1] = $eDirResultWindow
LoadAllEdirFiles()
Case $msg[0] = $eDirCloseButton AND $msg[1] = $EdirResultWindow
GUIDelete ($eDirResultWindow)
Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $EdirResultWindow
GUIDelete ($eDirResultWindow)
EndSwitch
Case $AgentResultWindow
Switch $msg[0]
Case $msg[0] = $eAgentCheckButton And $msg[1] = $AgentResultWindow
LoadAgentCheckResultsFile()
Case $msg[0] = $eAgentCheckClosebutton And $msg[1] = $AgentResultWindow
GUIDelete ($AgentResultWindow)
Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $AgentResultWindow
GUIDelete ($AgentResultWindow)
EndSwitch
Case $ComparisonResultWindow
Switch $msg[0]
Case $msg[0] = $eAgentCheckButton And $msg[1] = $ComparisonResultWindow
LoadComparisonAgentFile ()
Case $msg[0] = $eDirRegButton And $msg[1] = $ComparisonResultWindow
LoadComparisonEdirFile ()
Case $msg[0] = $NotSeenButton And $msg[1] = $ComparisonResultWindow
LoadComparisonNotSeenFile ()
Case $msg[0] = $NotRegisteredButton And $msg[1] = $ComparisonResultWindow
LoadComparisonNotRegisteredFile ()
Case $msg[0] = $ComparisonAllFilesButton And $msg[1] = $ComparisonResultWindow
LoadComparisonAll ()
Case $msg[0] = $ComparisonClosebutton And $msg[1] = $ComparisonResultWindow
GUIDelete ($ComparisonResultWindow)
Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $ComparisonResultWindow
GUIDelete ($ComparisonResultWindow)
EndSwitch
Case $AllResultsWindow
Switch $msg[0]
Case $msg[0] = $AllEdirectoryButton And $msg[1] = $AllResultsWindow
AlleDirCheck ()
Case $msg[0] = $AllAgentCheckButton And $msg[1] = $AllResultsWindow
AllAgentCheck ()
Case $msg[0] = $AllComparisonButton And $msg[1] = $AllResultsWindow
AllComparison ()
Case $msg[0] = $AllClosebutton And $msg[1] = $AllResultsWindow
GUIDelete ($AllResultsWindow)
Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $AllResultsWindow
GUIDelete ($AllResultsWindow)
EndSwitch

EndSwitch
WEnd

; Calling Functions - These enable us to manage different behavious according to which GUI calls the process

Func MaineDirCheck () ; Edir check called from main window
Progress()
GUISetState (@SW_DISABLE , $AppWindow )
eDirCheck ()
GUISetState (@SW_ENABLE , $AppWindow )
Endprogress ()
EndFunc

Func AlleDirCheck () ; eDir check called from all checks window
GUISetState (@SW_DISABLE , $AllResultsWindow )
EdirNameReport ()
GUISetState (@SW_ENABLE , $AllResultsWindow )
EndFunc

Func MainAgentCheck () ; Edir check called from main window
Progress()
GUISetState (@SW_DISABLE , $AppWindow )
AgentCheck ()
GUISetState (@SW_ENABLE , $AppWindow )
EndProgress ()
EndFunc

Func AllAgentCheck () ; eDir check called from all checks window
GUISetState (@SW_DISABLE , $AllResultsWindow )
AgentCheckReport ()
GUISetState (@SW_ENABLE , $AllResultsWindow )
EndFunc

Func MainComparison () ; Edir check called from main window
SlowProgress()
GUISetState (@SW_DISABLE , $AppWindow )
Comparison ()
GUISetState (@SW_ENABLE , $AppWindow )
EndSlowProgress ()
EndFunc

Func AllComparison () ; eDir check called from all checks window
VerySlowProgress ()
GUISetState (@SW_DISABLE , $AllResultsWindow )
ComparisonReport ()
GUISetState (@SW_ENABLE , $AllResultsWindow )
EndVerySlowProgress ()
EndFunc


; Top Level Functions for each of the checks

Func eDirCheck ()

EdirWorkstations ()
WrongName ($aeDirWorkstations)
EndProgress ()
EdirNameReport ()
EndFunc

Func AgentCheck()
AgentGetData ()
ProcessDupes ()
EndProgress()
AgentCheckReport ()
EndFunc

Func Comparison ()
AgentGetData ()
EdirWorkstations ()
WSCompare()
EndSlowProgress()
ComparisonReport ()
EndFunc

Func AllChecks ()
VerySlowProgress ()
GUISetState (@SW_DISABLE , $AppWindow )
EdirWorkstations ()
AgentGetData ()
WrongName ($aeDirWorkstations)
ProcessDupes ()
WSCompare ()
EndVerySlowProgress ()
AllReport ()
; MsgBox ( 0 , "Workstation Checks" , "Functionality not yet implemented" )
GUISetState (@SW_ENABLE , $AppWindow )
EndFunc

; Shared Functions (Used by more than one process

Func EdirWorkstations () ; Generates a "Live" list of all workstations in eDirectory, writes it to a file and loads it to an array - Used by EdirCheck and Comparison

$eDirDataFetch = RunWait ( @SystemDir & '\cmd.exe /c ' & $workpath & 'edirdata.cmd' , @WindowsDir , @SW_HIDE)
$datafile = FileOpen ( $workpath & "export.txt" , 0)
$LDAPDATA = FileRead ($datafile)
$CleanData = StringRegexpReplace ( $LDAPDATA , "\r\n " , "" )
$CleanData = StringRegExpReplace ( $CleanData , "#This\ LDIF\ file\ was\ generated\ by\ Novell's\ ICE\ and\ the\ LDIF\ destination\ handler.\r\nversion:\ 1\r\n\r\ndn:\ cn=" , "" )
$CleanData = StringReplace ( $CleanData , "," , "." )
$CleanData = StringRegExpReplace ( $CleanData , "\r\nchangetype:\ add\r\nwMNAMEComputer:\ " , "," )
$CleanData = StringRegExpReplace ( $CleanData , "\r\ndn: cn=" , "" )
$CleanData = StringRegExpReplace ( $CleanData , "\r\n\r\n" , "")
$cleandatafile = FileOpen ($workpath & "cleanexport.txt" , 1)
FileWrite ($cleandatafile , $CleanData )
FileClose ($cleandatafile)
FileClose ($datafile)
$eDirLoad = _FileReadToArray ($workpath & "cleanexport.txt" , $aeDirWorkstations) ; Load the reuslts into an array

EndFunc

Func AgentGetData ()
$aInstalled = _FileListToArray ( $LogFilePath & "\Installed\" , "*.txt" , 1 )
$aNotInstalled = _FileListToArray ( $LogFilePath & "\NotInstalled\" , "*.txt" , 1 )
$aProcess = _FileListToArray ( $LogFilePath & "\Process\" , "*.txt" , 1 )

If $aInstalled = 0 Then
$InstalledCount = 0
Else
$InstalledCount = $aInstalled[0]
EndIf

If $aNotInstalled = 0 Then
$NotInstalledCount = 0
Else
$NotInstalledCount = $aNotInstalled[0]
EndIf

If $aProcess = 0 Then
$ProcessCount = 0
Else
$ProcessCount = $aProcess[0]
EndIf

Global $a_a[4] = [3, $aInstalled, $aNotInstalled, $aProcess]
$aCheckList = $aInstalled
_ArrayConcatenate ($aCheckList ,$aNotInstalled , 1 )
_ArrayConcatenate ($aCheckList ,$aProcess , 1 )
$aCheckList[0] = $InstalledCount + $NotInstalledCount + $ProcessCount
$aCheckList2 = _ArrayUnique ($aCheckList)
EndFunc

; Edirectory Check Functions

Func WrongName ($aArray) ; Function to identify any workstations in eDirectory that have a different netbios name - Used by AgentCheck and Comparison

Local $dn ; Distinguished name of the workstation in eDirectory
Local $WSName ; Netbios Name of the workstation
Local $WSNameLength ; Number of characters in the Netbios Name
Local $ZenName ; The first characters of the Common Name - Same length as NetBios Name. This is the name we use for comparison checking
Local $NameMatch ; Returns zero if the names match and non zero if they do not. Used to determine the log file

; open the log files for writing
$RightLog = FileOpen ( $ResultsPath & $RightNameFile , 1 )
$WrongLog = Fileopen ( $ResultsPath & $WrongNameFile , 1 )
$NoNameLog = FileOpen ( $ResultsPath & $NoNameFile , 1 )

; Write the log file headers
FileWriteLine ( $RightLog , "DN,WM:NAME Computer" )
FileWriteLine ( $WrongLog , "DN,WM:NAME Computer" )
FileWriteLine ( $NoNameLog, "DN" )

; Perform the check

For $i = 1 To $aArray[0]
$WSDetails = StringSplit ( $aArray[$i] , "," )
If @error = 1 Then
FileWriteLine ($NoNameLog , $WSDetails[1])
Else
$dn = $WSDetails[1]
$WSName = $WSDetails[2]
$WSNameLength = StringLen ($WSName)
$ZenName = StringLeft ( $dn , $WSNameLength )
$NameMatch = StringCompare ($WSName , $ZenName )
If $NameMatch = 0 Then
FileWriteLine ( $RightLog , $dn & "," & $WSName )
Else
FileWriteLine ( $WrongLog , $dn & "," & $WSName )
EndIf
EndIf
Next

; Close the log files
FileClose ( $RightLog )
FileClose ( $WrongLog )
FileClose ( $NoNameLog )



; Rename the log files
FileMove ($ResultsPath & $RightNameFile , $ResultsPath & "rightname_" & $logdate & "_" & $logtime & ".csv" )
FileMove ($ResultsPath & $WrongNameFile , $ResultsPath & "wrongname_" & $logdate & "_" & $logtime & ".csv" )
FileMove ($ResultsPath & $NoNameFile , $ResultsPath & "noname_" & $logdate & "_" & $logtime & ".csv" )

$rightsheetname = "rightname_" & $logdate & "_" & $logtime
$wrongsheetname = "wrongname_" & $logdate & "_" & $logtime
$nosheetname = "noname_" & $logdate & "_" & $logtime

$RightLogLive = FileGetLongName ( $ResultsPath & "rightname_" & $logdate & "_" & $logtime & ".csv" )
$WrongLogLive = FileGetLongName ( $ResultsPath & "wrongname_" & $logdate & "_" & $logtime & ".csv" )
$NoNameLogLive = FileGetLongName ( $ResultsPath & "noname_" & $logdate & "_" & $logtime & ".csv" )
_FileReadToArray ($RightlogLive, $aRightname)
_FileReadToArray ($WrongLogLive , $aWrongName)
_FileReadToArray ($NoNameLogLive , $aNoName)

EndFunc

; Agent Check Functions

Func ProcessDupes ()
$Duplicates = _SearchForDupes($a_a)
$aDuplicates = StringSplit ( $Duplicates , "," )
If $Duplicates = "" Then
$DupeCount = 0
Else
_DeleteDupes ()
EndIf
EndFunc

Func _SearchForDupes($a_arrays, $i_ReturnType = 0)
Local $Dupes[1] = [0]

If $a_arrays[0] < 2 Then Return ''

For $i = 1 To $a_a[0] - 1
For $j = $i + 1 To $a_a[0]
_FindDupe($a_a[$i], $a_a[$j], $Dupes)
Next
Next

If $Dupes[0] = 0 Then Return ''

_ArraySort($Dupes)

If Not $i_ReturnType Then
Local $s_return = ''

For $x = 1 To $Dupes[0]
$s_return &= $Dupes[$x] & ','
Next
Return StringTrimRight($s_return, 1)
Else
Return $Dupes
EndIf
EndFunc ;==>_SearchForDupes

Func _FindDupe(ByRef $a_array01, ByRef $a_array02, ByRef $Dupes)
Local $found = False

For $i = 0 To UBound($a_array01) - 1
For $j = 0 To UBound($a_array02) - 1
If $a_array01[$i] = $a_array02[$j] Then
$found = False

For $x = 1 To $Dupes[0]
If $Dupes[$x] = $a_array01[$i] Then
$found = True
ExitLoop
EndIf
Next

If Not $found Then
$Dupes[0] += 1
ReDim $Dupes[$Dupes[0] + 1]
$Dupes[$Dupes[0]] = $a_array01[$i]
EndIf
EndIf
Next
Next
EndFunc ;==>_FindDupe

Func _DeleteDupes ()

$AgentCheckOutputFileHandle = FileOpen ($ResultsPath & $AgentCheckOutputFile , 1)

For $j = 1 to $aDuplicates[0]

Local $aFiles[4][2]
$aFiles[0][0] = 0

$InstalledTime = FileGetTime ( $LogFilePath & "\Installed\" & $aDuplicates[$j] , 0 , 1 )
; MsgBox ( 0 , "Installed" , $aDuplicates[$j] & @LF & $InstalledTime )
If $InstalledTime > 0 Then
$aFiles[0][0] = $aFiles[0][0] + 1
$aFiles[1][0] = $LogFilePath & "\Installed\" & $aDuplicates[$j]
$aFiles[1][1] = $InstalledTime
Else
$aFiles[1][0] = 0
$aFiles[1][1] = 0
EndIf

$NotInstalledTime = FileGetTime ($LogFilePath & "\NotInstalled\" & $aDuplicates[$j] , 0 , 1 )
; MsgBox (0, "NotInstalled" , $aDuplicates[$j] & @LF & $NotInstalledTime )
If $NotInstalledTime > 0 Then
$aFiles[0][0] = $aFiles[0][0] + 2
$aFiles[2][0] = $LogFilePath & "\NotInstalled\" & $aDuplicates[$j]
$aFiles[2][1] = $NotInstalledTime
Else
$aFiles[2][0] = 0
$aFiles[2][1] = 0
EndIf

$ProcessTime = FileGetTime ($LogFilePath & "\Process\" & $aDuplicates[$j] , 0 , 1 )
; MsgBox ( 0 , "Process" , $aDuplicates[$j] & @LF & $ProcessTime )
If $ProcessTime > 0 Then
$aFiles[0][0] = $aFiles[0][0] + 4
$aFiles[3][0] = $LogFilePath & "\Process\" & $aDuplicates[$j]
$aFiles[3][1] = $ProcessTime
Else
$aFiles[3][0] = 0
$aFiles[3][1] = 0
EndIf

; _ArrayDisplay ($aFiles , "Pre-Sort")

_ArraySort ($aFiles , 0 , 1 , 0 ,1 )

; _ArrayDisplay ($aFiles , "Sorted")

If IsString ($aFiles[1][0]) Then
FileWriteLine ($AgentCheckOutputFileHandle , $aFiles[1][0] )
FileDelete ($aFiles[1][0])
;;MsgBox (0 , "Duplicate ZFDAgentLog Deletion" , $aFiles[1][0] & " would be deleted" )
EndIf

If IsString ($aFiles[2][0]) Then
FileWriteLine ($AgentCheckOutputFileHandle , $aFiles[2][0] )
FileDelete ($aFiles[2][0])
; MsgBox (0 , "Duplicate ZFDAgentLog Deletion" , $aFiles[2][0] & " would be deleted" )
EndIf

Next

FileClose ($AgentCheckOutputFileHandle)

FileMove ($ResultsPath & $AgentCheckOutputFile , $ResultsPath & "deletions_" & $logdate & "_" & $logtime & ".csv" )

$agentchecksheetname = "deletions_" & $logdate & "_" & $logtime

$AgentCheckOutputFileLive = FileGetLongName ($ResultsPath & "deletions_" & $logdate & "_" & $logtime & ".csv")

$aAgentDeletionsLoad = _FileReadToArray ($AgentCheckOutputFileLive, $aAgentDeletions)

If $aAgentDeletionsLoad = 0 And @error = 2 Then
$DupeCount = 1
Else
$DupeCount = $aAgentDeletions[0]
EndIf

EndFunc

; Comparison Functions

Func WSCompare ()

; Clean up the output files
If FileExists ( $ResultsPath & $NotRegisteredFile ) Then
FileDelete ( $ResultsPath & $NotRegisteredFile )
EndIf

If FileExists ( $ResultsPath & $NotSeenFile ) Then
FileDelete ( $ResultsPath & $NotSeenFile )
EndIf

If FileExists ( $ResultsPath & $RegisteredFile ) Then
FileDelete ( $RegisteredFile )
EndIf

If FileExists ( $ResultsPath & $SeenFile ) Then
FileDelete ( $SeenFile )
EndIf

; Clean the eDirectory data
FileOpen ($eDirWorkstationsFile , 1 )
For $i = 1 To $aeDirWorkstations[0]
$aDetails = StringSplit ($aeDirWorkstations[$i] , ",")
If $aDetails[0]=2 Then
FileWriteLine ($eDirWorkstationsFile , $aDetails[2])
EndIf
Next
FileClose ($eDirWorkstationsFile)
_FileReadToArray ($eDirWorkstationsFile , $aeDirWorkstations2 )
$aeDirWorkstationsClean = _ArrayUnique ($aeDirWorkstations2 )

; Clean the Agent Check data

For $k=1 To $aCheckList2[0]
$aCheckList2[$k] = StringTrimRight ($aChecklist2[$k] , 4 )
Next

_FileWriteFromArray ($workpath & "\AgentUnique.csv" , $aCheckList2 , 2)
_FileWriteFromArray ($workpath & "\eDirUnique.csv" , $aeDirWorkstationsClean , 2)

; Show results

; _ArrayDisplay ($aCheckList2 , "AgentCheck List" )
; _ArrayDisplay ($aeDirWorkstationsClean , "eDirectory List" )

_FileReadToArray ($workpath & "\AgentUnique.csv" , $aAgentUnique )
_FileReadToArray ($workpath & "\eDirUnique.csv" , $aEdirUnique )





;Open the results file
$NotRegistered = FileOpen ( $ResultsPath & $NotRegisteredFile , 1 )
$Registered = FileOpen ( $ResultsPath & $RegisteredFile , 1 )

; Perform the check

For $i = 1 To $aAgentUnique[0]
_ArraySearch ( $aEdirUnique , $aAgentUnique[$i] , 1 , $aEdirUnique[0] , 0 , 0 )
If @error = 6 Then
FileWriteLine ( $NotRegistered , $aAgentUnique[$i] )
Else
FileWriteLine ($Registered , $aAgentUnique[$i] )
EndIf
Next

; Close the log files
FileClose ( $NotRegistered )
FileClose ( $Registered )

; Now we repeat the process in the reverse order to identify workstations in eDirectory that have not run the agent check

; Open the second logfile
$NotSeen = FileOpen ( $ResultsPath & $NotSeenFile , 1 )
$Seen = FileOpen ( $ResultsPath & $SeenFile , 1 )

For $i = 1 To $aeDirUnique[0]
_ArraySearch ( $aAgentUnique , $aEdirUnique[$i] , 1 , $aAgentUnique[0] , 0 , 0 )
If @error = 6 Then
FileWriteLine ( $NotSeen , $aEdirUnique[$i] )
Else
FileWriteLine ( $Seen , $aEdirUnique[$i] )
EndIf
Next

; Close the log files
FileClose ( $NotSeen )
FileClose ( $Seen )

; Rename the log files
FileMove ($ResultsPath & $NotSeenFile , $ResultsPath & "notseen_" & $logdate & "_" & $logtime & ".csv" )
FileMove ($ResultsPath & $SeenFile , $ResultsPath & "seen_" & $logdate & "_" & $logtime & ".csv" )
FileMove ($ResultsPath & $NotRegisteredFile , $ResultsPath & "notregistered_" & $logdate & "_" & $logtime & ".csv" )
FileMove ($ResultsPath & $RegisteredFile , $ResultsPath & "registered_" & $logdate & "_" & $logtime & ".csv" )

$notseensheetname = "notseen_" & $logdate & "_" & $logtime
$seensheetname = "seen_" & $logdate & "_" & $logtime
$notregisteredsheetname = "notregistered_" & $logdate & "_" & $logtime
$registeredsheetname = "registered_" & $logdate & "_" & $logtime

$NotSeenLogLive = FileGetLongName ( $ResultsPath & "notseen_" & $logdate & "_" & $logtime & ".csv" )
$SeenLogLive = FileGetLongName ( $ResultsPath & "seen_" & $logdate & "_" & $logtime & ".csv" )
$NotRegisteredLogLive = FileGetLongName ( $ResultsPath & "notregistered_" & $logdate & "_" & $logtime & ".csv" )
$RegisteredLogLive = FileGetLongName ( $ResultsPath & "registered_" & $logdate & "_" & $logtime & ".csv" )

; Now we check that the numbers match

; Load the results files into arrays

$Load3 = _FileReadToArray ( $NotRegisteredLogLive , $aNotRegistered )

$Load4 = _FileReadToArray ( $NotSeenLogLive , $aNotSeen )

$Load5 = _FileReadToArray ( $RegisteredLogLive , $aRegistered )

$Load6 = _FileReadToArray ( $SeenLogLive , $aSeen )

EndFunc

; Result GUIs

Func EdirNameReport ()

$eDirResultWindow = GUICreate ( $strTitle, 800 , 600, $strWidth/2-400, $strHeight/2-300 )
GUISetBkColor(0xFFFFFF)
GUISetIcon(@SystemDir & "\sysdm.cpl", 0)

GUICtrlCreatePic ( @ScriptDir & "\hcc_weblogo.gif", $strHeaderMarginLeft , $strHeaderMarginTop, 95, 61 )
GUISetFont ( 12, 800, 0, $Font )
GUICtrlCreateLabel ( "HCC Workstations", $strHeaderMarginLeft*2 + 95, $strHeaderMarginTop + 10 )
GUISetFont ( 10, 400, 0, $Font )
GUICtrlCreateLabel ( "Analysis of eDirectory and ZfDAgentCheck reports", $strHeaderMarginLeft*2 + 95, $strHeaderMarginTop + 10 + 25 )
GUICtrlCreatePic ( @ScriptDir & "\header_home_image.gif", 800 - $strHeaderMarginLeft - 354 , 0, 354, 100 )
GUICtrlCreateLabel ( "", $strHeaderMarginLeft, 94, 800 - $strHeaderMarginLeft - $strHeaderMarginRight - 354, 6 )
GUICtrlSetBkColor(-1,0xADBE10)

GUISetFont ( 8.5, 400, 0, $font )
GUICtrlCreateLabel ( $strDisplayDate , 800 - $strHeaderMarginLeft - 80, 80, 80, 20, $SS_CENTER )
GUICtrlSetBkColor(-1,0xADBE10)
;GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1,0xFFFFFF)

; GUI Header Labels
GUISetFont ( 12, 800, 0, $Font )
GUICtrlCreateLabel ( "Results of eDirectory Workstation Analysis", 20, 115, 700, 20 )

GUICtrlCreatePic ( @ScriptDir & "\askus.jpg", 800 - $strSercoMarginRight - 150, 600 - $strSercoMarginBottom - 150 - 33 - 16 - 20, 150, 150 )
GUICtrlCreatePic ( @ScriptDir & "\sercologo_tcm3-13101.jpg", 800 - $strSercoMarginRight - 106, 600 - $strSercoMarginBottom - 33 - 16, 106, 33 )
GUICtrlCreatePic ( @ScriptDir & "\strapline_tcm3-13100.gif", 800 - $strSercoMarginRight - 152, 600 - $strSercoMarginBottom - 16, 152, 16 )

GUISetFont (10 , 400, 0 , $Font )
$eDirRightText = GUICtrlCreateLabel ($aRightName[0]-1 & " workstations in edirectory have the correct name" , 20 ,165 ,450 )
$eDirRightButton = GUICtrlCreateButton ("View in Excel" , 650, 165, 100)
GUICtrlSetBkColor (-1, 0xADBE10)


$eDirWrongText = GUICtrlCreateLabel ($aWrongName[0] - 1 & " workstations in eDirectory have the wrong name" , 20 , 215 , 450 )
$eDirWrongButton = GUICtrlCreateButton ("View in Excel" , 650 ,215 ,100 )
GUICtrlSetBkColor (-1, 0xADBE10)


$eDirNoNameText = GUICtrlCreateLabel ($aNoName[0] - 1 & " workstations in eDirectory have no wMNAMEComputer attribute" , 20 ,265 ,450 )
$eDirNonameButton = GUICtrlCreateButton ("View in Excel" , 650 , 265 , 100 )
GUICtrlSetBkColor (-1, 0xADBE10)

$EdirAllFilesButton = GUICtrlCreateButton ("View all in Excel" , 20 ,315 ,180 )
GUICtrlSetBkColor (-1, 0xADBE10)

$EdirClosebutton = GUICtrlCreateButton ("Close" , 20 ,365, 180 )
GUICtrlSetBkColor (-1, 0xADBE10)

GUISetState (@SW_SHOW)

EndFunc

Func AgentCheckReport()
$AgentResultWindow = GUICreate ( $strTitle, 800 , 600, $strWidth/2-400, $strHeight/2-300 )
GUISetBkColor(0xFFFFFF)
GUISetIcon(@SystemDir & "\sysdm.cpl", 0)

GUICtrlCreatePic ( @ScriptDir & "\hcc_weblogo.gif", $strHeaderMarginLeft , $strHeaderMarginTop, 95, 61 )
GUISetFont ( 12, 800, 0, $Font )
GUICtrlCreateLabel ( "HCC Workstations", $strHeaderMarginLeft*2 + 95, $strHeaderMarginTop + 10 )
GUISetFont ( 10, 400, 0, $Font )
GUICtrlCreateLabel ( "Analysis of eDirectory and ZfDAgentCheck reports", $strHeaderMarginLeft*2 + 95, $strHeaderMarginTop + 10 + 25 )

GUICtrlCreatePic ( @ScriptDir & "\header_home_image.gif", 800 - $strHeaderMarginLeft - 354 , 0, 354, 100 )
GUICtrlCreateLabel ( "", $strHeaderMarginLeft, 94, 800 - $strHeaderMarginLeft - $strHeaderMarginRight - 354, 6 )
GUICtrlSetBkColor(-1,0xADBE10)

GUISetFont ( 8.5, 400, 0, $font )
GUICtrlCreateLabel ( $strDisplayDate , 800 - $strHeaderMarginLeft - 80, 80, 80, 20, $SS_CENTER )
GUICtrlSetBkColor(-1,0xADBE10)
;GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1,0xFFFFFF)

; GUI Header Labels
GUISetFont ( 12, 800, 0, $Font )
GUICtrlCreateLabel ( "Results of Agent Check run analysis", 20, 115, 700, 20 )

GUICtrlCreatePic ( @ScriptDir & "\askus.jpg", 800 - $strSercoMarginRight - 150, 600 - $strSercoMarginBottom - 150 - 33 - 16 - 20, 150, 150 )
GUICtrlCreatePic ( @ScriptDir & "\sercologo_tcm3-13101.jpg", 800 - $strSercoMarginRight - 106, 600 - $strSercoMarginBottom - 33 - 16, 106, 33 )
GUICtrlCreatePic ( @ScriptDir & "\strapline_tcm3-13100.gif", 800 - $strSercoMarginRight - 152, 600 - $strSercoMarginBottom - 16, 152, 16 )

GUISetFont (10 , 400, 0 , $Font )
$eAgentCheckText = GUICtrlCreateLabel ($DupeCount & " Agent Check log files have been deleted" , 20 ,165 ,450 )
If $DupeCount > 0 Then
$eAgentCheckButton = GUICtrlCreateButton ("View in Excel" , 650, 165, 100)
GUICtrlSetBkColor (-1, 0xADBE10)
EndIf

$eAgentCheckClosebutton = GUICtrlCreateButton ("Close" , 20 ,215, 180 )
GUICtrlSetBkColor (-1, 0xADBE10)

GUISetState (@SW_SHOW)

EndFunc

Func ComparisonReport ()

$ComparisonResultWindow = GUICreate ( $strTitle, 800 , 600, $strWidth/2-400, $strHeight/2-300 )
GUISetBkColor(0xFFFFFF)
GUISetIcon(@SystemDir & "\sysdm.cpl", 0)

GUICtrlCreatePic ( @ScriptDir & "\hcc_weblogo.gif", $strHeaderMarginLeft , $strHeaderMarginTop, 95, 61 )
GUISetFont ( 12, 800, 0, $Font )
GUICtrlCreateLabel ( "HCC Workstations", $strHeaderMarginLeft*2 + 95, $strHeaderMarginTop + 10 )
GUISetFont ( 10, 400, 0, $Font )
GUICtrlCreateLabel ( "Analysis of eDirectory and ZfDAgentCheck reports", $strHeaderMarginLeft*2 + 95, $strHeaderMarginTop + 10 + 25 )

GUICtrlCreatePic ( @ScriptDir & "\header_home_image.gif", 800 - $strHeaderMarginLeft - 354 , 0, 354, 100 )
GUICtrlCreateLabel ( "", $strHeaderMarginLeft, 94, 800 - $strHeaderMarginLeft - $strHeaderMarginRight - 354, 6 )
GUICtrlSetBkColor(-1,0xADBE10)

GUISetFont ( 8.5, 400, 0, $font )
GUICtrlCreateLabel ( $strDisplayDate , 800 - $strHeaderMarginLeft - 80, 80, 80, 20, $SS_CENTER )
GUICtrlSetBkColor(-1,0xADBE10)
;GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1,0xFFFFFF)

; GUI Header Labels
GUISetFont ( 12, 800, 0, $Font )
GUICtrlCreateLabel ( "Results of eDirectory and Agent Check Comparison", 20, 115, 700, 20 )

GUICtrlCreatePic ( @ScriptDir & "\askus.jpg", 800 - $strSercoMarginRight - 150, 600 - $strSercoMarginBottom - 150 - 33 - 16 - 20, 150, 150 )
GUICtrlCreatePic ( @ScriptDir & "\sercologo_tcm3-13101.jpg", 800 - $strSercoMarginRight - 106, 600 - $strSercoMarginBottom - 33 - 16, 106, 33 )
GUICtrlCreatePic ( @ScriptDir & "\strapline_tcm3-13100.gif", 800 - $strSercoMarginRight - 152, 600 - $strSercoMarginBottom - 16, 152, 16 )

GUISetFont (10 , 400, 0 , $Font )
$eAgentCheckText = GUICtrlCreateLabel ($aAgentUnique[0] & " workstations have run the Agent Check" , 20 ,165 ,450 )
$eAgentCheckButton = GUICtrlCreateButton ("View in Excel" , 650, 165, 100)
GUICtrlSetBkColor (-1, 0xADBE10)


$eDirRegText = GUICtrlCreateLabel ($aeDirUnique[0] & " workstations (with NETBIOS names) are registered in eDirectory" , 20 , 215 , 450 )
$eDirRegButton = GUICtrlCreateButton ("View in Excel" , 650 ,215 ,100 )
GUICtrlSetBkColor (-1, 0xADBE10)


$NotSeenText = GUICtrlCreateLabel ($aNotSeen[0] & " workstations in eDirectory have not run ZFDAgentCheck" , 20 ,265 ,450 )
$NotSeenButton = GUICtrlCreateButton ("View in Excel" , 650 , 265 , 100 )
GUICtrlSetBkColor (-1, 0xADBE10)

$NotRegisteredText = GUICtrlCreateLabel ($aNotRegistered[0] & " workstations have run ZFDAgentCheck but are not in eDirectory" , 20 , 315 , 450 )
$NotRegisteredButton = GUICtrlCreateButton ("View in Excel" , 650 ,315 ,100 )
GUICtrlSetBkColor (-1, 0xADBE10)

$ComparisonAllFilesButton = GUICtrlCreateButton ("View all in Excel" , 20 ,365 ,180 )
GUICtrlSetBkColor (-1, 0xADBE10)

$ComparisonClosebutton = GUICtrlCreateButton ("Close" , 20 ,415, 180 )
GUICtrlSetBkColor (-1, 0xADBE10)

GUISetState (@SW_SHOW)

EndFunc

Func AllReport ()
$AllResultsWindow = GUICreate ( $strTitle, 800 , 600, $strWidth/2-400, $strHeight/2-300 )
GUISetBkColor(0xFFFFFF)
GUISetIcon(@SystemDir & "\sysdm.cpl", 0)

GUICtrlCreatePic ( @ScriptDir & "\hcc_weblogo.gif", $strHeaderMarginLeft , $strHeaderMarginTop, 95, 61 )
GUISetFont ( 12, 800, 0, $Font )
GUICtrlCreateLabel ( "HCC Workstations", $strHeaderMarginLeft*2 + 95, $strHeaderMarginTop + 10 )
GUISetFont ( 10, 400, 0, $Font )
GUICtrlCreateLabel ( "Analysis of eDirectory and ZfDAgentCheck reports", $strHeaderMarginLeft*2 + 95, $strHeaderMarginTop + 10 + 25 )

GUICtrlCreatePic ( @ScriptDir & "\header_home_image.gif", 800 - $strHeaderMarginLeft - 354 , 0, 354, 100 )
GUICtrlCreateLabel ( "", $strHeaderMarginLeft, 94, 800 - $strHeaderMarginLeft - $strHeaderMarginRight - 354, 6 )
GUICtrlSetBkColor(-1,0xADBE10)

GUISetFont ( 8.5, 400, 0, $font )
GUICtrlCreateLabel ( $strDisplayDate , 800 - $strHeaderMarginLeft - 80, 80, 80, 20, $SS_CENTER )
GUICtrlSetBkColor(-1,0xADBE10)
;GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1,0xFFFFFF)

; GUI Header Labels
GUISetFont ( 12, 800, 0, $Font )
GUICtrlCreateLabel ( "Choose an option to view results", 20, 115, 700, 20 )

GUICtrlCreatePic ( @ScriptDir & "\askus.jpg", 800 - $strSercoMarginRight - 150, 600 - $strSercoMarginBottom - 150 - 33 - 16 - 20, 150, 150 )
GUICtrlCreatePic ( @ScriptDir & "\sercologo_tcm3-13101.jpg", 800 - $strSercoMarginRight - 106, 600 - $strSercoMarginBottom - 33 - 16, 106, 33 )
GUICtrlCreatePic ( @ScriptDir & "\strapline_tcm3-13100.gif", 800 - $strSercoMarginRight - 152, 600 - $strSercoMarginBottom - 16, 152, 16 )

GUISetFont (10 , 400, 0 , $Font )

$AllEdirectoryButton = GUICtrlCreateButton ("View eDirectory Results" , 20 ,165 ,180 )
GUICtrlSetBkColor (-1, 0xADBE10)

$AllAgentCheckButton = GUICtrlCreateButton ("View Agent Check Results" , 20 ,215 ,180 )
GUICtrlSetBkColor (-1, 0xADBE10)

$AllComparisonButton = GUICtrlCreateButton ("View Comparison Results" , 20 ,265 ,180 )
GUICtrlSetBkColor (-1, 0xADBE10)

$AllClosebutton = GUICtrlCreateButton ("Close" , 20 ,315, 180 )
GUICtrlSetBkColor (-1, 0xADBE10)

GUISetState (@SW_SHOW)

EndFunc

; Report Display Functions

Func LoadEdirRightFile()
$oExcel = ObjCreate ("Excel.Application")
With $oExcel
.Visible=1
.WorkBooks.Open($RightLogLive)
.Worksheets($rightsheetname).Columns("A:B").AutoFit
EndWith
EndFunc

Func LoadEdirWrongFile()
$oExcel = ObjCreate ("Excel.Application")
With $oExcel
.Visible=1
.WorkBooks.Open($WrongLogLive)
.Worksheets($wrongsheetname).Columns("A:B").AutoFit
EndWith
EndFunc

Func LoadEdirNoFile ()
$oExcel = ObjCreate ("Excel.Application")
With $oExcel
.Visible=1
.WorkBooks.Open($NoNameLogLive)
.Worksheets($nosheetname).Columns("A:B").AutoFit
EndWith
EndFunc

Func LoadAllEdirFiles()
LoadEdirRightFile ()
LoadEdirWrongFile ()
LoadEdirNoFile ()
EndFunc

Func LoadComparisonAgentFile ()
$oExcel = ObjCreate ("Excel.Application")
With $oExcel
.Visible=1
.WorkBooks.Open($SeenLogLive)
.Worksheets($seensheetname).Columns("A").AutoFit
EndWith
EndFunc

Func LoadComparisonEdirFile ()
$oExcel = ObjCreate ("Excel.Application")
With $oExcel
.Visible=1
.WorkBooks.Open($RegisteredLogLive)
.Worksheets($registeredsheetname).Columns("A").AutoFit
EndWith
EndFunc

Func LoadComparisonNotSeenFile ()
$oExcel = ObjCreate ("Excel.Application")
With $oExcel
.Visible=1
.WorkBooks.Open($NotSeenLogLive)
.Worksheets($notregisteredsheetname).Columns("A").AutoFit
EndWith
EndFunc

Func LoadComparisonNotRegisteredFile ()
$oExcel = ObjCreate ("Excel.Application")
With $oExcel
.Visible=1
.WorkBooks.Open($NotRegisteredLogLive)
.Worksheets($notregisteredsheetname).Columns("A").AutoFit
EndWith
EndFunc

Func LoadComparisonAll ()
LoadComparisonEdirFile ()
LoadComparisonAgentFile ()
LoadComparisonNotRegisteredFile ()
LoadComparisonNotSeenFile ()
EndFunc

Func LoadAgentCheckResultsFile()
$oExcel = ObjCreate ("Excel.Application")
With $oExcel
.Visible=1
.WorkBooks.Open($AgentCheckOutputFileLive)
.Worksheets($agentchecksheetname).Columns("A").AutoFit
EndWith
EndFunc

; Progress Functions - These display during processing

Func Progress ()
$Progresstext = GUICtrlCreateLabel (" Please wait, processing" , 250 , 180 )
$Progressicon = GUICtrlCreateAvi (@ScriptDir & "\progress.avi" , 0 , 500 , 165 )
GUICtrlSetState ($Progressicon , $GUI_AVISTART )
$CoffeeLabel = GUICtrlCreateLabel ("This will take a few moments," & @LF & "please wait." , 250 ,220 )
EndFunc

Func SlowProgress ()
$Progresstext = GUICtrlCreateLabel (" Please wait, processing" , 250 , 180 )
$Progressicon = GUICtrlCreateAvi (@ScriptDir & "\progress.avi" , 0 , 500 , 165 )
GUICtrlSetState ($Progressicon , $GUI_AVISTART )
$CoffeeLabel = GUICtrlCreateLabel ("This will take some time," & @LF & "so go get a coffee!" , 250 ,220 )
$CoffeeIcon2 = GUICtrlCreatePic (@scriptdir & "\Coffee_Cup_Icon_clip_art_medium.jpg" ,250, 270 ,0 ,0 )
EndFunc

Func VerySlowProgress ()
$Progresstext = GUICtrlCreateLabel (" Please wait, processing" , 250 , 180 )
$Progressicon = GUICtrlCreateAvi (@ScriptDir & "\progress.avi" , 0 , 500 , 165 )
GUICtrlSetState ($Progressicon , $GUI_AVISTART )
$CoffeeLabel = GUICtrlCreateLabel ("This will take a long time," & @LF & "maybe two coffees!" , 250 ,220 )
$CoffeeIcon = GUICtrlCreatePic (@scriptdir & "\Coffee_Cup_Icon_clip_art_medium.jpg" ,250, 270 ,0 ,0 )
EndFunc



Func EndProgress ()
GUICtrlDelete ($Progresstext)
GUICtrlDelete ($Progressicon)
GUICtrlDelete ($CoffeeLabel)
EndFunc

Func EndSlowProgress ()
GUICtrlDelete ($Progresstext)
GUICtrlDelete ($Progressicon)
GUICtrlDelete ($CoffeeLabel)
GUICtrlDelete ($CoffeeIcon)
EndFunc

Func EndVerySlowProgress ()
GUICtrlDelete ($Progresstext)
GUICtrlDelete ($Progressicon)
GUICtrlDelete ($CoffeeLabel)
GUICtrlDelete ($CoffeeIcon)
EndFunc

; Cleanup Function

Func Cleanup () ; Cleans up and backs up files from a previous run

If FileExists ($workpath & "cleanexport.txt") Then
FileDelete ($workpath & "cleanexport.txt")
EndIf

If FileExists ($workpath & "export.txt") Then
FileDelete ($workpath & "export.txt")
EndIf

If FileExists ($ResultsPath & $RightNameFile) Then
FileDelete ($ResultsPath & $RightNameFile)
EndIf

If FileExists ($ResultsPath & $WrongNameFile) Then
FileDelete ($ResultsPath & $WrongNameFile)
EndIf

If FileExists ( $ResultsPath & $NotRegisteredFile ) Then
FileDelete ( $ResultsPath & $NotRegisteredFile )
EndIf

If FileExists ( $ResultsPath & $NotSeenFile ) Then
FileDelete ( $ResultsPath & $NotSeenFile )
EndIf

If FileExists ( $eDirWorkstationsFile ) Then
FileDelete ( $eDirWorkstationsFile )
EndIf

If FileExists ( $ResultsPath & $RegisteredFile ) Then
FileDelete ( $RegisteredFile )
EndIf

If FileExists ( $ResultsPath & $SeenFile ) Then
FileDelete ( $SeenFile )
EndIf


EndFunc

Share this post


Link to post
Share on other sites

Check if this kind of error checking helps you

Move the includes to the top of the script if they are already not there

#include-once
#include <WinAPI.au3> ;Move to the top of the script
#include <StructureConstants.au3> ;Move to the top of the script


Func EdirNameReport()

$eDirResultWindow = GUICreate($strTitle, 800, 600, $strWidth / 2 - 400, $strHeight / 2 - 300)
GUISetBkColor(0xFFFFFF)
If Not GUISetIcon(@SystemDir & "\sysdm.cpl", 0) Then Exit MsgBox( 16, "Error", "Error Setting Icon" ) <> 1

If Not GUICtrlCreatePic(@ScriptDir & "\hcc_weblogo.gif", $strHeaderMarginLeft, $strHeaderMarginTop, 95, 61) Then Exit MsgBox( 16, "Error", "Error Setting Picture" ) <> 1
If PtNotInRect( $eDirResultWindow, $strHeaderMarginLeft, $strHeaderMarginTop )  Then Exit MsgBox( 16, "Error", "Pic not inside window" ) <> 1
If Not GUISetFont(12, 800, 0, $Font) Then Exit MsgBox( 16, "Error", "Error Setting Font" ) <> 1
If Not GUICtrlCreateLabel("HCC Workstations", $strHeaderMarginLeft * 2 + 95, $strHeaderMarginTop + 10) Then Exit MsgBox( 16, "Error", "Error Setting Label" ) <> 1
If PtNotInRect( $eDirResultWindow, $strHeaderMarginLeft * 2 + 95, $strHeaderMarginTop + 10 )  Then Exit MsgBox( 16, "Error", "Label not inside window" ) <> 1

If Not GUISetFont(10, 400, 0, $Font) Then Exit MsgBox( 16, "Error", "Error Setting Font2" ) <> 1
If Not GUICtrlCreateLabel("Analysis of eDirectory and ZfDAgentCheck reports", $strHeaderMarginLeft * 2 + 95, $strHeaderMarginTop + 10 + 25) Then Exit MsgBox( 16, "Error", "Error Setting Label2" ) <> 1
If PtNotInRect( $eDirResultWindow, $strHeaderMarginLeft * 2 + 95, $strHeaderMarginTop + 10 + 25)  Then Exit MsgBox( 16, "Error", "Label2 not inside window" ) <> 1
If Not GUICtrlCreatePic(@ScriptDir & "\header_home_image.gif", 800 - $strHeaderMarginLeft - 354, 0, 354, 100) Then Exit MsgBox( 16, "Error", "Error Setting Picture2" ) <> 1
If PtNotInRect( $eDirResultWindow, 800 - $strHeaderMarginLeft - 354, 0 )  Then Exit MsgBox( 16, "Error", "Pic2 not inside window" ) <> 1
If Not GUICtrlCreateLabel("", $strHeaderMarginLeft, 94, 800 - $strHeaderMarginLeft - $strHeaderMarginRight - 354, 6) Then Exit MsgBox( 16, "Error", "Error Setting Label3" ) <> 1
GUICtrlSetBkColor(-1, 0xADBE10)

GUISetFont(8.5, 400, 0, $Font)
If Not GUICtrlCreateLabel($strDisplayDate, 800 - $strHeaderMarginLeft - 80, 80, 80, 20, $SS_CENTER) Then Exit MsgBox( 16, "Error", "Error Setting Label4" ) <> 1
If PtNotInRect( $eDirResultWindow, 800 - $strHeaderMarginLeft - 80)  Then Exit MsgBox( 16, "Error", "Label4 not inside window" ) <> 1
If Not GUICtrlSetBkColor(-1, 0xADBE10) Then Exit MsgBox( 16, "Error", "Error Setting Label4's BkColor" ) <> 1
GUICtrlSetColor(-1, 0xFFFFFF)
GUISetState(@SW_SHOW)

EndFunc   ;==>EdirNameReport

Func PtNotInRect( $hGUI, $x, $y )
Local $tPoint = DllStructCreate( $tagPOINT )
Local $aPos = WinGetPos( $hGUI )
DllStructSetData( $tPoint, 1, $x )
DllStructSetData( $tPoint, 2, $y )
Local $tRect =  DllStructCreate( $tagRECT )
DllStructSetData( $tRect, 1, $aPos[0] )
DllStructSetData( $tRect, 2, $aPos[1] )
DllStructSetData( $tRect, 3, $aPos[0] + $aPos[2] )
DllStructSetData( $tRect, 4, $aPos[1] + $aPos[3] )

Return _WinAPI_PtInRect($tRect, $tPoint ) = False
EndFunc

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

Hi PhoenixXL,

That is really useful. It tells me that the controls are created, but not in the window. Now to work out why!

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
Sign in to follow this  
Followers 0