deef99 Posted October 31, 2011 Share Posted October 31, 2011 The code below exists in a folder on the network. About 10 uses execute the app and use it throughout the day. It does several things: 1. Alerts them to phone calls that are waiting if a threshold is meet by playing a sound and splashing text on the screen2. Writes to a log file - a unique file is created each time the user starts the app so all 10 users are not trying to write to the same file at the same time. 3. Remembers that the splash is on so it does not continue the sound which would annoy the people on the phone.4. Removes the splashed text once the calls are gone. My problem is... it works sporatically. I expected that if a threshold is met, that every log file would get written to and every PC would get the sound and the splash text. Not all do...and I just don't know where I am going wrong... Anybody have any ideas what I could have wrong here? I appreciate any time you might have to take a look at it... Many thanks in advance. #Region ;**** Directives created by AutoIt3Wrapper_GUI ****#AutoIt3Wrapper_Outfile=g:\Avaya_OS_Ticker\CallTicker_NS.exe#AutoIt3Wrapper_UseUpx=n#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****#include <Date.au3>#include <File.au3>#include "array.au3"#include "String.au3"#include <Sound.au3>#include <Constants.au3>Opt("TrayMenuMode", 0) ; Default tray menu items (Script Paused/Exit) will not be shown.Opt("WinTitleMatchMode", 1) ;1=start of textHotKeySet("^z", "Terminate"); Press Ctrl z to terminate script ;LIVE Aug2011 Checks file in g:\Avaya_OS_Ticker to see if Calls waiting for Major skills and pops on agent desktop Global $result, $vskill, $vOCW, $pt, $pd, $rr, $tCur, $tday, $search, $logfile, $hds, $hdn, $jd, $jd1, $jd2, $jd3, $jd4, $splay, $iq, $newlogGlobal $aLines$message = ""$hds = 0$jd = 0$jd1 = 0$jd2 = 0$jd3 = 0$jd4 = 0$hdn = 0 ;open sound file$sound = _SoundOpen("\\files02\common\Avaya_OS_Ticker\tada.wav", "Startup");set the MM_YYYY for log file$tday = @MON & "_" & @MDAY ;create unique log file name$newlog = Random(10, 10000, 1)$logfile = "\\files02\common\Avaya_OS_Ticker\SkillCheck_Log" & $tday & $newlog & ".txt"If FileExists($logfile) Then $logfile = "\\files02\common\Avaya_OS_Ticker\SkillCheck_Log" & $tday & $newlog & @MSEC & ".txt"EndIf;get the current hour and min$tCur = @MON & "/" & @MDAY & "," & @HOUR & ":" & @MIN & " - "While 9 = 9 _FileReadToArray("\\files02\common\avaya_OS_ticker\skillcheck.txt", $aLines) For $i = 1 To $aLines[0] $line = $aLines[$i] ;MsgBox(0,"",$line) ;grab the skill, OCW,in queue $vskill = StringMid($line, 1, 3) $vOCW = StringMid($line, 5, 3) $iq = StringRight($line, 2) If StringLeft($iq, 1) = "," Then $iq = StringRight($iq, 1) EndIf If StringRight($vOCW, 1) = "," Then $vOCW = StringLeft($vOCW, 2) EndIf FileOpen($logfile, 1) ;-----start skill checking ------------------------------------------------------------------------ If (($vOCW >= 150 Or $iq >= 5) And $vskill = "690") Then $vskill = "HD Supplements" If $hds = 0 Then $result = $vskill & " shows OCW " & $vOCW & " seconds -- " & $iq & " Calls in Queue" FileWrite($logfile, $tCur & $result & @CRLF) _SoundPlay($sound, 1) $hds = 1 ;played sound set flag to no sound ;FileClose($logfile) EndIf $message = $vskill & " has Calls in Queue!" SplashTextOn("LOG IN IMMEDIATELY!", $message, 250, 40, 875, 12, -1, "Arial", 9, 500) ControlSetText("LOG IN IMMEDIATELY!", "", "Static1", $message) Sleep(2000) ElseIf (($vOCW < 150 Or $iq < 5) And $hds = 1 And $vskill = "690") Then $hds = 0 SplashOff() EndIf ;------------------------------------------------------------------------------------------------------ If (($vOCW >= 150 Or $iq >= 3) And $vskill = "644") Then $vskill = "John Deere Frontier" If $jd4 = 0 Then _SoundPlay($sound, 1) $result = $vskill & " shows OCW " & $vOCW & " seconds -- " & $iq & " Calls in Queue" FileWrite($logfile, $tCur & $result & @CRLF) $jd4 = 1 ;played sound set flag to no sound ;FileClose($logfile) EndIf $message = $vskill & " has Calls in Queue!" SplashTextOn("LOG IN IMMEDIATELY!", $message, 250, 40, 875, 15, -1, "Arial", 10, 500) ControlSetText("LOG IN IMMEDIATELY!", "", "Static1", $message) $result = $vskill & " shows OCW: " & $vOCW & " seconds" Sleep(2000) ElseIf (($vOCW < 150 Or $iq < 3) And $jd4 == 1 And $vskill = "644") Then $jd4 = 0 SplashOff() EndIf ;------------------------------------------------------------------------------------------------------ If (($vOCW >= 150 Or $iq >= 3) And $vskill = "650") Then $vskill = "John Deere MCCC" If $jd1 = 0 Then _SoundPlay($sound, 1) $result = $vskill & " shows OCW " & $vOCW & " seconds -- " & $iq & " Calls in Queue" FileWrite($logfile, $tCur & $result & @CRLF) $jd1 = 1 ;played sound set flag to no sound ;FileClose($logfile) EndIf $message = $vskill & " has Calls in Queue!" SplashTextOn("LOG IN IMMEDIATELY!", $message, 250, 40, 875, 15, -1, "Arial", 10, 500) ControlSetText("LOG IN IMMEDIATELY!", "", "Static1", $message) $result = $vskill & " shows OCW: " & $vOCW & " seconds" Sleep(2000) ElseIf (($vOCW < 150 Or $iq < 3) And $jd1 = 1 And $vskill = "650") Then $jd1 = 0 SplashOff() EndIf ;------------------------------------------------------------------------------------------------------ If (($vOCW >= 150 Or $iq >= 3) And $vskill = "651") Then $vskill = "John Deere Ecrate" If $jd2 = 0 Then _SoundPlay($sound, 1) $result = $vskill & " shows OCW " & $vOCW & " seconds -- " & $iq & " Calls in Queue" FileWrite($logfile, $tCur & $result & @CRLF) $jd2 = 1 ;played sound set flag to no sound ;FileClose($logfile) EndIf $message = $vskill & " has Calls in Queue!" SplashTextOn("LOG IN IMMEDIATELY!", $message, 250, 40, 875, 15, -1, "Arial", 10, 500) ControlSetText("LOG IN IMMEDIATELY!", "", "Static1", $message) Sleep(2000) ElseIf (($vOCW < 150 Or $iq < 3) And $jd2 = 1 And $vskill = "651") Then $jd2 = 0 SplashOff() EndIf ;------------------------------------------------------------------------------------------------------ If (($vOCW >= 150 Or $iq >= 3) And $vskill = "652") Then $vskill = "John Deere Transportation" If $jd3 = 0 Then _SoundPlay($sound, 1) $result = $vskill & " shows OCW " & $vOCW & " seconds -- " & $iq & " Calls in Queue" FileWrite($logfile, $tCur & $result & @CRLF) $jd3 = 1 ;played sound set flag to no sound ;FileClose($logfile) EndIf $message = $vskill & " has Calls in Queue!" SplashTextOn("LOG IN IMMEDIATELY!", $message, 250, 40, 875, 15, -1, "Arial", 10, 500) ControlSetText("LOG IN IMMEDIATELY!", "", "Static1", $message) $result = $vskill & " shows OCW: " & $vOCW & " seconds" Sleep(2000) ElseIf ($vOCW < 150 And $iq < 3 And $jd3 = 1 And $vskill = "652") Then $jd3 = 0 SplashOff() EndIf ;------------------------------------------------------------------------------------------------------ If (($vOCW >= 150 Or $iq >= 5) And $vskill = "707") Then $vskill = "John Deere CCC" If $jd = 0 Then _SoundPlay($sound, 1) $result = $vskill & " shows OCW " & $vOCW & " seconds -- " & $iq & " Calls in Queue" FileWrite($logfile, $tCur & $result & @CRLF) $jd = 1 ;played sound set flag to no sound ;FileClose($logfile) EndIf $message = $vskill & " has Calls in Queue!" SplashTextOn("LOG IN IMMEDIATELY!", $message, 250, 40, 875, 18, -1, "Arial", 9, 500) ControlSetText("LOG IN IMMEDIATELY!", "", "Static1", $message) $result = $vskill & " shows OCW: " & $vOCW & " seconds" Sleep(2000) ElseIf (($vOCW < 150 Or $iq < 3) And $jd = 1 And $vskill = "707") Then $jd = 0 SplashOff() EndIf ;------------------------------------------------------------------------------------------------------ If $vOCW >= 150 And $vskill = "740" Then $vskill = "HD Newsletters" If $hdn = 0 Then _SoundPlay($sound, 1) $result = $vskill & " shows OCW " & $vOCW & " seconds -- " & $iq & " Calls in Queue" FileWrite($logfile, $tCur & $result & @CRLF) $hdn = 1 ;played sound set flag to no sound ;FileClose($logfile) EndIf $message = $vskill & " has Calls in Queue!" SplashTextOn("LOG IN IMMEDIATELY!", $message, 250, 40, 875, 15, -1, "Arial", 10, 500) ControlSetText("LOG IN IMMEDIATELY!", "", "Static1", $message) $result = $vskill & " shows OCW: " & $vOCW & " seconds" Sleep(2000) ElseIf ($vOCW < 150 And $hdn = 1 And $vskill = "740") Then $hdn = 0 SplashOff() EndIf Next Sleep(2000)WEndFileClose($logfile)_SoundClose($sound)Func Terminate() Exit 0EndFunc ;==>Terminate Link to comment Share on other sites More sharing options...
Tvern Posted October 31, 2011 Share Posted October 31, 2011 (edited) I had a shot at this, but it's just not clear from the script how it's meant to work. Mostly because there is no information about what the skillcheck.txt file contains, in what format and how it is updated when calls are added/removed from the queue. Also, because you are using different flags for each skill, sounds of some skills will still play, even when they are blocked for one, or more other skills. I would try to change it into something like this, but I'm stuck without more info. p.s. use [ autoit] and [ /autoit] tags, like this: expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=g:\Avaya_OS_Ticker\CallTicker_NS.exe #AutoIt3Wrapper_UseUpx=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <File.au3> #include <Sound.au3> Opt("TrayMenuMode", 0) ; Default tray menu items (Script Paused/Exit) will not be shown. Opt("WinTitleMatchMode", 1) ;1=start of text HotKeySet("^z", "Terminate"); Press Ctrl z to terminate script ;LIVE Aug2011 Checks file in g:\Avaya_OS_Ticker to see if Calls waiting for Major skills and pops on agent desktop Global $hFile, $hSound Global $iIq, $iNum, $iOCW Global $sResult, $sPath, $sTime, $sMessage Global $vSkill Global $fRun = True, $fDebug = True Global $aLines, $aSkills[7][4] ;might want to read this array from a file $aSkills[0][0] = "690" ;skill id $aSkills[0][1] = 5 ;skill iq number $aSkills[0][2] = "HD Supplements" ;skill name $aSkills[0][3] = 0 ;soundplay flag $aSkills[1][0] = "644" $aSkills[1][1] = 3 $aSkills[1][2] = "John Deere Frontier" $aSkills[1][3] = 0 $aSkills[2][0] = "650" $aSkills[2][1] = 3 $aSkills[2][2] = "John Deere MCCC" $aSkills[2][3] = 0 $aSkills[3][0] = "651" $aSkills[3][1] = 3 $aSkills[3][2] = "John Deere Ecrate" $aSkills[3][3] = 0 $aSkills[4][0] = "652" $aSkills[4][1] = 3 $aSkills[4][2] = "John Deere Transportation" $aSkills[4][3] = 0 $aSkills[5][0] = "707" $aSkills[5][1] = 5 $aSkills[5][2] = "John Deere CCC" $aSkills[5][3] = 0 $aSkills[6][0] = "740" $aSkills[6][1] = 0 $aSkills[6][2] = "HD Newsletters" $aSkills[6][3] = 0 ;open sound file $hSound = _SoundOpen("\\files02\common\Avaya_OS_Ticker\tada.wav") ;create unique log file name $sPath = "\\files02\common\Avaya_OS_Ticker\SkillCheck_Log" & @MON & "_" & @MDAY & "(" $iNum = 1 While FileExists($sPath & $iNum & ").txt") $iNum += 1 WEnd ;open logfile $hFile = FileOpen($sPath, 1) While $fRun _FileReadToArray("\\files02\common\avaya_OS_ticker\skillcheck.txt", $aLines) For $i = 1 To $aLines[0] ;grab the skill, OCW,in queue ;this can be improved if you supply the format the data comes in. It also needs errorchecking. $vSkill = StringMid($aLines[$i], 1, 3) StringMid($aLines[$i], 5, 3) StringRight($aLines[$i], 2) If StringLeft($iIq, 1) = "," Then $iIq = StringRight($iIq, 1) EndIf If StringRight($iOCW, 1) = "," Then $iOCW = StringLeft($iOCW, 2) EndIf $iOCW = Number($iOCW) ;check if this value is correct! $iIq = Number($iIq) ;check if this value is correct! For $n = 0 To UBound($aSkills)-1 If $vSkill = $aSkills[$n][2] Then If $iOCW >= 150 Or $iIq >= $aSkills[$n][1] Then If $aSkills[$n][3] = 0 Then $sResult = @MON & "/" & @MDAY & "," & @HOUR & ":" & @MIN & " - " & $aSkills[$n][2] & " shows OCW " & $iOCW & " seconds -- " & $iIq & " Calls in Queue" & @CRLF FileWrite($hFile,$sResult) _SoundPlay($hSound, 1) $aSkills[$n][3] = 1 ;played sound set flag to no sound EndIf SplashTextOn("LOG IN IMMEDIATELY!", $aSkills[$n][3] & " has Calls in Queue!", 250, 40, 875, 12, -1, "Arial", 9, 500) ControlSetText("LOG IN IMMEDIATELY!", "", "Static1", $aSkills[$n][3] & " has Calls in Queue!") Sleep(2000) ElseIf $aSkills[$n][3] = 1 Then $aSkills[$n][3] = 0 SplashOff() EndIf ExitLoop EndIf Next Next Sleep(2000) WEnd FileClose($hFile) _SoundClose($hSound) Exit Func Terminate() $fRun = False EndFunc Edited October 31, 2011 by Tvern Link to comment Share on other sites More sharing options...
deef99 Posted October 31, 2011 Author Share Posted October 31, 2011 (edited) Thank you for looking into this!!!! Skillcheck.txt looks like this: 640,0,0 641,0,0 642,0,0 643,0,0 644,0,0 650,0,0 651,0,0 652,0,0 655,0,0 690,0,0 707,0,0 740,0,0 The first item is the skill number, the second is the calls in queue, and the third is how long the call has been waiting in queue. This file gets updated every 5 seconds... Edited October 31, 2011 by deef99 Link to comment Share on other sites More sharing options...
Tvern Posted October 31, 2011 Share Posted October 31, 2011 Something like this? expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=g:\Avaya_OS_Ticker\CallTicker_NS.exe #AutoIt3Wrapper_UseUpx=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <File.au3> #include <Sound.au3> Opt("TrayMenuMode", 0) ; Default tray menu items (Script Paused/Exit) will not be shown. Opt("WinTitleMatchMode", 1) ;1=start of text HotKeySet("^z", "Terminate"); Press Ctrl z to terminate script ;LIVE Aug2011 Checks file in g:\Avaya_OS_Ticker to see if Calls waiting for Major skills and pops on agent desktop Global $hFile, $hSound Global $iQueue, $iNum, $iTime Global $sResult, $sPath, $sTime, $sMessage Global $iSkill Global $fRun = True, $fDebug = True, $fPlayed Global $aLines, $aSkills[7][3], $aTemp ;might want to read this array from a file $aSkills[0][0] = "690" ;skill id $aSkills[0][1] = 5 ;skill iq number $aSkills[0][2] = "HD Supplements" ;skill name $aSkills[1][0] = "644" $aSkills[1][1] = 3 $aSkills[1][2] = "John Deere Frontier" $aSkills[2][0] = "650" $aSkills[2][1] = 3 $aSkills[2][2] = "John Deere MCCC" $aSkills[3][0] = "651" $aSkills[3][1] = 3 $aSkills[3][2] = "John Deere Ecrate" $aSkills[4][0] = "652" $aSkills[4][1] = 3 $aSkills[4][2] = "John Deere Transportation" $aSkills[5][0] = "707" $aSkills[5][1] = 5 $aSkills[5][2] = "John Deere CCC" $aSkills[6][0] = "740" $aSkills[6][1] = 0 $aSkills[6][2] = "HD Newsletters" ;open sound file $hSound = _SoundOpen("\\files02\common\Avaya_OS_Ticker\tada.wav") ;create unique log file name $sPath = "\\files02\common\Avaya_OS_Ticker\SkillCheck_Log" & @MON & "_" & @MDAY & "(" $iNum = 1 While FileExists($sPath & $iNum & ").txt") $iNum += 1 WEnd ;open logfile $hFile = FileOpen($sPath, 1) While $fRun _FileReadToArray("\\files02\common\avaya_OS_ticker\skillcheck.txt", $aLines) For $i = 1 To $aLines[0] ;grab the skill, OCW,in queue ;this can be improved if you supply the format the data comes in. It also needs errorchecking. $aTemp = StringSplit($aLines[$i],",") If $aTemp[0] <> 3 Then MsgBox(0,"error!", "skillcheck.txt is not correctly formatted" & @CRLF & "line " & $i & " = " & $aLines[$i]) ExitLoop 2 EndIf $iSkill = Number($aTemp[1]) ;skill number $iQueue = Number($aTemp[2]) ;Queue size $iTime = Number($aTemp[3]) ;time in queue For $n = 0 To UBound($aSkills)-1 If $iSkill = $aSkills[$n][2] Then If $iTime >= 150 Or $iQueue >= $aSkills[$n][1] Then If $fPlayed = False Then $sResult = @MON & "/" & @MDAY & "," & @HOUR & ":" & @MIN & " - " & $aSkills[$n][2] & " shows OCW " & $iTime & " seconds -- " & $iQueue & " Calls in Queue" & @CRLF FileWrite($hFile,$sResult) _SoundPlay($hSound, 1) $fPlayed = True EndIf SplashTextOn("LOG IN IMMEDIATELY!", $aSkills[$n][3] & " has Calls in Queue!", 250, 40, 875, 12, -1, "Arial", 9, 500) ControlSetText("LOG IN IMMEDIATELY!", "", "Static1", $aSkills[$n][3] & " has Calls in Queue!") Sleep(2000) ElseIf $fPlayed Then $fPlayed = False SplashOff() EndIf ExitLoop EndIf Next Next Sleep(2000) WEnd FileClose($hFile) _SoundClose($hSound) Exit Func Terminate() $fRun = False EndFunc I've got to go now, I hope you'll be able to work with that. Link to comment Share on other sites More sharing options...
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