Jump to content

Writing to Log GUI from another script


Recommended Posts

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

 

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?

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...