Sign in to follow this  
Followers 0
AllanS

_IETableWriteToArray and the Tray Menu

2 posts in this topic

Hi Guys,

I'm having trouble with updating tray menu items from an array created by _IETableWriteToArray function.

/// This script works without any issues:

#include <Array.au3>
#include <IE.au3>
#include <Constants.au3>

GUISetIcon(@WindowsDir & "\system32\shell32.dll", 269)
TraySetIcon(@WindowsDir & "\system32\shell32.dll", 269)
TraySetToolTip("Agent Status Monitor")

Opt("TrayAutoPause",0)
TrayTip("Agent Status Monitor","Click this icon to display the status of your agents.",5,0)

$oAgentStatusURL = "C:\Documents and Settings\AllanS\Desktop\Agent Status Monitor\ExpRep-223869650.html"
$oAgentStatus = _IECreate($oAgentStatusURL,0)
_IELoadWait($oAgentStatus)

$oAgentStatusTable = _IETableGetCollection($oAgentStatus, 0)
$oAgentStatusArray = _IETableWriteToArray($oAgentStatusTable, True)

;_ArrayDisplay($oAgentStatusArray)
$StartPoint = 6

for $i = $StartPoint to UBound($oAgentStatusArray)-1
    Global $oMasterMenu[100][100], $oMasterMenuItem[100][100]
    $oMasterMenu[0][$i] = TrayCreateMenu($oAgentStatusArray[$i][0])
    $oMasterMenuItem[$i][0] = TrayCreateItem($oAgentStatusArray[$i][4], $oMasterMenu[0][$i])
    $oMasterMenuItem[$i][1] = TrayCreateItem($oAgentStatusArray[$i][5], $oMasterMenu[0][$i])
Next

While 1 ;reload the tray menu items every 60 secs.
    _IENavigate($oAgentStatus ,$oAgentStatusURL)
    _IELoadWait($oAgentStatus)

    $oAgentStatusTable = _IETableGetCollection($oAgentStatus, 0)
    $oAgentStatusArray = _IETableWriteToArray($oAgentStatusTable, True)

        for $j = $StartPoint to UBound($oAgentStatusArray)-1
            TrayItemSetText($oMasterMenuItem[$j][0], $oAgentStatusArray[$j][4])
            TrayItemSetText($oMasterMenuItem[$j][1], $oAgentStatusArray[$j][5])
        next

    sleep(60000)
WEnd

/// This script fails to reload the tray menu items from the _IETableWriteToArray array. (The above script is very similar to this one, and works perfect)

#include <Array.au3>
#include <IE.au3>
#include <Constants.au3>

GUISetIcon(@WindowsDir & "\system32\shell32.dll", 167)
TraySetIcon(@WindowsDir & "\system32\shell32.dll", 167)
TraySetToolTip("Service Levels Monitor")

Opt("TrayAutoPause",0)
TrayTip("Service Levels Monitor","Click this icon to display the service levels.",5,0)

$oServiceLevelsURL = "C:\Documents and Settings\AllanS\Desktop\Service Levels Monitor\ExpRep-1232280670.html"
$oServiceLevels = _IECreate($oServiceLevelsURL,0)
_IELoadWait($oServiceLevels)

$oServiceLevelsTable = _IETableGetCollection($oServiceLevels, 0)
$oServiceLevelsArray = _IETableWriteToArray($oServiceLevelsTable, True)

;_ArrayDisplay($oServiceLevelsArray)
$StartPoint = 4

for $i = $StartPoint to UBound($oServiceLevelsArray)-2
    Global $oMasterMenu[100][100], $oMasterMenuItem[100][100]
    $oMasterMenu[0][$i] = TrayCreateMenu($oServiceLevelsArray[$i][0])
    $oMasterMenuItem[$i][0] = TrayCreateItem("SL% Today: " & $oServiceLevelsArray[$i][2], $oMasterMenu[0][$i])
    $oMasterMenuItem[$i][1] = TrayCreateItem("SL% Last 30 Mins: " & $oServiceLevelsArray[$i][3], $oMasterMenu[0][$i])
    $oMasterMenuItem[$i][2] = TrayCreateItem("Calls Today: " & $oServiceLevelsArray[$i][4], $oMasterMenu[0][$i])
    $oMasterMenuItem[$i][3] = TrayCreateItem("Calls Queued: " & $oServiceLevelsArray[$i][6], $oMasterMenu[0][$i])
Next

While 1 ;reload the tray menu items every 60 secs.
    _IENavigate($oServiceLevels ,$oServiceLevelsURL)
    _IELoadWait($oServiceLevels)

    $oServiceLevelsTable = _IETableGetCollection($oServiceLevels, 0)
    $oServiceLevelsArray = _IETableWriteToArray($oServiceLevelsTable, True)

        for $j = $StartPoint to UBound($oServiceLevelsArray)-2
            TrayItemSetText($oMasterMenuItem[$j][0], "SL% Today: " & $oServiceLevelsArray[$j][2])
            TrayItemSetText($oMasterMenuItem[$j][1], "SL% Last 30 Mins: " & $oServiceLevelsArray[$j][3])
            TrayItemSetText($oMasterMenuItem[$j][2], "Calls Today: " & $oServiceLevelsArray[$j][4])
            TrayItemSetText($oMasterMenuItem[$j][3], "Calls Queued: " & $oServiceLevelsArray[$j][6])
        next

    sleep(60000)
WEnd

Would anyone have some ideas on how to resolve this issue.

Share this post


Link to post
Share on other sites



Instrument your loop to see if the values are what you expected. Something like this:

While 1 ;reload the tray menu items every 60 secs.
    _IENavigate($oServiceLevels ,$oServiceLevelsURL)
    _IELoadWait($oServiceLevels)

    $oServiceLevelsTable = _IETableGetCollection($oServiceLevels, 0)
    $oServiceLevelsArray = _IETableWriteToArray($oServiceLevelsTable, True)
    _ArrayDisplay($oServiceLevelsTable, "Debug: $oServiceLevelsTable")
        for $j = $StartPoint to UBound($oServiceLevelsArray)-2
            ConsoleWrite("Debug: $j = " & $j & @LF)
            TrayItemSetText($oMasterMenuItem[$j][0], "SL% Today: " & $oServiceLevelsArray[$j][2])
            TrayItemSetText($oMasterMenuItem[$j][1], "SL% Last 30 Mins: " & $oServiceLevelsArray[$j][3])
            TrayItemSetText($oMasterMenuItem[$j][2], "Calls Today: " & $oServiceLevelsArray[$j][4])
            TrayItemSetText($oMasterMenuItem[$j][3], "Calls Queued: " & $oServiceLevelsArray[$j][6])
        next

    sleep(60000)
WEnd

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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
Sign in to follow this  
Followers 0