I tested your script and it worked perfectly fine.
Then I tried my code again with your entries like below: (I think I know the reason for this: I am using portable version of chrome. Does this tell you anything? Could it be the reason? )
temp = r"C:\Users\Test\Desktop\Chromes\f1\f1.exe"
App.logOn()
a = App(temp)
print a
a.open(10) #worked
print "after open"
App.open("notepad") # to steel focus # worked
wait(3)
a.focus()
print "after focus"
wait(3)
a.closeByKey(3) # see comment
print "after close"
App.logOff()
[AppLog] App.focus: no window for [1068:f1 (OleMainThreadWndName)] C:\Users\Test\Desktop\Chromes\f1\f1.exe
after open
[AppLog] App.create: [-1:notepad]
[AppLog] App.focus: no window for [1068:f1 (OleMainThreadWndName)] C:\Users\Test\Desktop\Chromes\f1\f1.exe
after focus
[AppLog] App.focus: no window for [1068:f1 (OleMainThreadWndName)] C:\Users\Test\Desktop\Chromes\f1\f1.exe
[error] script [ Untitled ] stopped with error at line --unknown--
[error] Error caused by: Traceback (most recent call last): File "C:\Users\Test\AppData\Local\Temp\Sikulix_1621692664\sikuli-6955607908584789750.py", line 12, in <module> a.closeByKey(3) # see comment at org.sikuli.script.App.closeByKey(App.java:638)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
java.lang.NullPointerException: java.lang.NullPointerException
I tested your script and it worked perfectly fine.
Then I tried my code again with your entries like below: (I think I know the reason for this: I am using portable version of chrome. Does this tell you anything? Could it be the reason? )
temp = r"C:\Users\ Test\Desktop\ Chromes\ f1\f1.exe"
App.logOn()
a = App(temp)
print a
a.open(10) #worked
print "after open"
App.open("notepad") # to steel focus # worked
wait(3)
a.focus()
print "after focus"
wait(3)
a.closeByKey(3) # see comment
print "after close"
App.logOff()
then It stopped and gave me this log:
[AppLog] App.create: [-1:f1] Test\Desktop\ Chromes\ f1\f1.exe
[-1:f1 ()] C:\Users\
[AppLog] App.open: [1068:f1 (OleMainThreadW ndName) ] C:\Users\ Test\Desktop\ Chromes\ f1\f1.exe
[AppLog] App.focus: no window for [1068:f1 (OleMainThreadW ndName) ] C:\Users\ Test\Desktop\ Chromes\ f1\f1.exe
after open
[AppLog] App.create: [-1:notepad]
[AppLog] App.open: [17516:notepad (Untitled - Notepad)] notepad
[AppLog] App.focus: [17516:notepad (Untitled - Notepad)] notepad
[AppLog] App.focus: no window for [1068:f1 (OleMainThreadW ndName) ] C:\Users\ Test\Desktop\ Chromes\ f1\f1.exe
after focus
[AppLog] App.focus: no window for [1068:f1 (OleMainThreadW ndName) ] C:\Users\ Test\Desktop\ Chromes\ f1\f1.exe
[error] script [ Untitled ] stopped with error at line --unknown-- Test\AppData\ Local\Temp\ Sikulix_ 1621692664\ sikuli- 695560790858478 9750.py" , line 12, in <module> a.closeByKey(3) # see comment at org.sikuli. script. App.closeByKey( App.java: 638) NativeMethodAcc essorImpl. invoke0( Native Method) NativeMethodAcc essorImpl. invoke( Unknown Source) DelegatingMetho dAccessorImpl. invoke( Unknown Source) reflect. Method. invoke( Unknown Source) NullPointerExce ption: java.lang. NullPointerExce ption
[error] Error caused by: Traceback (most recent call last): File "C:\Users\
at sun.reflect.
at sun.reflect.
at sun.reflect.
at java.lang.
java.lang.