Vnc app detected only at first attempt after Sikulix Ide launch

Asked by matteoa

Hello,
I'm automating using a UltraVNC external app, and for that I have this script:
appVNC= App(getParentFolder() + r'UltraVNC\vncviewer.exe')
if not appVNC.isRunning(0): appVNC.open(0)
print appVNC
if not(appVNC.isRunning(5)):
    LogAll('VNC_NOT STARTED')
    exit(-1)
appVNC.focus()
vncReg=Region(appVNC.window())

With version
1.1.4-SNAPSHOT-#223-2019-03-06_14:23/Windows10.0/Java8(64)1.8.0_191-b12
it runs ok and finish correctly only at first attempt.
When I try to relaunch it without closing the IDE it has an exception at line 8:
error] script [ testApp ] stopped with error at line --unknown--
[error] Error caused by: Traceback (most recent call last): File "\testApp.sikuli\testApp.py", line 8, in <module> vncReg=Region(appVNC.window()) at org.sikuli.script.Region.<init>(Region.java:414)
at org.python.proxies.sikuli.Region$Region$5.<init>(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.python.core.PyReflectedConstructor.constructProxy(PyReflectedConstructor.java:211)
java.lang.NullPointerException: java.lang.NullPointerException

The same behavior can be see using Pycharm, to make it work I have to close the project and restart the IDE

Using an older version I had by mistake
1.1.4-SNAPSHOT-2019-01-30_21:31/Windows10.0/Java8(64)1.8.0_191-b12
It runs correctly every time, as it was doing from months
Let me know if I can help you more on understanding the problem
Thanks in advance

Question information

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

Yes, there have been some changes to the App class since the mentioned snapshot.
I will check the situation asap.

Revision history for this message
RaiMan (raimund-hocke) said :
#2

tested with the latest build #226 and Google Chrome:
cannot reproduce this behavior:

chrExe = r"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
app = App(chrExe)
if not app.isRunning():
    app.open(10)
print app, app.window()

output:
[105652:chrome (SikuliX1 Downloads - Google Chrome)] C:\Program Files (x86)\Google\Chrome\Application\chrome.exe R[151,17 1720x993]@S(0)
[198460:chrome (SikuliX1 Downloads - Google Chrome)] C:\Program Files (x86)\Google\Chrome\Application\chrome.exe R[151,17 1720x993]@S(0)
[198460:chrome (SikuliX1 Downloads - Google Chrome)] C:\Program Files (x86)\Google\Chrome\Application\chrome.exe R[151,17 1720x993]@S(0)
[198460:chrome (SikuliX1 Downloads - Google Chrome)] C:\Program Files (x86)\Google\Chrome\Application\chrome.exe R[151,17 1720x993]@S(0)

Revision history for this message
matteoa (matteoa) said :
#3

I reproduced the problem with this script(Notepad++ was closed before the launch):
chrExe = r"c:\Program Files (x86)\Notepad++\notepad++.exe"
app = App(chrExe)
if not app.isRunning():
    app.open(10)
vncReg=Region(app.window())
print app, app.window()
The error is on the line5 : vncReg=Region(app.window())
and the output is
[error] script [ testapp2 ] stopped with error at line --unknown--
[error] Error caused by: Traceback (most recent call last): File "C:\Projects\DataPurchase\REACT\SikuliX\Test_h20\testapp2.sikuli\testapp2.py", line 5, in <module> vncReg=Region(app.window()) at org.sikuli.script.Region.<init>(Region.java:414)
at org.python.proxies.sikuli.Region$Region$5.<init>(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.python.core.PyReflectedConstructor.constructProxy(PyReflectedConstructor.java:211)
java.lang.NullPointerException: java.lang.NullPointerException

When Notepad++ is already opened the script works repeatedly.

The original script I put on this question was working without problem from months, and using an older version of Sikulix still works every time.
Is it possible that in the newer versions there is something different to do to grab the region of an application and use it as a ROI for all the subsequent operations?
Thanks for your invaluable support
Matteo

Revision history for this message
matteoa (matteoa) said :
#4

Just a small addition:
with the older version of Sikulix I have the second test script never has problems, even if Notepad++ is closed.
I hope this helps...
Thanks again
Matteo

Revision history for this message
matteoa (matteoa) said :
#5

hello,
no hopes for a fix for this problem?
Not a blocking one, but it would be nice to overcome it...
Thanks
Matteo

Revision history for this message
Launchpad Janitor (janitor) said :
#6

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
RaiMan (raimund-hocke) said :
#7

Sorry for the delay. Is now at the top of the list.

Revision history for this message
Best RaiMan (raimund-hocke) said :
#8

My tests with the latest build 1.1.4 did not show any problems, no matter wether Notepad++ was already running or not.

I repeated the script several times, while stopping Notepad++ from time to time.

my test

exe = r"C:\Program Files\Notepad++\notepad++.exe"
app = App(exe)
if not app.isRunning():
    app.open(10)
if app.isRunning():
    app.focus()
    reg = Region(app.window())
    print app, reg
else:
    print "not running"

So it might be worth, to give the latest 1.1.4 a new chance.

I am on Windows 10 64Bit (1809/2019-03-23) with Java 12

Revision history for this message
matteoa (matteoa) said :
#9

Thanks RaiMan, that solved my question.