runscript

Asked by gob on 2019-09-25

runScript(xxx)
runScript(yyy)
runScript(zzz)

When runScript(zzz) finished, i wanna return to runScript(yyy).
and keep loop runScript(yyy) and runScript(zzz).
How can i do this?

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
gob
Solved:
2019-10-09
Last query:
2019-10-09
Last reply:
2019-09-26
Manfred Hampl (m-hampl) said : #1

To repeat forever you can use a construct like this:

runScript(xxx)
while True:
     runScript(yyy)
     runScript(zzz)

If you want the script to terminate at a certain condition, you can extend it with

runScript(xxx)
while True:
     runScript(yyy)
     runScript(zzz)
     if termination_condition_is_True:
         break

This is simple python, to be found in the manuals, e.g. https://docs.python.org/

gob (fkhrtan) said : #2

ty sir!

runScript(xxx)
while True:
     runScript(yyy)
     runScript(zzz)

this code get
java.nio.channels.ClosedByInterruptException

and i have no idea about this IOError

Manfred Hampl (m-hampl) said : #3

Please provide more information.
When does this message occur, are there additional messages, etc.

gob (fkhrtan) said : #4

Thanks for your reply

https://imgur.com/a/3zHDE6O

[error] script [ C:\script\VGWRM9.sikuli ] stopped with error at line --unknown--
[error] Error caused by: Traceback (most recent call last): File "C:\script\VGWRM9.sikuli\VGWRM9.py", line 75, in <module> java.lang.ThreadDeath
at java.lang.Thread.stop(Unknown Source)
at org.sikuli.ide.SikuliIDE$ButtonRun.stopRunScript(SikuliIDE.java:2671)
at org.sikuli.ide.SikuliIDE.onStopRunning(SikuliIDE.java:3016)
at org.sikuli.ide.SikuliIDE$10.hotkeyPressed(SikuliIDE.java:3008)
at org.sikuli.hotkey.HotkeyController$HotKeyListenerWrapper.onHotKey(HotkeyController.java:177)
at com.tulskiy.keymaster.common.Provider$HotKeyEvent.run(Provider.java:153)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.ThreadDeath: java.lang.ThreadDeath

[error] script [ C:\script\VGWRM10.sikuli ] stopped with error at line --unknown--
[error] Error caused by: IOError: java.nio.channels.ClosedByInterruptException

[error] script [ C:\script\VGWRM9.sikuli ] stopped with error at line --unknown--
[error] Error caused by: IOError: java.nio.channels.ClosedByInterruptException

[error] script [ C:\script\VGWRM10.sikuli ] stopped with error at line --unknown--
[error] Error caused by: IOError: java.nio.channels.ClosedByInterruptException

[error] script [ C:\script\VGWRM9.sikuli ] stopped with error at line --unknown--
[error] Error caused by: IOError: java.nio.channels.ClosedByInterruptException

[error] script [ C:\script\VGWRM10.sikuli ] stopped with error at line --unknown--
[error] Error caused by: IOError: java.nio.channels.ClosedByInterruptException

[error] script [ C:\script\VGWRM9.sikuli ] stopped with error at line --unknown--
[error] Error caused by: IOError: java.nio.channels.ClosedByInterruptException

Regards

Manfred Hampl (m-hampl) said : #5

The error messages refer to your VGWRM9 and VGWRM10 scripts.

gob (fkhrtan) said : #6

Thank you for your reply

Each script works without error

runScript("C:\script\VGWRM9.sikuli")
runScript("C:\script\VGWRM10.sikuli")
works without error

But
while True:
     runScript("C:\script\VGWRM9.sikuli")
     runScript("C:\script\VGWRM10.sikuli")
get error

I don't know why this happen

Regards

Manfred Hampl (m-hampl) said : #7

"I don't know why this happen"
Nor do I.

What you could try:
- check the return value and output of the scripts, see https://sikulix-2014.readthedocs.io/en/latest/scripting.html#running-scripts-and-snippets-from-within-other-scripts-and-run-scripts-one-after-the-other
- put wait statements between the runScript statements to slow down execution

Maybe RaiMan can help better.

RaiMan (raimund-hocke) said : #8

looks like you are terminating the complete run (which is an endless loop) by pressing the abort/stop hotkey.

gob (fkhrtan) said : #9

Thank you for all your help.
I've tried again

runScript(xxx)
while True:
     runScript(yyy)
     runScript(zzz)

and works fine at last.
I seem to have jumped to the conclusion.

"looks like you are terminating the complete run (which is an endless loop) by pressing the abort/stop hotkey."

yes I used the abort/stop hotkey.
and this endless loop still keeping occur when i use the abort/stop hotkey in this codes.

How can i stop this endless loop in this codes?

Regards

gob (fkhrtan) said : #10

ty