#include #include opt("mousecoordmode",1) ;set the mouse co-ordinate mode to absolute opt("pixelcoordmode",1) ;set the pixel co-ordinate mode to absolute AutoItSetOption("MustDeclareVars", 1) ;ensure that all variables have to be declared dim $MSSTextBoxX, $MSSTextBoxY dim $MSSSearchButtonX, $MSSSearchButtonY dim $MSSViArrowX, $MSSViArrowY dim $MSSViewLinkX, $MSSViewLinkY dim $MSSWindowTop, $MSSWindowLeft, $MSSWindowHeight, $MSSWindowWidth, $MSSWindowSize dim $MSSPeriodDropDownArrowX, $MSSPeriodDropDownArrowY dim $MSSViewLinkBoxLeft, $MSSViewLinkBoxRight, $MSSViewLinkBoxBottom, $MSSViewLinkBoxTop dim $XLMacroX, $XLMacroY dim $InputFile, $ThisLine, $LastLine dim $i, $multiplier, $temp, $NoResult, $Debugging, $GoodCount, $BadCount, $Failures dim $BlackPixelLocation[2] dim $OrangePixelLocation[2] $Debugging = False ;record the base position for MSS msgbox(0,"Set the home position","Move the mouse to the arrow next to the router Vi reporting state arrow",5) $MSSViArrowX = mousegetpos(0) $MSSViArrowY = mousegetpos(1) ;derive the other key positions for MSS $MSSTextBoxX = $MSSViArrowX $MSSTextBoxY = $MSSViArrowY-50 $MSSSearchButtonX = $MSSTextBoxX+300 $MSSSearchButtonY = $MSSTextBoxY $MSSViewLinkX = $MSSViArrowX +250 $MSSViewLinkY = $MSSViArrowY +30 $MSSViewLinkBoxLeft = $MSSViArrowX +225 $MSSViewLinkBoxRight = $MSSViewLinkBoxLeft + 55 $MSSViewLinkBoxTop = $MSSViArrowY + 17 $MSSViewLinkBoxBottom = $MSSViewLinkBoxTop + 25 ;record the base position for Excel msgbox(0,"Set the home position","Move the mouse to run macro button in Excel",5) $XLMacroX = mousegetpos(0) $XLMacroY = mousegetpos(1) ;initialise the variables for the run $i=1 $multiplier = 0 $LastLine = "" $GoodCount = 0 $BadCount = 0 $Failures = "" $InputFile = "c:\temp\site list.txt" $BlackPixelLocation[0] = 0 $BlackPixelLocation[1] = 0 $OrangePixelLocation[0] = 0 $OrangePixelLocation[1] = 0 $ThisLine = FileReadLine($InputFile,$i) ;process the file while @error <> -1 ;@error will equal -1 when EoF reached $NoResult = false ;reset for the loop if StringCompare($ThisLine,$LastLine) = 0 then ; to cope with multi interfaces on the same router $multiplier = $multiplier+1 else $multiplier = 0 Endif if $Debugging then msgbox(0,"Input",$ThisLine & " " & $LastLine & " " & $multiplier) ;click in the MSS Search box, select all existing text and replace it with the next entry from the file mouseclick("left",$MSSTextBoxX, $MSSTextBoxY,2) ;2 clicks ensures this is the active window send("^a") send($ThisLine) mouseclick("left",$MSSSearchButtonX, $MSSSearchButtonY) ;click the search button mouseclick("left",$MSSViArrowX, $MSSViArrowY) ;expand the search results (if any) ;check the search found something by looking for an orange pixel (i.e. view linktext) near where the Vi Arrow should be $OrangePixelLocation = PixelSearch($MSSViewLinkBoxLeft,$MSSViewLinkBoxTop,$MSSViewLinkBoxRight,$MSSViewLinkBoxBottom,0xFF6600,0) if (@error<>0) then ;i.e. no result found $NoResult = True if $Debugging then msgbox(0,"First Search Failed","First Search Error Code was " & @error) EndIf if ($Debugging and (not($NoResult))) then msgbox(0,"First Search Success","Orange pixel found at X=" &$OrangePixelLocation[0] & ", Y=" & $OrangePixelLocation[1]) if (not($NoResult)) then ;click the view link MouseMove($MSSViewLinkX, $MSSViewLinkY + ($multiplier * 26)) mouseclick("left",$MSSViewLinkX, $MSSViewLinkY + ($multiplier * 26)) ;determine the size of the current window which will give us the button position as ; X being the left edge + 115 and Y being the top + the height - 45 $MSSWindowSize = WinGetPos("[active]") $MSSWindowLeft = $MSSWindowSize[0] $MSSWindowTop = $MSSWindowSize[1] $MSSWindowWidth = $MSSWindowSize[2] $MSSWindowHeight = $MSSWindowSize[3] $MSSPeriodDropDownArrowX = $MSSWindowLeft+115 $MSSPeriodDropDownArrowY = $MSSWindowTop + $MSSWindowHeight-45 sleep(10000) ;wait for the next screen to load ;set the data period to the last month MouseClick("left",$MSSPeriodDropDownArrowX, $MSSPeriodDropDownArrowY) ;click the drop down MouseClick("left",$MSSPeriodDropDownArrowX-60, $MSSPeriodDropDownArrowY-70) ;click "last month" MouseClick("left",$MSSWindowLeft+$MSSWindowWidth-70,$MSSPeriodDropDownArrowY) ;click "submit" sleep(15000) ;wait for the next screen to load ;check there is actually data for month by looking for a black pixel near where the graph should be $BlackPixelLocation = PixelSearch($MSSViArrowX,$MSSViArrowY-50,$MSSViArrowX+200,$MSSViArrowY+50,0x000000,100) if @error<>0 then ;i.e. no result found $NoResult = True send("^{F4}") ;close the current data set window (it may or may not be a blank one) if $Debugging then msgbox(0,"Second Search Failed","Second Search Error Code was " & @error) EndIf if ($Debugging and (not($NoResult))) then msgbox(0,"Second Search Success","Black pixel found at X=" &$temp[0] &", Y=" & $temp[1]) if (not($NoResult)) then MouseClick("left",$MSSWindowLeft + ($MSSWindowWidth/2)-100, $MSSWindowTop+194) ;download the last month raw data sleep(30000) ;wait for the data to download MouseClick("left",$MSSPeriodDropDownArrowX, $MSSPeriodDropDownArrowY) ;click the drop down MouseClick("left",$MSSPeriodDropDownArrowX-60, $MSSPeriodDropDownArrowY-15) ;click "last 365 days" MouseClick("left",$MSSWindowLeft+$MSSWindowWidth-70,$MSSPeriodDropDownArrowY) ;click "submit" sleep(15000) ;wait for the next screen to load MouseClick("left",$MSSWindowLeft + ($MSSWindowWidth/2)-80, $MSSWindowTop+194) ;download the 365 days data sleep(20000) ;wait for the data to download ;close the current data set window (it may or may not be a blank one) send("^{F4}") MouseClick("left",$XLMacroX+50,$XLMacroY);activate Excel MouseClick("left",$XLMacroX,$XLMacroY);run the Excel macro $GoodCount = $GoodCount + 1 ;increment the count of good router data EndIf EndIf ;if there was no data for any reason, increment the BadCount and note the name of the router with no data If $NoResult then $BadCount = $BadCount +1 $Failures = $Failures & $ThisLine & "," EndIf ;check to see, every 10 routers, if we want to continue if (mod($i,5)=0) then $temp = msgbox(4, "Process more routers?", $i & " routers processed. Do you want to continue?", 10) if $temp = 7 then ExitLoop ;7=no, 6=yes and -1=timeout ;prepare for the next run $LastLine = $ThisLine $i = $i +1 $ThisLine = FileReadLine($InputFile,$i) Wend msgbox(0,"File Processing Results",$i-1 & " routers looked at from file " & $InputFile & chr(13) & $GoodCount & " good data sets found & " & $BadCount & " sets of missing data") if $BadCount <> 0 then msgbox(0,"Failure List","The following routers had no data" & chr(13) & $Failures)