← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #169023]: Currently running application title needed

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
This only works of course if you have a frontmost window, with a classic title bar like with Notepad.
And the window, you are targeting must have had the focus, before you switched to Sikuli IDE, to run the script.

this e.g. works for a Notepad window on my Win7:

win = App.focusedWindow()
titleBar = win.above(1).below(26) # select the titlebar
titleBarText = titleBar.left(1).right(26).right(titleBar.w-150) # narrow to text part
titleBarText.highlight(2)
print titleBarText.text()

The above solution, does not use drag/drop and does not touch the
cursor. It simply reads, what is visible on the screen.

--- you say: As we can close the app by its title
yes of course - but there you have to know at least part of the window title of the window, that you want to close.

--- you say: Shall I have to use any python or java function for that.
The App class is implemented on the Java level and furthermore depends on system specific (Windows, Mac, Linux) low level modules. You might have a look into the sources, to find out, how the internal access to the window title is realized e.g. for the close function. So you might find out how to code in Java, to get the window title of the frontmost window.
On the Python level (which is Jython actually), there is no feature available to access the Windows GUI.

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