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:
- The toolbar is recognized as an swfobject here
- We are accessing the CommandLinks collection to access individual buttons in the toolbar
- 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
Mnuname=Mnubar.Item(i).Text
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("").Activate
SwfWindow("").SwfObject("").Click iX,iY
Next
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!
Comments
Post a Comment