Jump to content



Photo

_Log() - Create a log file that can be displayed in a GUI just like _ArrayDisplay with icons and a contextmenu.


  • Please log in to reply
6 replies to this topic

#1 guinness

guinness

    guinness

  • MVPs
  • 10,299 posts

Posted 06 June 2011 - 01:29 PM

The UDF was created because I wanted a log function in which I could then display the log file in a small custom GUI to the end user, so this is what I came up with. Data is written to the log file, the same as you would do with _FileWriteLog() and then can be displayed by simply calling _Log_Display(), it couldn't be easier than that.

The data is written to the log file in a standard CSV format and for this I would like to show my gratitude to ProgAndy for the idea of parsing the CSV data to an array.

Note: The language strings are written in English, but it isn't hard to change these in the UDF.

I also wanted to improve my coding technique :huh2:

Any suggestions post below. Thanks.

UDF:
AutoIt         
#include-once ; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 ; #INDEX# ======================================================================================================================= ; Title .........: _Log ; AutoIt Version : v3.3.2.0 or higher ; Language ......: English ; Description ...: Create a log file that can be displayed in a GUI just like _ArrayDisplay with icons and a contextmenu. ; Note ..........: ; Author(s) .....: guinness ; Remarks .......: ; =============================================================================================================================== ; #INCLUDES# ========================================================================================================= #include <GUIConstantsEx.au3> #include <GUIImageList.au3> #include <GUIListView.au3> #include <GUIMenu.au3> #include <GUIStatusBar.au3> #include <WindowsConstants.au3> ; #GLOBAL VARIABLES# ================================================================================================= Global $__Log_Array[2] = [-1, -1], $__Log_Clear, $__Log_Copy, $__Log_ListView, $__Log_Refresh, $__Log_StatusBar ; #CURRENT# ===================================================================================================================== ; _Log_Display: Display a log file in a GUI that is currently open using the function _Log_Startup(). ; _Log_Error: Write an error line to the log file that is currently open using the function _Log_Startup(). ; _Log_Shutdown: Closes a log file that is currently open using the function _Log_Startup(). ; _Log_Startup: Open a log file to be used as default throught function calls, unless specified otherwise. ; _Log_Write: Write a line to the log file that is currently open using the function _Log_Startup(). ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#============================================================================================================ ; __Log_Get ......; Parse a log file to an array. Thanks to ProgAndy for the SRE's. ; __Log_GUICtrlListView_ContextMenu ......; Displays a rightclick contextmenu on the _Log_Display listview. ; __Log_GUICtrlListView_Refresh ......; Refresh the _Log_Display listview. ; __Log_Reduce ......; Reduce the log file to a maximum filesize of 3 MB. ; __Log_Startup ......; Open a log file to be used as default throught function calls, unless specified otherwise. Internal use only. ; __Log_WM_NOTIFY ......; Intercept mouseclicks from the _Log_Display listview. ; __Log_WM_SIZE ......; Intercept sizing from the _Log_Display GUI. ; =============================================================================================================================== ; #FUNCTION# ========================================================================================================= ; Name...........: _Log_Display() ; Description ...: Display a log file in a GUI that is currently open using the function _Log_Startup(). ; Syntax.........: _Log_Display([$hHandle = -1]) ; Parameters ....: $hHandle - [Optional] Handle of the previously called GUI. [Default = 0 - none.] ; Requirement(s).: v3.3.2.0 or higher ; Return values .: Success - Returns log filename. ;                  none ; Author ........: guinness ; Example........; Yes ; Remarks........; _Log_Display() supports the following hotkeys, F5 to refresh the listview & DEL to clear the log file (& listview.) There's also a righclick contextmenu ;                  where additional commands to manipulate the display can be found - Copy, Delete & Refresh. ;===================================================================================================================== Func _Log_Display($hHandle = -1)     Local $hGUI, $hImageList, $hListView, $hStatusBar, $iColumns, $iListView     Local $aIndex, $aStringSplit, $sFile = $__Log_Array[0], $sReturn, $sStringInStr = "<"     Local $iWidth = 500, $iHeight = 300     Local $aParts[1] = [$iWidth], $aStatusBar[1] = ["Welcome to Log: Display"]     If IsHWnd($hHandle) = 0 Then         $hHandle = 0     EndIf     $hGUI = GUICreate("Welcome to Log: Display", $iWidth, $iHeight, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_MINIMIZEBOX), -1, $hHandle)     $iListView = GUICtrlCreateListView("", 0, 0, $iWidth, $iHeight - 22)     $hListView = GUICtrlGetHandle(-1)     $__Log_ListView = $hListView     GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)     $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aParts, $aStatusBar)     $__Log_StatusBar = $hStatusBar     $hImageList = _GUIImageList_Create(16, 16, 5, 3)     _GUIImageList_AddIcon($hImageList, @SystemDir & "\shell32.dll", 1)     _GUIImageList_AddIcon($hImageList, @SystemDir & "\shell32.dll", -161)     _GUICtrlListView_SetImageList($hListView, $hImageList, 1)     _Log_Shutdown()     __Log_GUICtrlListView_Refresh($hListView, $sFile, $sStringInStr, 0)     $iColumns = @extended     __Log_Startup($sFile, 0, 0)     _GUICtrlListView_RegisterSortCallBack($iListView)     GUIRegisterMsg($WM_NOTIFY, "__Log_WM_NOTIFY")     GUIRegisterMsg($WM_SIZE, "__Log_WM_SIZE")     GUISetState(@SW_SHOW)     Local $iClear = GUICtrlCreateDummy(), $iCopy = GUICtrlCreateDummy(), $iRefresh = GUICtrlCreateDummy()     $__Log_Clear = $iClear     $__Log_Copy = $iCopy     $__Log_Refresh = $iRefresh     Local $aAcceleratorKeys[2][2] = [["{DEL}", $iClear],["{F5}", $iRefresh]]     GUISetAccelerators($aAcceleratorKeys, $hGUI)     While 1         Switch GUIGetMsg()             Case $GUI_EVENT_CLOSE                 _GUICtrlListView_UnRegisterSortCallBack($__Log_ListView)                 GUIDelete($hGUI)                 ExitLoop             Case $iClear                 _GUICtrlListView_DeleteAllItems($hListView)                 _Log_Shutdown()                 __Log_Startup($sFile, 1, 0)                 _Log_Shutdown()                 __Log_Startup($sFile, 0, 1)                 _Log_Write("Log: Display", "Cleared & Restarted")                 _GUICtrlStatusBar_SetText($hStatusBar, "Log: Display was cleared.", 0)             Case $iCopy                 $sReturn = ""                 $aIndex = GUICtrlRead($iCopy)                 $aStringSplit = StringSplit($aIndex, "|", 2)                 If @error Then                     For $A = 0 To $iColumns - 1                         $sReturn &= _GUICtrlListView_GetItemText($hListView, $aIndex, $A) & ","                     Next                     $sReturn = StringTrimRight($sReturn, 1)                 Else                     $sReturn = _GUICtrlListView_GetItemText($hListView, $aStringSplit[0], $aStringSplit[1])                 EndIf                 _GUICtrlStatusBar_SetText($hStatusBar, 'Copied "' & $sReturn & '" to the Clipboard.', 0)                 ClipPut($sReturn)             Case $iRefresh                 _Log_Shutdown()                 __Log_GUICtrlListView_Refresh($hListView, $sFile, $sStringInStr, 1)                 $iColumns = @extended                 __Log_Startup($sFile, 0, 0)                 _GUICtrlStatusBar_SetText($hStatusBar, "Log: Display was refreshed.", 0)         EndSwitch     WEnd     GUISwitch($hHandle)     Return $sFile EndFunc   ;==>_Log_Display ; #FUNCTION# ========================================================================================================= ; Name...........: _Log_Error() ; Description ...: Write an error line to the log file that is currently open using the function _Log_Startup(). ; Syntax.........: _Log_Error($sTitle, $sData, [$iStart = 0, [$iIndex = -1]]) ; Parameters ....: $sTitle - Title of the error message. ;                  $sData - Data of the error message, this can be a string or an array (1D/2D). ;                  $iStart - [Optional] If $sData is an array then you can specific the index of where to start. [Default = 0 - Index 0.] ;                  $iIndex - [Optional] If $sData is an array then you can either print a specific row or the whole array. [Default = -1 - Entire array.] ; Requirement(s).: v3.3.2.0 or higher ; Return values .: Success - Returns value from FileWriteLine. See Help File for more details. ;                  none ; Author ........: guinness ; Example........; Yes ; Remarks........; Arrays are merged into a single string, @ is used to distinguish between different rows and | is used for columns. So for example a 2D array with 2 rows and 2 columns ;                  would look like Column01|Column2@Column01|Column2. ;===================================================================================================================== Func _Log_Error($sTitle, $sData, $iStart = 0, $iIndex = -1)     Return _Log_Write($sTitle, "--@--" & $sData & "--@--", $iStart, $iIndex) EndFunc   ;==>_Log_Error ; #FUNCTION# ========================================================================================================= ; Name...........: _Log_IsOpen() ; Description ...: Checks whether a specifed file or currently opened log file is being used. ; Syntax.........: _Log_IsOpen([$sFile = -1]) ; Parameters ....: $sFile - [Optional] File to be checked that is open. [Default = -1 - File currently open using the function _Log_Startup().] ; Requirement(s).: v3.3.2.0 or higher ; Return values .: Success - Returns 0 ;                  Failure - Returns 1 ; Author ........: guinness ; Example........; Yes ;===================================================================================================================== Func _Log_IsOpen($sFile = -1)     If $sFile = -1 Then         $sFile = $__Log_Array[0]     EndIf     If $sFile = $__Log_Array[0] And $__Log_Array[1] > -1 Then         Return 1     EndIf     Return 0 EndFunc   ;==>_Log_IsOpen ; #FUNCTION# ========================================================================================================= ; Name...........: _Log_Shutdown() ; Description ...: Closes a log file that is currently open using the function _Log_Startup(). ; Syntax.........: _Log_Shutdown() ; Parameters ....: none ; Requirement(s).: v3.3.2.0 or higher ; Return values .: Success - Resets Global array to -1. ;                  none ; Author ........: guinness ; Example........; Yes ;===================================================================================================================== Func _Log_Shutdown()     Local $iClose = FileClose($__Log_Array[1])     $__Log_Array[0] = -1     $__Log_Array[1] = -1     Return $iClose EndFunc   ;==>_Log_Shutdown ; #FUNCTION# ========================================================================================================= ; Name...........: _Log_Startup() ; Description ...: Open a log file to be used as default throught function calls, unless specified otherwise. ; Syntax.........: _Log_Startup($sFile, [$iOverwrite = 0]) ; Parameters ....: $sFile - Log file to be used, ideally the extension should end with .log. ;                  $iOverwrite - [Optional] Destroy the log file data with blank data. [Default = 0 - append to the end of the log file.] ; Requirement(s).: v3.3.2.0 or higher ; Return values .: Success - Returns log filename. ;                  Failure - Returns log filename & sets @error = 1 ; Author ........: guinness ; Example........; Yes ;===================================================================================================================== Func _Log_Startup($sFile, $iOverwrite = 0)     $sFile = __Log_Startup($sFile, $iOverwrite, 1)     Return SetError(@error, 0, $sFile) EndFunc   ;==>_Log_Startup ; #FUNCTION# ========================================================================================================= ; Name...........: _Log_Write() ; Description ...: Write a line to the log file that is currently open using the function _Log_Startup(). ; Syntax.........: _Log_Write($sTitle, $sData, [$iStart = 0, [$iIndex = -1]]) ; Parameters ....: $sTitle - Title of the message. ;                  $sData - Data of the message, this can be a string or an array (1D/2D). ;                  $iStart - [Optional] If $sData is an array then you can specific the index of where to start. [Default = 0 - Index 0.] ;                  $iIndex - [Optional] If $sData is an array then you can either print a specific row or the whole array. [Default = -1 - Entire array.] ; Requirement(s).: v3.3.2.0 or higher ; Return values .: Success - Returns value from FileWriteLine. ;                  none ; Author ........: guinness ; Example........; Yes ; Remarks........; Arrays are merged into a single string, @ is used to distinguish between different rows and | is used for columns. So for example a 2D array with 2 rows and 2 columns ;                  would look like Column01|Column2@Column01|Column2. ;===================================================================================================================== Func _Log_Write($sTitle, $sData, $iStart = 0, $iIndex = -1)     Local $aArray = $sData, $aReturn[4] = [3, $sTitle, "Unknown", @HOUR & ":" & @MIN & ":" & @SEC], $iCount = 0, $sDelimiter = ",", $sQuote = '"', $sReturn     Local $iDimension, $iUbound, $iSubMax, $iItem     __Log_Reduce($__Log_Array[0]) ; Reduce Log File.     If IsArray($aArray) Then         $iDimension = UBound($aArray, 0)         $iUbound = UBound($aArray, 1) - 1         $iSubMax = UBound($aArray, 2) - 1         $sData = ""         If $iSubMax = -1 Then             $iSubMax = 0         EndIf         If $iStart < 0 Or $iStart > $iUbound Then             $iStart = 0         EndIf         If $iIndex < 0 Or $iIndex > $iUbound Then             $iIndex = $iSubMax         Else             $iCount = $iIndex         EndIf         For $A = $iStart To $iUbound             For $B = $iCount To $iIndex                 Switch $iDimension                     Case 1                         $iItem = $aArray[$A]                     Case 2                         $iItem = $aArray[$A][$B]                 EndSwitch                 $sData &= $iItem & "|"             Next             $sData = StringTrimRight($sData, 1) & "@" ; Remove "|"         Next         $sData = StringTrimRight($sData, 1) ; Remove "@"     EndIf     $aReturn[2] = $sData     For $A = 1 To $aReturn[0]         $sReturn &= $sQuote & StringReplace($aReturn[$A], $sQuote, $sQuote & $sQuote, 0, 1) & $sQuote         If $A < $aReturn[0] Then             $sReturn &= $sDelimiter         EndIf     Next     Return FileWriteLine($__Log_Array[1], $sReturn) EndFunc   ;==>_Log_Write ; #INTERNAL_USE_ONLY#============================================================================================================ Func __Log_Get($sFile)     Local $aResult[1][2] = [[0, 0]], $aStringRegExp, $hFileOpen, $iIndex = 1, $iSub = 0, $iSubUbound = 1, $sData, $sDelimiter = ",", $sPattern, $sQuote = '"', $sSREDelimiter, $sSREQuote     $hFileOpen = FileOpen($sFile, 0)     If $hFileOpen = -1 Then         Return SetError(1, 0, $aResult)     EndIf     $sData = FileRead($hFileOpen)     FileClose($hFileOpen)     $sSREDelimiter = StringRegExpReplace($sDelimiter, '[\\\^\-\[\]]', '\\\0')     $sSREQuote = StringRegExpReplace($sQuote, '[\\\^\-\[\]]', '\\\0')     $sPattern = StringReplace(StringReplace('(?m)(?:^|[,])\h*(["](?:[^"]|["]{2})*["]|[^,\r\n]*)(\v+)?', ',', $sSREDelimiter, 0, 1), '"', $sSREQuote, 0, 1)     $aStringRegExp = StringRegExp($sData, $sPattern, 3)     If @error Then         Return SetError(1, 0, $aResult)     EndIf     Local $iUbound = UBound($aStringRegExp)     Local $aResult[$iUbound + 1][$iSubUbound]     For $A = 0 To $iUbound - 1         If $iSub = $iSubUbound Then             $iSubUbound += 1             ReDim $aResult[$iUbound + 1][$iSubUbound]         EndIf         Select             Case StringLen($aStringRegExp[$A]) < 3 And StringInStr(@CRLF, $aStringRegExp[$A])                 $iIndex += 1                 $iSubUbound = $iSub                 $aResult[0][0] += 1                 $aResult[0][1] = $iSubUbound                 $iSub = 0                 ContinueLoop             Case StringLeft(StringStripWS($aStringRegExp[$A], 1), 1) = $sQuote                 $aStringRegExp[$A] = StringStripWS($aStringRegExp[$A], 3)                 $aResult[$iIndex][$iSub] = StringReplace(StringMid($aStringRegExp[$A], 2, StringLen($aStringRegExp[$A]) - 2), $sQuote & $sQuote, $sQuote, 0, 1)             Case Else                 $aResult[$iIndex][$iSub] = $aStringRegExp[$A]         EndSelect         $iSub += 1     Next     If $iIndex = 0 Then         $iIndex = 1         $iSubUbound = 0     EndIf     ReDim $aResult[$iIndex][$iSubUbound]     Return $aResult EndFunc   ;==>__Log_Get Func __Log_GUICtrlListView_ContextMenu($hListView, $iIndex, $iSubItem)     Local Enum $iContextItem1 = 1000, $iContextItem2, $iContextItem3, $iContextItem4     Local $hContextMenu     $hContextMenu = _GUICtrlMenu_CreatePopup()     _GUICtrlMenu_AddMenuItem($hContextMenu, "Refresh", $iContextItem1)     If _GUICtrlListView_GetItemCount($hListView) > 0 Then         _GUICtrlMenu_AddMenuItem($hContextMenu, "Clear Log", $iContextItem2)     EndIf     If $iIndex <> -1 And $iSubItem <> -1 Then         _GUICtrlMenu_AddMenuItem($hContextMenu, "")         _GUICtrlMenu_AddMenuItem($hContextMenu, "Copy Item", $iContextItem3)         _GUICtrlMenu_AddMenuItem($hContextMenu, "Copy Row", $iContextItem4)     EndIf     Switch _GUICtrlMenu_TrackPopupMenu($hContextMenu, $hListView, -1, -1, 1, 1, 2)         Case $iContextItem1             GUICtrlSendToDummy($__Log_Refresh, $iIndex & "|" & $iSubItem)         Case $iContextItem2             GUICtrlSendToDummy($__Log_Clear)         Case $iContextItem3             GUICtrlSendToDummy($__Log_Copy, $iIndex & "|" & $iSubItem)         Case $iContextItem4             GUICtrlSendToDummy($__Log_Copy, $iIndex)     EndSwitch     Return _GUICtrlMenu_DestroyMenu($hContextMenu) EndFunc   ;==>__Log_GUICtrlListView_ContextMenu Func __Log_GUICtrlListView_Refresh($hListView, $sFile, $sStringInStr, $iRefresh)     Local $aArray, $iImage = 0, $iIndex, $iCount = 0, $sHeader = -1     _GUICtrlListView_DeleteAllItems($hListView)     _GUICtrlListView_EnableGroupView($hListView, True)     $aArray = __Log_Get($sFile)     If $aArray[0][0] = 0 Then         Return SetError(1, 0, 0)     EndIf     If $iRefresh = 0 Then         For $A = 1 To $aArray[0][1]             _GUICtrlListView_InsertColumn($hListView, $A - 1, "Column " & $A, 100)         Next     EndIf     For $A = 1 To $aArray[0][0]         If $sHeader <> $aArray[$A][0] And StringInStr($aArray[$A][0], $sStringInStr) Then             $iCount += 1             _GUICtrlListView_InsertGroup($hListView, -1, $iCount, $aArray[$A][0])             _GUICtrlListView_SetGroupInfo($hListView, $iCount, $aArray[$A][0], 0, $LVGS_COLLAPSIBLE + $LVGS_COLLAPSED)             $sHeader = $aArray[$A][0]             ContinueLoop         EndIf         If $sHeader = $aArray[$A][0] Then             ContinueLoop         EndIf         $aArray[$A][1] = StringReplace($aArray[$A][1], "--@--", "")         If @extended = 0 Then             $iImage = 0         Else             $iImage = 1         EndIf         $iIndex = _GUICtrlListView_AddItem($hListView, $aArray[$A][0], $iImage, _GUICtrlListView_GetItemCount($hListView) + 9999)         For $B = 1 To $aArray[0][1] - 1             _GUICtrlListView_AddSubItem($hListView, $iIndex, $aArray[$A][$B], $B, -1)         Next         _GUICtrlListView_SetItemGroupID($hListView, $iIndex, $iCount)     Next     Return SetError(0, $aArray[0][1], $aArray) EndFunc   ;==>__Log_GUICtrlListView_Refresh Func __Log_Reduce($sFile)     Local $iSize, $sRead, $sStringInStr     $iSize = FileGetSize($sFile)     If $iSize > 3072 * 1024 Then ; 3072 KB Is The Same As 3 MB.         _Log_Shutdown()         $sRead = FileRead($sFile)         If @error Then             _Log_Startup($sFile)             Return SetError(1, 0, -1)         EndIf         $sStringInStr = StringInStr($sRead, @CRLF, 0, -1, $iSize / 2)         If $sStringInStr = 0 Then             _Log_Startup($sFile)             Return SetError(1, 0, -1)         EndIf         _Log_Startup($sFile, 2)         FileWrite($__Log_Array[1], StringTrimLeft($sRead, $sStringInStr + 3))         _Log_Shutdown()         _Log_Startup($sFile)     EndIf     Return 1 EndFunc   ;==>__Log_Reduce Func __Log_Startup($sFile, $iOverwrite, $iWrite)     If $sFile = -1 Or $sFile = $__Log_Array[0] Or $__Log_Array[1] > -1 Then         Return SetError(1, 0, $__Log_Array[1])     EndIf     Local $hFileOpen = FileOpen($sFile, 1 + $iOverwrite)     If $hFileOpen = -1 Then         Return SetError(1, 0, $__Log_Array[1])     EndIf     $__Log_Array[0] = $sFile     $__Log_Array[1] = $hFileOpen     If $iWrite = 1 Then         _Log_Write("<Log Started - " & @MDAY & "-" & @MON & "-" & @YEAR & ">", "Log was Started at")     EndIf     Return $sFile EndFunc   ;==>__Log_Startup Func __Log_WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)     #forceref $hWnd, $iMsg, $iwParam     Local $hListView = $__Log_ListView     Local $hWndFrom, $iCode, $iIndex, $iInfo, $iSubItem, $tNMHDR     Local Const $tagNMHDR = "hwnd hWndFrom; uint_ptr IDFrom; int Code" ; x32/x64.     $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)     $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))     $iCode = DllStructGetData($tNMHDR, "Code")     $iInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)     $iIndex = DllStructGetData($iInfo, "Index")     $iSubItem = DllStructGetData($iInfo, "SubItem")     Switch $hWndFrom         Case $hListView             Switch $iCode                 Case $LVN_COLUMNCLICK                     $iSubItem = DllStructCreate($tagNMLISTVIEW, $ilParam)                     _GUICtrlListView_SortItems($hListView, DllStructGetData($iSubItem, "SubItem"))                 Case $NM_RCLICK                     If $iIndex <> -1 And $iSubItem <> -1 Then                     EndIf                     __Log_GUICtrlListView_ContextMenu($hListView, $iIndex, $iSubItem)             EndSwitch     EndSwitch     Return "GUI_RUNDEFMSG" EndFunc   ;==>__Log_WM_NOTIFY Func __Log_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam)     #forceref $hWnd, $iMsg, $iwParam, $ilParam     _GUICtrlStatusBar_Resize($__Log_StatusBar)     Return "GUI_RUNDEFMSG" EndFunc   ;==>__Log_WM_SIZE
Example 1:
AutoIt         
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_UseX64=N #include "_Log.au3" #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> _Main() Func _Main()     Local $hGUI, $i1DArray, $iButton, $iClose, $iError, $iOpen, $iStatus, $sLogFile     Local $a1DArray[10] = ["Row 0", "Row 1", "Row 2", "Row 3", "Row 4", "Row 5", "Row 6", "Row 7", "Row 8", "Row 9"]     $sLogFile = _Log_Startup(@ScriptDir & "\Example.log", 1) ; Open the log file and erase previous contents.     _Log_Write("Log Startup", "The Log File that is being used will be: " & $sLogFile)     $hGUI = GUICreate("_Log()", 400, 300, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX))     $i1DArray = GUICtrlCreateButton("Create 1D Array", 5, 5, 95, 22.5)     GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKSIZE + $GUI_DOCKTOP)     $iError = GUICtrlCreateButton("Create Error", 5, 30, 95, 22.5)     GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKSIZE + $GUI_DOCKTOP)     $iOpen = GUICtrlCreateButton("Open Log", 5, 80, 95, 22.5)     GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKSIZE + $GUI_DOCKTOP)     $iClose = GUICtrlCreateButton("Close Log", 5, 105, 95, 22.5)     GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKSIZE + $GUI_DOCKTOP)     $iStatus = GUICtrlCreateLabel("Welcome to Log: Example", 5, 270, 295, 40)     GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKSIZE + $GUI_DOCKBOTTOM)     GUICtrlSetFont(-1, 14)     $iButton = GUICtrlCreateButton("Display", 400 - 80, 275, 75, 22.5)     GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKSIZE + $GUI_DOCKBOTTOM)     GUISetState(@SW_SHOW)     While 1         Switch GUIGetMsg()             Case $GUI_EVENT_CLOSE                 _Log_Shutdown() ; Close the log file.                 Exit             Case $i1DArray                 If _Log_Write("1D Array", $a1DArray, 0) Then ; Write a 1D array to the log file.                     GUICtrlSetData($iStatus, "Wrote 1D Array to the Log File.")                 Else                     GUICtrlSetData($iStatus, "An error occurred _Log_Write().")                 EndIf             Case $iError                 If _Log_Error("An error occurred!", "This could be some random error which we would like to log.") Then ; Create an error entry in the log file.                     GUICtrlSetData($iStatus, "Wrote Error to the Log File.")                 Else                     GUICtrlSetData($iStatus, "An error occurred with _Log_Error().")                 EndIf             Case $iOpen                 _Log_Startup($sLogFile, 0) ; Open the log file and append to the end of the log file.                 If @error Then                     GUICtrlSetData($iStatus, "The Log File appears to be Open.")                 Else                     GUICtrlSetData($iStatus, "Log File was Opened.")                 EndIf             Case $iClose                 _Log_Shutdown() ; Close the log file.                 If _Log_IsOpen() Then ; Check the log file was closed.                     GUICtrlSetData($iStatus, "Log File wasn't Closed.")                 Else                     GUICtrlSetData($iStatus, "Log File was Closed.")                 EndIf             Case $iButton                 GUICtrlSetData($iStatus, "Displayed the Log File.")                 _Log_Display($hGUI) ; Display the current opened log file using _Log_Display().         EndSwitch     WEnd EndFunc   ;==>_Main
All of the above has been included in a ZIP file. Attached File  Log.zip   6.02K   428 downloads

