New question #260283 on Sikuli:
https://answers.launchpad.net/sikuli/+question/260283

Hello, I am automating a graph functionality and have to catch the value 
displayed in tooltip. The tooltip is displayed after hovering over the plot 
points plotted on graph. Is there any way where I can identify the tooltips 
displayed dynamically and create region for these tooltips dynamically. 
Currently I am using the tooltip image and generating region when tooltip image 
is displayed, but my script fails as the tooltip size changes depending upon 
the content or values in it.

Following is the code I am using:

def func(offSetImage, plotPointsImage):
    offSetImageRegion = Region(find(offSetImage))
    offSetImageRegion.highlight(1) # highlight matching offset image region on 
screen.
    # Dynamically generate new Graph Region
    graphRegion = Region(offSetImageRegion.x+20, offSetImageRegion.y-90, 
offSetImageRegion.w+1050, offSetImageRegion.h+200)
    graphRegion.highlight(1) # highlight matching graph image region on screen.
    
    counter = 0 # to calculate total plot points.
    intTemp = 0.0
    newTemp = valEx = 0
    for inc in graphRegion.findAll(plotPoints):
        counter += 1
        hover(inc)
        wait(tooltip, 2) # Wait for 2 seconds for the tooltip to display.
        if exists(tooltipImage):
            print "Tooltip is displayed"
            ttRegion = Region(find(tooltip)) #Dynamically generate Tooltip 
Region
            ttRegion.highlight(1) #highlight matching tooltip image region on 
screen.
            RegToolTipW = ttRegion.getW()
            revenueRegion = Region(ttRegion.find(revenue)) #Dynamically 
generate Region of field label
            revenueRegion.highlight(1)
            xcoordinate = revenueRegion.getW()
            new = Region(revenueRegion.x+xcoordinate, revenueRegion.y+0, 
RegToolTipW-xcoordinate, revenueRegion.h+0) # Region where actual value is 
displayed.
            new.highlight(1)
            val = new.text()
            print "texttest: ",val
            valre = re.search(p,val) # p is regular expression to get desired 
substring from the string.
            a = valre.group()
            print "group: ", a
            aa = float(a)
            intTemp = intTemp+aa
            print "temp: ", intTemp

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.

_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp

Reply via email to