9252Survive

Help with OutlookEX - Sending Email/ Monitoring File

18 posts in this topic

Hello, 

I am trying to use the latest version of OutlookEx.au3 and my script is able to send the email to the user first time but second time I am getting this error (see attached) I am trying to check a file every min and verify if the file has been modified, if the file was not modified then an email is sent. It works for the first time but fails in the second iteration. Also, attaching my code, I am very new to AutoIT, any help would be much appreciated! 

Thanks! 

 

 

#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y

#include <MsgBoxConstants.au3>
#include <Debug.au3>
#include <File.au3>
#include <WinAPI.au3>
#include <GuiComboBox.au3>
#include <Date.au3>
#include <AutoItConstants.au3>
#include <Array.au3>
#include <Process.au3>
#include <StringConstants.au3>
#include <FileConstants.au3>  ; include for file functions
#include <WinAPIFiles.au3>
#include <_SingleScript.au3>
#include <WinNet.au3>
#include <Timers.au3>
#include <INet.au3>
#include <OutlookEX.au3>
#include <DateCalc.au3>

#Region AutoIT_Options

Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=No case
Opt("WinSearchChildren", 1) ;0=no, 1=search children also
Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info
Opt("TrayAutoPause", 0) ; 0 = no pause , 1 = pause when tray icon is clicked

#EndRegion AutoIT_Options

Global $logFileName = "Test" & "-" & @YEAR &"_"&@MON& "." & "log"
Global $logfile = @ScriptDir &"\"& $logFileName
Global $LastModTime
Global $LastModTime
Global $LastModTimeStamp
Global $FiletoCheck_1
Global $FiletoCheck_2
Global $oOutlook = _OL_Open()

Func _SendAlert()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)

;Global $sCurrentUser = $oOutlook.GetNameSpace("MAPI").CurrentUser.Name
;_OL_Wrapper_SendMail($oOutlook, $sCurrentUser, "", "", "Travel Time Calc Engine ALERT! ", "An error has occurred, the log file has not changed since: " & $LastModTimeStamp, "", $olFormatHTML, $olImportanceHigh
_OL_Wrapper_SendMail($oOutlook, "testemail@gmail.com", "", "", "ALERT! ", "An error has occurred, the log file has not changed since: " & $LastModTimeStamp, "", $olFormatHTML, $olImportanceHigh)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OutlookSendMail Wrapper Script", "Error sending mail. @error = " & @error & ", @extended: " & @extended)
;MsgBox(64, "OutlookEX UDF: _OutlookSendMail Wrapper Script", "Mail successfully sent to user '" & $sCurrentUser & "'!")

_OL_Close($oOutlook)

EndFunc

Func _ChecklogFile()
    $FiletoCheck_2 = FileGetTime($logfile, 0, 1)   ; Timestamp
    If $FiletoCheck_1 == $FiletoCheck_2 Then   ; if the time stamp has not changed
        Msgbox("","","File has not changed")
_SendAlert()
    Else
     Msgbox("","","File has changed")
EndIf
EndFunc

; Initial Launch, grab current GetTime
$FiletoCheck_1 = FileGetTime($logfile,0,1)
Local $YYYY = StringLeft ( $FiletoCheck_1, 4 )
Local $MM = StringMid ( $FiletoCheck_1,5,2)
Local $DD = StringMid ( $FiletoCheck_1,7,2 )
Local $HH = StringMid ( $FiletoCheck_1,9,2 )
Local $Min = StringMid ( $FiletoCheck_1,11,2 )
Local $SS = StringMid ( $FiletoCheck_1,13,2 )


$LastModTimeStamp = $YYYY&"-"&$MM&"-"&$DD&"  "&$HH&":"&$Min&":"&$SS



 While 1
 Sleep(60000)   ; check every 10 mins
    _ChecklogFile()
WEnd

 

OutlookEXError.jpg

Share this post


Link to post
Share on other sites



That's easy :)

You call _OL_Open when starting the script but immediately close Outlook after the first mail has been send in function _SendAlert.
Move _OL_Close to the main script and close Outlook before you exit the script.


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

Oh yes, that makes sense, I will put that at the end of the script and see how that goes. 

Thanks

Share this post


Link to post
Share on other sites

Seems like this is working!  :)

Next question, how can I use a distribution list or list of recipients here?  

