How to change window size using Sikuli

Asked by Juliana Xiao on 2017-12-15

I have experience that our native application's window size is changing sometimes and in this case I need to retake all the images. To avoid that can I change the window size using to certain value, for example 100X100? or is there any work around?

Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Solved by:
Juliana Xiao
Last query:
Last reply:
RaiMan (raimund-hocke) said : #1

Sorry, not a feature.

At least you might test the window size using

window = App.focusedWindow()
neededW = ....
neededH = ....
if not (window.w == neededW and window.h = neededH):
    print "wrong window size"

... and then somehow correct the situation and start again.

The only scripting correction is, to script what you manually would do, to resize the window to the needed shape.

Jeff_Vallis (vallis-pj) said : #3

On a Mac I use Applescript to do this

You can get the size of the window from

    Tynon_Size = "0, 23, 1422, 949" # With Toolbar

    cmd = """
    tell application """ + "\""+Sub_Open_Which_App+"\"" + """ to set the bounds of the first window to {"""+Tynon_Size+"""}

Juliana Xiao (julianax) said : #4

Thanks all for helping me out.

I tried to use window menu to set window size on Windows from the following link but it is not stable enough.

I tried to use the way in Masuo's link above and it worked for both Windows and Mac. I just drag and drop the upper left corner to certain offset and it works.

Thank you all again.