aa2zz6

Writing to Log GUI from another script

6 posts in this topic

How do I post results to a Log GUI from another script?

Log Script ~

#include <AutoItConstants.au3>
#include <Date.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiButton.au3>
#include <GuiRichEdit.au3>
#include <GUIImageList.au3>
#include <GUIMenu.au3>
#include <GuiEdit.au3>
#include <GuiComboBox.au3>
#include <GuiTab.au3>

#include <GDIPlus.au3>

HotKeySet("{ESC}", "Terminate")

#cs ----------------------------------------------------------------------------
    GUI Settings
#ce ----------------------------------------------------------------------------

Global $width = -500, $height = 700, $LogMessage

$style1 = BitXOR($WS_POPUP, $WS_EX_LAYERED) ; Tabs
$style2 = BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_LAYERED) ; Tabs

;Popup/Transparent view
$hGUI = GUICreate("GUI", 500, 500, @DesktopWidth / 2 - $width / 2, @DesktopHeight / 2 - $height / 2, _
        $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$hTab = GUICtrlCreateTab(10, 10, 480, 480)
; Create tabitems

;left, top, width, hieth
GUICtrlCreateTabItem("Log")
GUICtrlSetImage(-1, @ScriptDir & "")
GUICtrlSetState(-1, $GUI_SHOW)
Global $log = GUICtrlCreateEdit("", 20, 40, 460, 400, BitOR($ES_WANTRETURN, $ES_READONLY, $ES_AUTOVSCROLL, $WS_VSCROLL))
GUICtrlSetFont($log, 12, 800, "verdana")
GUICtrlSetBkColor($log, 0xFFFFFF)
GUICtrlSetColor($log, $COLOR_Green)
GUICtrlSetResizing(-1, 802)

GUICtrlCreateTabItem("")

_WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 255)
GUISetBkColor(0xABCDEF)
GUISetState(@SW_SHOW, $hGUI) ; Makes GUI Visible

;Pre-Conditions to check for..
Ini_Config()

While 1
    Sleep(1000)
WEnd

Func Ini_Config()
    Local Const $ArcGIS_Explorer = @ScriptDir & "\Script Function\ini Directory\" & "Map Location.ini"
    Local $MapFileExists = FileExists($ArcGIS_Explorer)

    If $MapFileExists Then
        $LogMessage = $LogMessage & @CRLF & _NowTime() & " Files: [" & $MapFileExists & "]" & @CRLF & $ArcGIS_Explorer
        GUICtrlSetData($log, $LogMessage, 1)
    Else
        $LogMessage = $LogMessage & @CRLF & _NowTime() & " Files: [" & $MapFileExists & "]" & " Missing Map Location" & @CRLF
        GUICtrlSetData($log, $LogMessage, 1)
        RunWait(@AutoItExe & ' "' & @ScriptDir & '\Script Function\Map Location.au3"')
    EndIf
EndFunc   ;==>Ini_Config

Func Terminate()
    Exit
EndFunc   ;==>Terminate

Calling Script ~

HotKeySet("{ESC}", "Terminate")

Write_To_Log()

Func Write_To_Log()
    ;Do something

    ;post results to Log

EndFunc   ;==>Write_To_Log

Func Terminate()
    Exit
EndFunc   ;==>Terminate

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Why can't you use $CmdLineRaw?

Just read your script, since its just an Edit control you could just use Control Send.

Edited by Subz

Share this post


Link to post
Share on other sites

Personal preference. For me It's easier to customize and read when using a GUICtrlCreateEdit. 

Share this post


Link to post
Share on other sites

Personally, I would write to a log file and then just have the Log Gui, check it for changes, although I usually use NotePad++ or SCCM CMTrace.exe to view changes to logs.  Note: Looking at your script, if you don't have Map Location.au3, you realize that it will just keep spawning new instances of your GUI?

Share this post


Link to post
Share on other sites

The Debug UDF creates its own window to display debug messages. It lets you write to log files too. 

Maybe this is what you are looking for. 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I found a piece of code Kylomas wrote to actually fit my needs. I'll include the code and link below. 

Thanks guys

 

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