Share this post


Link to post
Share on other sites

Just enter the name of the distribution list. For a list of recipients separate them with a semicolon.

1 person likes this

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

Just enter the name of the distribution list. For a list of recipients separate them with a semicolon.


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

Great thanks! I will try that

Meanwhile I am having some trouble in passing the value of the email through a variable, I keep getting the error 4400

This is what I am trying to do... 

    Global $Email = "testmail@gmail.com"

_OL_Wrapper_SendMail($oOutlook,$Email, "", "", "ALERT! ", "An error has occurred, the log file has not changed since: " & $LastModTimeStamp, "", $olFormatHTML, $olImportanceHigh)

 

Share this post


Link to post
Share on other sites

Is testmail@gmail.com correct? In your OP you use testemail@gmail.com


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

#9 ·  Posted (edited)

It must be a typo while typing here ... I have checked the code its not address

Its the placeholder anyways 

Edited by 9252Survive

Share this post


Link to post
Share on other sites

Can you insert

MsgBox(0, "", $email)

before _OL_Wrapper_SendMail to make sure the value hasn't been changed by the script somewhere?


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

Sure, let me check that... 

Share this post


Link to post
Share on other sites

The email is correct (as declared) and the funny thing is that it's working now, not sure why it wont work earlier.  The end goal is to read this value from an INI file, I was having problems with that initially and then I tried assigning the value in the code but that didn't work either. It seems to work now, I will try to read the value from an INI and see how that goes. 

Thanks a lot for your help! 

Share this post


Link to post
Share on other sites

Thanks for the feedback. Hope the INI-file approach works as well ;)

1 person likes this

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

Hi, 

Sorry for the delay in response...

The script is working fine with the INI!

 

Thanks a lot

Share this post


Link to post
Share on other sites

Great :)


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

Hi

I am again getting the same error that I posted in the beginning of this thread. The strange thing is that it works on one computer and not another. I just copied the script to another pc and it wont work and same is the case with the compiled exe. Below given is the code that uses INI file ( as I mentioned in my last post) and attached is the error. 

 

#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y

#include <MsgBoxConstants.au3>
#include <Debug.au3>
#include <File.au3>
#include <WinAPI.au3>
#include <GuiComboBox.au3>
#include <Date.au3>
#include <AutoItConstants.au3>
#include <Array.au3>
#include <Process.au3>
#include <StringConstants.au3>
#include <FileConstants.au3>  ; include for file functions
#include <WinAPIFiles.au3>
#include <_SingleScript.au3>
#include <WinNet.au3>
#include <Timers.au3>
#include <INet.au3>
#include <OutlookEX.au3>
#include <TrayConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>


#Region AutoIT_Options

Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=No case
Opt("WinSearchChildren", 1) ;0=no, 1=search children also
Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info
Opt("TrayAutoPause", 0) ; 0 = no pause , 1 = pause when tray icon is clicked

#EndRegion AutoIT_Options
Global $ImportFiles
Global $RootSHM
Global $Site
Global $Truck
Global $j
Global $i
Global $SiteArray
Global $MsgType
Global $TruckArray
Global $logfilepath
Global $logFileName = "Test" & "-" & @YEAR &"_"&@MON& "." & "log"

Global $LastModTime
Global $LastModTimeStamp
Global $Filecount
Global $FiletoCheck_1
Global $FiletoCheck_2
Global $oOutlook = _OL_Open()
Global $Message
Global $Email
Global $Inifile = @ScriptDir & "\FileWatcher.ini"
Global $Freq
Global $sdata
Global $Env
Global $tdata

If FileExists($Inifile) = 0 Then              ; Check if .INI file exists
_CreateIni()
EndIf

_GetValues() ; Read INI file for values

