Determine if application has been fired up and close it

Asked by Shubham Rathi

I have an application which processes a file and returns its output as txt ( via notepad)
I want my script to determine if notepad is fired up and if notepad is fired, it go to file > save as. ( I can figure out after fireup)

Interesting will be to see how Sikuli would wait until Notepad is fired up. How should one do this in Sikuli?

Question information

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

This is an example code , when you allow that responce time is long.

notepad=App("notepad")
while True:
    if notepad.isRunning():
        popup("oh!")
    sleep(1)

http://sikulix-2014.readthedocs.io/en/latest/appclass.html#general-aspects-hints-and-tipps

Revision history for this message
Shubham Rathi (shubhamrathi) said :
#2

Thanks masuo, that solved my question.

Revision history for this message
Shubham Rathi (shubhamrathi) said :
#3

This almost solves my problem! I just have another quick query.
As part of the same job. I also want to trigger a popup after the application has finished loading a large file.
When the mouse is loading - it shows up with the loading circle (https://img.buzzfeed.com/buzzfeed-static/static/2014-03/enhanced/webdr05/7/13/grid-cell-16832-1394218439-13.jpg)

I want to trigger a popup as soon after the circle is gone ( file has loaded)

Does Sikuli have ways to handle cursor behavior?

Revision history for this message
masuo (masuo-ohara) said :
#4

You have to find out something change of status instead of mouse pointer.

https://answers.launchpad.net/sikuli/+question/276328

Revision history for this message
Shubham Rathi (shubhamrathi) said :
#5

I'm trying this currently:

<Cursor turns into loading circle>
if waitVanish(Pattern("cursor.png").similar(0.50),3600):
            popup("Found")

However, the above code returns 'Found' even when the cursor has not vanished ( The loading icon is still on screen). I understand this is perhaps because SikuliX generally does not support visually searching the mouse pointer.

The answer you cited, has mention of Mouse.at(), I'm not sure that I understand what Mouse.at() can be used for in this case.

Revision history for this message
masuo (masuo-ohara) said :
#6

Sorry that the quoted example was bad.
I had wanted to explane that SikuliX generally does not support visually searching the mouse pointer.

Revision history for this message
Shubham Rathi (shubhamrathi) said :
#7

I see. Thanks nonetheless for all the help.