How to change window size using Sikuli

Asked by Juliana Xiao

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

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Juliana Xiao
Solved:
Last query:
Last reply:
Revision history for this message
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"
    exit()

... 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.

Revision history for this message
masuo (masuo-ohara) said :
#2
Revision history for this message
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 = """
    applescript
    tell application """ + "\""+Sub_Open_Which_App+"\"" + """ to set the bounds of the first window to {"""+Tynon_Size+"""}
    """
    runScript(cmd)

Revision history for this message
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.
https://answers.launchpad.net/sikuli/+question/122526

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.