Func _CreateIni() ; IniWrite used to create the file and add section/keys.
    IniWrite($Inifile, "Project", "Root", "\\fcgwnt01\share.$\StandardHaulage\TEST\")
    IniWrite($Inifile, "Project", "Email", "TestEmail@gmail.com")
    IniWrite($Inifile, "Project", "Frequency", "60000")
    IniWrite($Inifile, "Project", "Logfile path","\\testpc\test\FileWatcher\V5")
EndFunc   ;==>_CreateIniV5


Func _GetValues() ; Read the INI File
    
    $RootSHM = IniRead($Inifile, "Project", "Root", "\\testpc\TEST\")
    $Email = IniRead($Inifile, "Project", "Email", "TestEmail@gmail.com")
    $Freq =IniRead($Inifile, "Project", "Frequency", "60000")
    $logfilepath=IniRead($Inifile, "Project", "Logfile path","\\testpc\test\FileWatcher\V5")


    If $RootSHM = "" Then
        $RootSHM = "\\testpc\TEST\"
    EndIf

    If $Email = "" Then
         $Email = "TestEmail@gmail.com"
    EndIf

    If $Freq = "" Then
        $Freq = "60000"
    EndIf

EndFunc   ;==>_GetValues

Global $logfile = $logfilepath &"\"& $logFileName



Func _SendAlert($MsgType,$Message)

If $MsgType = "0" Then
    $MsgType = "ALERT!"

Else
    If $MsgType = "1" Then
        $MsgType = "Notification-Processing Complete"

        Else
            If $MsgType = "2" Then
        $MsgType = "Notification-Processing Pending"

    EndIf


            EndIf
EndIf

If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)

;Global $sCurrentUser = $oOutlook.GetNameSpace("MAPI").CurrentUser.Name
;_OL_Wrapper_SendMail($oOutlook, $sCurrentUser, "", "", " ALERT! ", "An error has occurred, the log file has not changed since: " & $LastModTimeStamp, "", $olFormatHTML, $olImportanceHigh
;_OL_Wrapper_SendMail($oOutlook, "TestEmail@gmail.com", "", "", " ALERT! ", "An error has occurred, the log file has not changed since: " & $LastModTimeStamp, "", $olFormatHTML, $olImportanceHigh)
;MsgBox("","",$Email)
_OL_Wrapper_SendMail($oOutlook,$Email, "", "", " - "& $MsgType, $Message, "", $olFormatHTML, $olImportanceHigh)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OutlookSendMail Wrapper Script", "Error sending mail. @error = " & @error & ", @extended: " & @extended)
;MsgBox(64, "OutlookEX UDF: _OutlookSendMail Wrapper Script", "Mail successfully sent to user '" & $sCurrentUser & "'!")

EndFunc

Func _ChecklogFile()
    ;$FiletoCheck_1 = FileGetTime($logfile,0,1)
    $FiletoCheck_2 = FileGetTime($logfile, 0, 1)   ; Timestamp
    If $FiletoCheck_1 == $FiletoCheck_2 Then   ; if the time stamp has not changed
        ;Msgbox("","","File has not changed")
_SendAlert(0,"An error has occurred, the log file has not changed since: " & $LastModTimeStamp)
    Else
     ;Msgbox("","","File has changed")
EndIf
EndFunc


$FiletoCheck_1 = FileGetTime($logfile,0,1)   ; Initial Launch, grab current GetTime

;MsgBox("","",$logfilepath)
;MsgBox("","",$logfile)
;MsgBox("","",$FiletoCheck_1)


Func _SplitDT($file)

Local $YYYY = StringLeft ( $file, 4 )
Local $MM = StringMid ( $file,5,2)
Local $DD = StringMid ( $file,7,2 )
Local $HH = StringMid ( $file,9,2 )
Local $Min = StringMid ( $file,11,2 )
Local $SS = StringMid ( $file,13,2 )


$LastModTimeStamp = $YYYY&"-"&$MM&"-"&$DD&"  "&$HH&":"&$Min&":"&$SS

EndFunc


 While 1
 Sleep($Freq)   ; check every 10 mins
     _SplitDT($FiletoCheck_1)
    _ChecklogFile()
    $FiletoCheck_1 = FileGetTime($logfile,0,1)  ; reset the timestamp
WEnd

_OL_Close($oOutlook)

 

2016-02-12_11-24-43.jpg

Share this post


Link to post
Share on other sites

Line

If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)

should be inserted immediately after _Ol_Open because now you do not get any error information.


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

Hello Water, 

Sorry, I have been tied up with some other stuff and this was side tracked I will try your suggestion and report later. Thanks again! 

 

 

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

  • Similar Content

    • VaishnaviBUtpat
      By VaishnaviBUtpat
      <!DOCTYPE html> <html lang="en" xml:lang="en" style="height: 100%;" xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <style> * { margin: 0; padding: 0; } .th-lk { color: #3665d0; font-family: Arial; font-size: small; text-decoration: none; } .th-lk { vertical-align: 0px; } .th-menu2 .th-lk { line-height: 2em; margin-bottom: 0px; margin-right: 0px; overflow: hidden; padding: 0; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; width: 100%; } .th-menu2 .th-lk { color: black; font-weight: bold; } .th-menu2 > li > .th-lk { display: block; padding-left: 8px; width: auto; } .th-menu2 .th-menu2-sub-item .th-lk, .th-menu2 .th-menu2-sub-item-hov .th-lk { margin-right: 20px; } .th-menu2-sub-item { position: relative !important; } .th-menu2 .th-menu2-item, .th-menu2 .th-menu2-item-hov, .th-menu2 .th-menu2-sub-item, .th-menu2 .th-menu2-sub-item-hov { background-repeat: repeat-x; border-left-style: solid; border-left-width: 1px; border-right-style: solid; border-right-width: 1px; border-top-style: solid; border-top-width: 1px; height: 2em; list-style: none; margin-bottom: 0px; padding: 0; width: 100%; } .th-menu2 .th-menu2-item, .th-menu2 .th-menu2-item-hov, .th-menu2 .th-menu2-sub-item, .th-menu2 .th-menu2-sub-item-hov { background-color: #ECECEC; background-image: url(sap_skins/default/styling/lshape/chg_butt_det_nav.gif); border-left-color: #d3d1ce; border-right-color: #d3d1ce; border-top-color: #d3d1ce; border-top-width: 0px; } .th-menu2 { border: 0 solid black; left: 0px; list-style: none; margin: 0; padding: 0; position: relative; } .th-menu2 { z-index: 10006; } .th-menu2 { background-color: white; } div { zoom: 1; } .th-sc-content { left: 0px; position: absolute; top: 0px; } .th-sc-container { left: 0px; overflow: hidden; position: relative; top: 0px; } .th-sc-top { position: relative; } .th-sc-top, .th-sc-content, .th-sc-container, .th-sc-buttondown, .th-sc-buttonup { width: 172px; } .th-sc-buttonup, .th-sc-container { z-index: 10101; } .th-sc-top { z-index: 10100; } body, td, th { font-family: Arial,Helvetica,sans-serif; font-size: small; } .th-l-navcontainer, .th_l_downcontainer { border-right-style: solid; border-right-width: 1px; width: 172px; } .th-l-navcontainer, .th_l_downcontainer { background-color: white; border-right-color: #d3d1ce; } body, html { margin: 0px; border: 0; margin: 0; } </style> </head> <body><form name="myFormId" id="myFormId" action="/sap(ZT1TVVJEWDFWVFVsOWZYMTlmTWpNNU9UWmZXWTlwZG5telZ1RGhBSUFBQ3Nyc2tBPT0=)/bc/bsp/sap/crm_ui_frame/BSPWDApplication.do?sap-client=100&amp;sap-language=EN&amp;sap-domainrelax=min" method="post" target="WorkAreaFrame2"><div class="th-ajax-area" id="rootAreaDiv"><div id="C1_W1_V2" tgt="" dhe="false"><table width="100%" style="table-layout: fixed;" cellspacing="0" cellpadding="0"><tbody><tr><td><table width="100%" style="table-layout: fixed;" cellspacing="0" cellpadding="0"><tbody><tr valign="top"><td class="th-l-navcontainer" id="th_l_navcontainer"><div class="th-sc-top" id="C1_W1_V2_thescroll" style="height: 786px;"><div class="th-sc-container" id="C1_W1_V2_thescroll_scbox" style="height: 786px;"><div class="th-sc-content" id="C1_W1_V2_thescroll_sccontent"><div class="th-ajax-area" id="C1_W1_V2_$navbar"><div id="C7_W35_V36" tgt="" dhe="true" excevt="" intevt="c:C7_W35_V36:C1_W1_V2_C7_W35_V36_MainNavigationLinks.do;" automode="true"><div class="th-ajax-area" id="C1_W1_V2_C7_W35_V36_MainNavigationLinks.do"><ul class="th-menu2" id="C7_W35_V36_mainmenu" style="width: 171px;"><li class="th-menu2-sub-item"><a title="Sales Cycle" class="th-lk" id="C7_W35_V36_UTL-SLS" onclick="htmlbSubmitLib('htmlb',this,'thtmlb:link:click:0','myFormId','C7_W35_V36_UTL-SLS','UTL\x2dSLS\x2dWC',0);return false" onfocus="thSaveKbFocus(this);" oncontextmenu="return false;" href="javascript:void(0)">Sales Cycle</a></li></ul></div></div></div></div></div></div></td></tr></tbody></table></td></tr></tbody></table></div></div></form></body> </html> How to capture above HTML element using AutoIT
    • cu0x
      By cu0x
      Hello guys,
       
      im trying to solved a problem that I have.
       
      Need to get some chinese text from an old Wise script, and in the wise file says f.e. Ù×÷ϵͳ¡£ ÇëÉý¼¶Ä. Is there any way to convert it to traditional chinese?
       
      Already tryied the following code...
       
      #include <MsgBoxConstants.au3> Example() Func Example() ; Define the string that will be converted later. ; NOTE: This string may show up as ?? in the help file and even in some editors. ; This example is saved as UTF-8 with BOM. It should display correctly in editors ; which support changing code pages based on BOMs. Local Const $sString = "Ù×÷ϵͳ¡£ ÇëÉý¼¶Ä" ; Temporary variables used to store conversion results. $dBinary will hold ; the original string in binary form and $sConverted will hold the result ; afte it's been transformed back to the original format. Local $dBinary = Binary(""), $sConverted = "" ; Convert the original UTF-8 string to an ANSI compatible binary string. $dBinary = StringToBinary($sString) ; Convert the ANSI compatible binary string back into a string. $sConverted = BinaryToString($dBinary) ; Display the resulsts. Note that the last two characters will appear ; as ?? since they cannot be represented in ANSI. DisplayResults($sString, $dBinary, $sConverted, "ANSI") ; Convert the original UTF-8 string to an UTF16-LE binary string. $dBinary = StringToBinary($sString, 2) ; Convert the UTF16-LE binary string back into a string. $sConverted = BinaryToString($dBinary, 2) ; Display the resulsts. DisplayResults($sString, $dBinary, $sConverted, "UTF16-LE") ; Convert the original UTF-8 string to an UTF16-BE binary string. $dBinary = StringToBinary($sString, 3) ; Convert the UTF16-BE binary string back into a string. $sConverted = BinaryToString($dBinary, 3) ; Display the resulsts. DisplayResults($sString, $dBinary, $sConverted, "UTF16-BE") ; Convert the original UTF-8 string to an UTF-8 binary string. $dBinary = StringToBinary($sString, 4) ; Convert the UTF8 binary string back into a string. $sConverted = BinaryToString($dBinary, 4) ; Display the resulsts. DisplayResults($sString, $dBinary, $sConverted, "UTF8") EndFunc ;==>Example ; Helper function which formats the message for display. It takes the following parameters: ; $sOriginal - The original string before conversions. ; $dBinary - The original string after it has been converted to binary. ; $sConverted- The string after it has been converted to binary and then back to a string. ; $sConversionType - A human friendly name for the encoding type used for the conversion. Func DisplayResults($sOriginal, $dBinary, $sConverted, $sConversionType) MsgBox($MB_SYSTEMMODAL, "", "Original:" & @CRLF & $sOriginal & @CRLF & @CRLF & "Binary:" & @CRLF & $dBinary & @CRLF & @CRLF & $sConversionType & ":" & @CRLF & $sConverted) EndFunc ;==>DisplayResults Thanks a lot!
    • nacerbaaziz
      By nacerbaaziz
      Hi dear
      I want create retractable bar using autoit
      I tried creating slider, but there's a problem with screen reader for the blind, so is there another retractable tape?
      It is advisable to not accept dragging with the keybord only with  mouse
      note:
      This bar is needed in the process of raising and lowering the volume
      I hope that there is a solution to do that
      i waiting your responses.
      Thanks in advance to all members and administrators
    • XanzyX
      By XanzyX
      Is there a function out there that will edit an existing file witha a "Save" and "Cancel" at the bottom?
      Example: Funcrion("TestFile.txt")
    • usmiv4o
      By usmiv4o
      #cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.4.3 Author: usmiv4o Script Function: AutoIt script to check if files in directory are changed. It is usefull for security contra-inteligense measures. Function Name: LoadTripwireDB() Description: Loads database (text file tripwire.txt) and compare files in /test folder for changes. compares Hash (MD5) checksums. If they are not the same starts Initial() Function Name: Initial() Description: Checks directory and makes index of files and their MD5 checksums in text file (tripwire.txt) Function Name: Hush() Description: Checks file and returns its MD5 checksum. Requirement(s): Windows XP Return Value(s): On Success - Returns true. Files are the same as before. On Failure - return false. Example: LoadTripwireDB() #ce ---------------------------------------------------------------------------- #include <Crypt.au3> #include <File.au3> #include <Array.au3> $sDir = @ScriptDir & "\Test" $sFilePath = @ScriptDir & "\tripwire.txt" Func Hush(ByRef $sFile) $sRead = FileOpen( $sFile) $dHash = _Crypt_HashData($sRead, $CALG_MD5) ; Create a hash of the text entered. ConsoleWrite("Hash of file " & $sFile & " is " & $dHash & @CRLF) EndFunc ;ConsoleWrite("Files in Dir are " & $aScriptDir[0] & @CRLF) ;$sFilePath = @ScriptDir & "\Examples.txt" ;_FileWriteFromArray($sFilePath, $aScriptDir, 1) ;_ArrayDisplay($aScriptDir, "1D display") Func Initial() $aScriptDir = _FileListToArray($sDir) for $i = 1 To UBound($aScriptDir) - 1 $dHash = _Crypt_HashData($i, $CALG_MD5) ;ConsoleWrite("File " & $aScriptDir[$i] & " is " & $dHash & @CRLF) ConsoleWrite($aScriptDir[$i] & ":" & $dHash & @CRLF) ;Hush($aScriptDir[$i]) ;FileWrite $hFileOpen = FileOpen($sFilePath, $FO_APPEND) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.") EndIf FileWrite($hFileOpen, $aScriptDir[$i] & ":" & $dHash & @CRLF) Next EndFunc Func Monitor() $aScriptDir = _FileListToArray($sDir) for $i = 1 To UBound($aScriptDir) - 1 Next EndFunc Func LoadTripwireDB() $comparison_ok = false $dArray = _FileListToArray($sDir) ;directory $dArray0 = UBound($dArray) - 1 $fArray = FileReadToArray($sFilePath) ;file $fArray0 = UBound($fArray) ;_ArrayDisplay($dArray, "files array") if $dArray0 = $fArray0 Then ; are file same as recorded in txt file? ;ConsoleWrite("files in monitoring dir: " & $dArray[0] & " = file recorded: " & $fArray0 & @CRLF & $fArray[0]& @CRLF) for $i = 1 To UBound($dArray) - 1 ;ConsoleWrite("i = " & $i & @CRLF) $dHash = _Crypt_HashData($i, $CALG_MD5) ;binary ;$dHash = BinaryToString($dHash) $ffhash = StringSplit( $fArray[$i-1],":") $fhash = $ffhash[2] ;ConsoleWrite("IsBinary $dHash " & IsBinary($dHash) & @CRLF) if $dHash = $fhash Then ;if compared hashes are equal ;ConsoleWrite($fhash & ":" & $dHash & " equal" & @CRLF) ;ConsoleWrite("File: " & $fhash & @CRLF & "Directory: " & $dHash & @CRLF & "equal: yes " & @CRLF) Else ;if compared hashes are not equal ;ConsoleWrite("File: " & $fhash & @CRLF & "Directory: " & $dHash & @CRLF & "equal: not " & @CRLF) ;MsgBox(0,"hash md5",$fhash & ":" & $dHash & " not equal") EndIf Next ;ConsoleWrite("hashes are equal" & @CRLF) $comparison_ok = true Else ConsoleWrite("number of files in monitoring dir are not same as recorded" & @CRLF) ConsoleWrite("directory: " & $dArray[0] &":"& "files: " & UBound($fArray) - 1 & @CRLF) EndIf Return $comparison_ok EndFunc #main if LoadTripwireDB() = true Then ConsoleWrite(" hashes are equal " & @CRLF) ElseIf LoadTripwireDB() <> true Then ConsoleWrite(" hashes are not equal " & @CRLF) ConsoleWrite(" hashes are not equal " & @CRLF) Initial() EndIf  
      tripwire.au3
      tripwire.txt