Edited by guinness, 06 June 2011 - 05:21 PM.

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringIsValid()_StringReplaceWholeWord()_StringStripChar()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore Examples...Updated: 11/04/2013






#2 guinness

guinness

    guinness

  • MVPs
  • 10,299 posts

Posted 06 June 2011 - 04:37 PM

For those that have download already I just made a slight modification after finding out new information from here >> http://www.autoitscript.com/forum/topic/129427-create-a-gui-with-only-the-close-button/

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringIsValid()_StringReplaceWholeWord()_StringStripChar()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore Examples...Updated: 11/04/2013


#3 guinness

guinness

    guinness

  • MVPs
  • 10,299 posts

Posted 09 June 2011 - 05:36 PM

I will be updating this in the next couple of days so if anyone has any suggestions, improvements then please let me know. Currently _Log_Display supports column sorting, but I want to take it a step further and improve the overall design and feel of _Log_Display.

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringIsValid()_StringReplaceWholeWord()_StringStripChar()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore Examples...Updated: 11/04/2013


#4 ricky03

ricky03

    Polymath

  • Active Members
  • PipPipPipPip
  • 217 posts

Posted 12 August 2011 - 01:46 PM

Hello,

very good script, how can we choose the icon? I don't understand this point...

#5 guinness

guinness

    guinness

  • MVPs
  • 10,299 posts

Posted 12 August 2011 - 07:28 PM

Search for _GUIImageList_AddIcon() in the Log.au3 and change the values accordingly. Currently I'm using icons in Shell32.dll.

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringIsValid()_StringReplaceWholeWord()_StringStripChar()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore Examples...Updated: 11/04/2013


#6 ricky03

ricky03

    Polymath

  • Active Members
  • PipPipPipPip
  • 217 posts

Posted 16 August 2011 - 02:41 PM

Ok, but where can I choose : this icon is for this information?

#7 guinness

guinness

    guinness

  • MVPs
  • 10,299 posts

Posted 16 August 2011 - 04:58 PM

By using something like enumicons.au3 which is in the Examples section of C:\Program Files\AutoIt\. It cycles through the icons located in a DLL, in this example it would be Shell32.dll.

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringIsValid()_StringReplaceWholeWord()_StringStripChar()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore Examples...Updated: 11/04/2013





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users