Combo box scrolling
I have a widget called a combo box. If I click it, I get a scrollable list of options. I want to potentialy scroll through the entire list to find my desired option, since only some of the available options are visable at any one time and I don't know where I will start at in the list. An answer to Question #205813 suggest checking to see when the image stops changing as a means of determining having reached either end of the scroll list. But I can't get that onChange to work right.
A selected item in the scroll list is highlighted blue. Some image comparisons mistakenly key off of that blue bar, which no longer works when the blue bar does not change relative position. The selected item also shows up unhighlighted at the top of the list, which is another area I've tried to do image comparisons on.
I can't figure out how to manualy compare a saved image of the list from prior to the last scroll to what the list currently looks like. At times my comparisons are saying nothing has changed too soon, and at other times my comparisons are not detecting the fact that nothing has changed. If I do an exists, I have to do so within a region, instead of a previosly saved image, and I can't throw a similar qualifier on it. If I use getScore, I either can't attach that to the previous exists, or the score does not reflect my desired match.
My first combo box is just a list of months. I should be able to force some kind of nearly exact match on the text of the month name, but I can't.
import shutil
import os
Settings.
Settings.
Settings.
#setFindFailedR
click(Pattern(
direction = WHEEL_DOWN # direction of wheeling/scrolling
reachedBottom = False # flag to see if bottom of the list was reached
reachedTop = False # flag to see if top of the list was reached
entryFound = False # is set True if the image was found
maxScrolls = 20 # maximum number of scroll attempts
# the image that is searched in the list
#goalImage = "October.png"
goalImage = "January.png"
click(Pattern(
wait(3)
click(Pattern(
#smallRegion = getLastMatch(
reg = getLastMatch()
#smallRegion = Region(reg.x + 40, reg.y, reg.w-40, reg.h+140)
smallRegion = Region(reg.x + 42, reg.y, reg.w-42, reg.h)
lastImage = capture(
shutil.
for i in range(maxScrolls): # avoid endless loop
thisImage = capture(
shutil.
if (Region(
print("did not find %d"%(i))
if (direction == WHEEL_DOWN): # scroll down
else:
wait(4)
#if (lastImage.
#if (Region(
if (smallRegion.
#if (smallRegion.
if (direction == WHEEL_DOWN): # bottom reached, change wheel direction
else: # top reached, change wheel direction
if (reachedTop == True and reachedBottom == True): # both ends of the dropdown-menu were reached, no more scrolling needed.
else:
else: # entry was found
entryFound = True
break
if (entryFound): # do stuff if successfull
click(
print("found & clicked")
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- SikuliX Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- RaiMan
- Solved:
- Last query:
- Last reply: