Click on .net toolbar using bounds property

In continuation to the previous post Automation of the .NET ToolbarsManager , here is the code that will click on any toolbars button using the bounds property :

Note that:
  1. The toolbar is recognized as an swfobject here
  2. We are accessing the CommandLinks collection to access individual buttons in the toolbar
  3. Using an array to get the bounds and then clicking on the respective button.

Set Mnubar = SwfWindow("").SwfObject("").Object.CommandLinks

For i = 0 To Mnubar.Count -1
    msgbox Mnuname
    oBounds = Mnubar.Item(i).Bounds
    arrBounds = Split(oBounds, ",")
    arrBound = Split(arrBounds(0), "=")
    iX = CInt(arrBound(1))
    arrBound = Split(arrBounds(1), "=")
    iY = CInt(arrBound(1))
    SwfWindow("").SwfObject("").Click iX,iY   

We can make this code more generic by passing the name of the button or the tooltip of the button which has to be clicked.

Hope this helps... Happy Automating!


Popular posts from this blog

Trim / Remove spaces in Xpath?

RPA - Blue Prism, OpenSpan, Automation Anywhere vs UIPath