padinski

Sound alert - after x amount of time

9 posts in this topic

Hi All,

I have the following script which works beautifully :)

;-----------------------------------------------------------------------------
; Select filepath with message to display in FileOpenDialog.
;-----------------------------------------------------------------------------
Local Const $sMessage = "Select your excel file."
Local $sFilePath = FileOpenDialog($sMessage, "D:\Users\xxxx\Documents\", "Excel (*.xls;*.xlsx;*.csv)|", $FD_FILEMUSTEXIST)
;-----------------------------------------------------------------------------
; Create application object or connect to an already running Excel instance
;-----------------------------------------------------------------------------
Local $oAppl = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF:", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
;-----------------------------------------------------------------------------
;open workbook from excel
;-----------------------------------------------------------------------------
$oWorkbook = _Excel_BookOpen($oAppl, $sFilepath, Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF:", "Error opening '" & $oWorkbook & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
;-----------------------------------------------------------------------------
;Read array from excel
;-----------------------------------------------------------------------------
Local $aArray1 = _Excel_RangeRead($oWorkbook, Default)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF:", "Error reading from workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
_ArrayDisplay($aArray1)
;-----------------------------------------------------------------------------
; Turn on progress GUI
;-----------------------------------------------------------------------------
ProgressOn("Progress", "address updates", "0%")
;-----------------------------------------------------------------------------
; counts the number of rows in the array
;-----------------------------------------------------------------------------
$rows = UBound($aArray1) -1
;-----------------------------------------------------------------------------
; script start
;-----------------------------------------------------------------------------
for $c = 1 to $rows
;-----------------------------------------------------------------------------
; Progress calcualtions
;-----------------------------------------------------------------------------
$p=($c-1)/$rows*100
ProgressSet($p,$c-1&" of "&$rows&" addresses processed")
;-----------------------------------------------------------------------------
;Address id search in IE
;-----------------------------------------------------------------------------
$oIE = _IEAttach("Address")
_IENavigate($oIE, "http://intranet/addaddresssearch")
$oForm1 = _IEFormGetCollection($oIE, 0)
Local $oQuery = _IEFormElementGetObjByName($oForm1, "AddressID")
_IEFormElementSetValue($oQuery, $aArray1[$c][0])
_IEFormSubmit($oForm1)
_IELoadWait($oIE)
If WinActive ("Message")Then
ControlClick("Message", "OK", "[CLASS:Button;INSTANCE:1]");Confirmation message box, click "ok"
Continueloop
EndIf
;-----------------------------------------------------------------------------
;Update fieldB in IE
;-----------------------------------------------------------------------------
$oForm2 = _IEFormGetCollection($oIE, 0)
Local $oQuery1 = _IEFormElementGetObjByName($oForm2, "fieldB")
_IEFormElementSetValue($oQuery1, $aArray1[$c][1])
;-----------------------------------------------------------------------------
;Update fieldC in IE
;-----------------------------------------------------------------------------
Local $oQuery2 = _IEFormElementGetObjByName($oForm2, "fieldC")
_IEFormElementSetValue($oQuery2, $aArray1[$c][2])
;-----------------------------------------------------------------------------
;Update fieldD in IE
;-----------------------------------------------------------------------------
Local $oQuery3 = _IEFormElementGetObjByName($oForm2, "fieldD")
_IEFormElementSetValue($oQuery3, $aArray1[$c][3])
;-----------------------------------------------------------------------------
;Update date in IE
;-----------------------------------------------------------------------------
Local $oQuery4 = _IEFormElementGetObjByName($oForm2, "Date")
_IEFormElementSetValue($oQuery4, "01-06-2015");Set to the first of the month
;-----------------------------------------------------------------------------
;Submit form & prepare for next address
;-----------------------------------------------------------------------------
_IEFormSubmit($oForm2)
_IELoadWait($oIE)
WinWaitActive("Message")
ControlClick("Message", "OK", "[CLASS:Button;INSTANCE:1]");Confirmation message box, click "ok"
next

Occasionally the page might hang or be slow to load. Now because this will be running on a computer next to me, I need to be alerted if the my _IEnavigate hasn't worked because the web page is unavailable or if _ieloadwait is taking to long to load so I can check whether it's an issue with the server either being down, slow or it's just IE hanging & requires me to click submit again on a form to try again. If it's just the server being slow I need to know so I can stop the script and perhaps run it again when the server is performing at full potential.

I am aware I could probably build in functions to allow for such issues, but I would prefer to handle it this way with some sort of alert.

I was wondering how I could add a command that would play a sound if more than 3 minutes has passed between a loop?
Or if it's easier, if 3 minutes has passed and a page still hasn't loaded, something like:
 

If _IELoadWait($oIE) >  180000 Then ; IE has waited more than 3 minutes to load webpage
SoundPlay(@WindowsDir & "\media\tada.wav", 1)
EndIf

Any help here would be much appreciated.

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Thanks Jfish I will add that into my script, should be exactly what I'm after.

Just realized _IENavigate has that same functionality too so I would use that statement after that too I take it.

If I change _IELoadWaitTimeout from the default 5 mins to 2 mins I should then get a sound alert if either _IELoadWait or _IENavigate idles for longer than 2 minutes?

Edited by padinski

Share this post


Link to post
Share on other sites
If @error Then
EndIf
; Is suffice, unless you really really need to know it produced an error of 6

 

2 people like this

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_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()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_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()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Thanks for the help both of you.

Share this post


Link to post
Share on other sites

It's just if the function changes the @error codes and you missed the script breaking changes, then it still won't break your code. For when something went well, use...

If Not @error Then
EndIf

But again, it depends entirely on how important the @error code is to you. Some people like to be descriptive to the end user, others are find with a generic "Whoops, something went wrong" kind of message.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_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()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_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()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

That is a pretty cool little script, mind posting all of your includes? 

I may want to see about setting up some automation and use this as a base.

Share this post


Link to post
Share on other sites

That is a pretty cool little script, mind posting all of your includes? 

I may want to see about setting up some automation and use this as a base.

Hey mate used the following:
 

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>
#include <IE.au3>
#include <Excel.au3>

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