← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #162050]: about App.focus() question

 

Question #162050 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/162050

RaiMan proposed the following answer:
taking the following example: (supposing Notepad is closed)

(you might have to fix the type()'s - I am on german Win7)

App("Notepad").open(); wait(1) # opens a new Notepad window
App("Editor").focus() # german: comes up with a different prog-name
type("s", KEY_CTRL); wait(1)
type("testing\n") # to give the window a name (mind overwrite situation)
np = App("testing.txt") # the App instance
Region(np.window()).highlight(2) # the Notepad window
type(" ", KEY_ALT); wait(1); type("n") # the sequence to minimize
wait(2) # it is minimized now

np = App("testing.txt").focus() # we try to focus using a new App object
Region(np.window()).highlight(2) # the Notepad window
# nothing happens, because the window is at (-32000, -32000)
# but it accepts type()'s 
type(" ", KEY_ALT); wait(1); type("w") # the sequence to restore the window

the window you want, is restored when minimized.

You could even check the x-value of the window region, to find out,
whether it is minimized or not after the App.focus().

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