wan Posted August 15, 2022 Posted August 15, 2022 (edited) Hello. I want to ask on how Autoit exe can send a log after every time my program running ? It is for debug purpose to easily know whic line does not execute correctly. For a better, I want Autoit to send the log to me through email. Below is my scripts. Thank You TMGAD0001.au3 Edited August 15, 2022 by wan
Moderators Melba23 Posted August 15, 2022 Moderators Posted August 15, 2022 Moved to the appropriate AutoIt General Help and Support forum, as the AutoIt Example Scripts forum very clearly states: Quote Share your cool AutoIt scripts, UDFs and applications with others. Do not post general support questions here, instead use the AutoIt Help and Support forums. Moderation Team Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Zedna Posted August 15, 2022 Posted August 15, 2022 Log: Func MyLog($text) FileWrite('c:\temp\mylog.txt', @YEAR&'-'&@MON&'-'&@MDAY&' '&@HOUR&':'&@MIN&':'&@SEC & ' ' & $text & @CRLF) ; append EndFunc Email: Resources UDF ResourcesEx UDF AutoIt Forum Search
wan Posted August 15, 2022 Author Posted August 15, 2022 @Zedna where did I need to put the function for log? At the beginning or end of script ? Sorry im newbie
Zedna Posted August 15, 2022 Posted August 15, 2022 Declaration (from my previous post) put at then end of your scripy. Then add call of this function at every important part of your script with short descriptive text as parameter like this: MyLog('start of section one ...') ... MyLog('start of section two ...') Resources UDF ResourcesEx UDF AutoIt Forum Search
wan Posted August 15, 2022 Author Posted August 15, 2022 @Zedna The sVMS2000.exe start in multiple window thus error box message appear Abnormalities Runtime. Can you check my script? #include <Date.au3> #include <MsgBoxConstants.au3> #RequireAdmin Global $sPath = "\\10.174.10.9\SPOON\TMGAD0001\INPUT\" Global $tLocal = _Date_Time_SystemTimeToTzSpecificLocalTime(_Date_Time_GetSystemTime()) Global $sFileName1 = "FR_IP_79_" & _WinAPI_GetDateFormat(0, $tLocal, 0, 'yyyyMMdd') & _WinAPI_GetTimeFormat(0, $tLocal, $TIME_FORCE24HOURFORMAT, 'HHmm') Global $sFileName2 = "FR_IP_82_" & _WinAPI_GetDateFormat(0, $tLocal, 0, 'yyyyMMdd') & _WinAPI_GetTimeFormat(0, $tLocal, $TIME_FORCE24HOURFORMAT, 'HHmm') Global $sFileName3 = "FR_IP_47_" & _WinAPI_GetDateFormat(0, $tLocal, 0, 'yyyyMMdd') & _WinAPI_GetTimeFormat(0, $tLocal, $TIME_FORCE24HOURFORMAT, 'HHmm') Global $sFileName4 = "FR_IP_49_" & _WinAPI_GetDateFormat(0, $tLocal, 0, 'yyyyMMdd') & _WinAPI_GetTimeFormat(0, $tLocal, $TIME_FORCE24HOURFORMAT, 'HHmm') Global $sWindow1 = "[TITLE:" & $sFileName1 & ".xlsx - Excel; CLASS:XLMAIN]" Global $sWindow2 = "[TITLE:" & $sFileName2 & ".xlsx - Excel; CLASS:XLMAIN]" Global $sWindow3 = "[TITLE:" & $sFileName3 & ".xlsx - Excel; CLASS:XLMAIN]" Global $sWindow4 = "[TITLE:" & $sFileName4 & ".xlsx - Excel; CLASS:XLMAIN]" Sleep (1000) run("E:\sVMS2000\sVMS2000.exe") Local $hWnd = WinWait("[TITLE:Login; CLASS:Qt5QWindowIcon]", "") Sleep(1000) ; Click "Login" ControlClick( "Login", "", $hWnd ,"left", 1, 277, 490 ) Local $hWnd = WinWait("[TITLE:sVMS2000; CLASS:Qt5QWindowIcon]", "") $WinPos = WinGetPos($hWnd) Sleep(1000) ; *************************************************************** ; Perform Face Recognition Device 10.174.120.79 (Terminal A) ; *************************************************************** ; Click "Face Manage" ControlClick( "sVMS2000", "", $hWnd, "left", 1, 667, 195 ) Sleep(1000) ; Click "Default Group" ControlClick( "sVMS2000", "", $hWnd, "left", 2, 37, 119 ) Sleep(1000) ; Click 10.174.10.79 "Terminal A" Device ControlClick( "sVMS2000", "", $hWnd, "left", 1, 80, 141 ) Sleep(1000) ; Click "Search" ControlClick( "sVMS2000", "", $hWnd, "left", 1, 1455, 145 ) Sleep(10000) If WinActive ("MessBox") Then ; Close the Excel file. WinClose("MessBox") ; Activate the sVMS2000 window. Local $hWnd = WinWait("[TITLE:sVMS2000; CLASS:Qt5QWindowIcon]", "") ; Uncheck "Export Picture" ControlClick( "sVMS2000", "", $hWnd, "left", 1, 245, 838 ) Sleep(1000) Else ; Click "Export" ControlClick( "sVMS2000", "", $hWnd, "left", 1, 1530, 145 ) Sleep(2000) ; Wait for Explorer Window Local $hWnd1 = WinWait("[TITLE:Save; CLASS:#32770]", "") ; Click on the text box ControlClick ( $hWnd1, "", 1001 ) Sleep(10000) ; Enter file saved name. ControlSetText( $hWnd1, "", 1001, $sPath & $sFileName1 ) Sleep(10000) ; Click SAVE ControlClick ( $hWnd1, "", 1 ) Sleep(10000) ; Wait for the Excel File to Appear WinWait($sWindow1, "") Sleep(2000) ; Close the Excel file. WinClose($sWindow1, "") Sleep(500) EndIf MyLog('start of section two ...') Sleep(500) ; *************************************************************** ; Perform Face Recognition Device 10.174.120.82 (Terminal ; *************************************************************** ; Activate the sVMS2000 window. Local $hWnd = WinWait("[TITLE:sVMS2000; CLASS:Qt5QWindowIcon]", "") ; Click 10.174.10.82 "Terminal B" Device ControlClick( "sVMS2000", "", $hWnd, "left", 1, 80, 162 ) Sleep(1000) ; Click "Search" ControlClick( "sVMS2000", "", $hWnd, "left", 1, 1455, 145 ) Sleep(10000) If WinActive ("MessBox") Then ; Close the error box. WinClose("MessBox") Sleep(500) Else ;WinWaitClose("MessBox") ; Wait until the window is closed ;ProcessWaitClose("") ; Wait until the window is closed via Process Close ;MsgBox(0, "MessBox", "MessBox has been closed", 5) ;ElseIf WinExists("MessBox") = "0" Then ;ElseIf ProcessExists("") = "0" Then ;MsgBox(0, "MessBox", "That window doesn't exist!", 5) ; Click "Export" ControlClick( "sVMS2000", "", $hWnd, "left", 1, 1530, 145 ) Sleep(2000) ; Wait for Explorer Window Local $hWnd1 = WinWait("[TITLE:Save; CLASS:#32770]", "") ; Click on the text box ControlClick ( $hWnd1, "", 1001 ) Sleep(10000) ; Enter file saved name. ControlSetText( $hWnd1, "", 1001, $sPath & $sFileName2 ) Sleep(10000) ; Click SAVE ControlClick ( $hWnd1, "", 1 ) Sleep(60000) ; Wait for the Excel File to Appear. WinWait($sWindow2, "") Sleep(2000) ; Close the Excel file. WinClose($sWindow2, "") Sleep(500) EndIf Sleep(500) MyLog('start of section 3 ...') Sleep(500) ; *************************************************************** ; Perform Face Recognition Device 10.174.120.47 (Terminal C) ; *************************************************************** ; Activate the sVMS2000 window. Local $hWnd = WinWait("[TITLE:sVMS2000; CLASS:Qt5QWindowIcon]", "") ; Click 10.174.10.47 "Terminal C" Device ControlClick( "sVMS2000", "", $hWnd, "left", 1, 80, 183 ) Sleep(1000) ; Click "Search" ControlClick( "sVMS2000", "", $hWnd, "left", 1, 1455, 145 ) Sleep(60000) If WinActive ("MessBox") Then ; Close the error box WinClose("MessBox") Sleep(500) ;WinWaitClose("MessBox") ; Wait until the window is closed ;ProcessWaitClose("") ; Wait until the window is closed via Process Close ;MsgBox(0, "MessBox", "MessBox has been closed", 5) ;ElseIf WinExists("MessBox") = "0" Then ;ElseIf ProcessExists("") = "0" Then ;MsgBox(0, "MessBox", "That window doesn't exist!", 5) Else ; Click "Export" ControlClick( "sVMS2000", "", $hWnd, "left", 1, 1530, 145 ) Sleep(2000) ; Wait for Explorer Window Local $hWnd1 = WinWait("[TITLE:Save; CLASS:#32770]", "") ; Click on the text box ControlClick ( $hWnd1, "", 1001 ) Sleep(10000) ; Enter file saved name. ControlSetText( $hWnd1, "", 1001, $sPath & $sFileName3 ) Sleep(10000) ; Click SAVE ControlClick ( $hWnd1, "", 1 ) Sleep(60000) ; Wait for the Excel File to Appear. WinWait($sWindow3, "") Sleep(2000) ; Close the Excel file. WinClose($sWindow3, "") Sleep(500) _WriteErrorLog("3") EndIf Sleep(500) MyLog('start of section 4 ...') Sleep(500) ; *************************************************************** ; Perform Face Recognition Device 10.174.120.49 (Terminal D) ; *************************************************************** ; Activate the sVMS2000 window. Local $hWnd = WinWait("[TITLE:sVMS2000; CLASS:Qt5QWindowIcon]", "") ; Click 10.174.10.49 "Terminal D" Device ControlClick( "sVMS2000", "", $hWnd, "left", 1, 80, 204 ) Sleep(1000) ; Click "Search" ControlClick( "sVMS2000", "", $hWnd, "left", 1, 1455, 145 ) Sleep(60000) If WinActive ("MessBox") Then ; Close the error box. WinClose("MessBox") Sleep(500) ;WinWaitClose("MessBox") ; Wait until the window is closed ;ProcessWaitClose("") ; Wait until the window is closed via Process Close ;MsgBox(0, "MessBox", "MessBox has been closed", 5) ;ElseIf WinExists("MessBox") = "0" Then ;ElseIf ProcessExists("") = "0" Then ;MsgBox(0, "MessBox", "That window doesn't exist!", 5) Else ; Click "Export" ControlClick( "sVMS2000", "", $hWnd, "left", 1, 1530, 145 ) Sleep(2000) ; Wait for Explorer Window Local $hWnd1 = WinWait("[TITLE:Save; CLASS:#32770]", "") ; Click on the text box ControlClick ( $hWnd1, "", 1001 ) Sleep(10000) ; Enter file saved name. ControlSetText( $hWnd1, "", 1001, $sPath & $sFileName4 ) Sleep(10000) ; Click SAVE ControlClick ( $hWnd1, "", 1 ) Sleep(60000) ; Wait for the Excel File to Appear. WinWait($sWindow4, "") Sleep(2000) ; Close the Excel file. WinClose($sWindow4, "") Sleep(500) EndIf Sleep(500) MyLog('start of section 5 ...') Sleep(500) ; *************************************************************** ; Close/Exit the sVMS2000 Application. ; *************************************************************** ; Activate the sVMS2000 window. Local $hWnd = WinWait("[TITLE:sVMS2000; CLASS:Qt5QWindowIcon]", "") ; Click EXIT. ControlClick( "sVMS2000", "", $hWnd, "left", 1, 1580, 20 ) ; Wait for the Exit Confirmation window. Local $hWnd1 = WinWait("[TITLE:MessBox; CLASS:Qt5QWindowIcon]", "") ; Confirm to exit. ControlClick( "sVMS2000", "", $hWnd1, "left", 1, 370, 210 ) Sleep(500) Func MyLog($text) FileWrite('E:\TMGAD0001\mylog.txt', @YEAR&'-'&@MON&'-'&@MDAY&' '&@HOUR&':'&@MIN&':'&@SEC & ' ' & $text & @CRLF) ; append EndFunc exit 0
Solution Zedna Posted August 16, 2022 Solution Posted August 16, 2022 change Func MyLog($text) FileWrite('E:\TMGAD0001\mylog.txt', @YEAR&'-'&@MON&'-'&@MDAY&' '&@HOUR&':'&@MIN&':'&@SEC & ' ' & $text & @CRLF) ; append EndFunc to Func MyLog($text) FileWrite(@ScriptDir & '\mylog.txt', @YEAR&'-'&@MON&'-'&@MDAY&' '&@HOUR&':'&@MIN&':'&@SEC & ' ' & $text & @CRLF) ; append EndFunc Resources UDF ResourcesEx UDF AutoIt Forum Search
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now