button matrix

Asked by Mic Cross

Just started sikula tonight so total newbie ... the gui is a matrix of small square buttons 20 by 10 ..... do I need to try and capture every one, or can I capture the block and somehow interpolate inside with x = topLeft + (btnCount*5) etc? tia

 .... the gui is like a spreadsheet of tiny buttons ... looking at region and pattern - am I getting warm? :-) tia

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Roman Podolyan
Solved:
Last query:
Last reply:
Revision history for this message
Best Roman Podolyan (podolyan-roman) said :
#1

Errrrrrr... what you mean by 'capture' here?

If you want to click the buttons, and the button matrix is static, all buttons have same width and same height, of course, you can build a function which captures one top left button, gets some "zero coordinates" out of its position, and then returns coordinates for screen Click from button row/column number.

You need just build that function measuring single button length and interval between two buttons.

It would look like:

x = topleft_button_center_x + (column - 1) * (button_width + horizontal_interval_between_buttons)
y = topleft_button_center_y + (row - 1) * (button_height + vertical_interval_between_buttons)

Is that - coordinates for clicking - what you want?

Revision history for this message
j (j-the-k) said :
#2

You can capture all buttons at once or you can capture each button explicitly. What works better for you depends on your GUI.

You can use the method of capturing the whole GUI and then calculate the clickpoint-coordinates if
- the buttons (almost) never move or change in size (or you'll have to recalculate and retake the screenshot)
- the buttons are very simmilar to each other (so that image recognition is not able to find the right image every time)
You should use one image for every button if
- The buttons move inside of the GUI or other elements of the GUI can change (so that the all-button-image would not be found)
- The look/size of some buttons can change (and would need a recalculation of the clickpoint-coordinates)

I guess the script that uses only one big image would be faster than searching for each button, but it depends on the fact that you never change the button positions.

Revision history for this message
Mic Cross (flexframers) said :
#3

Thanks Roman Podolyan, that solved my question.