Closed scottschreckengaust closed 3 years ago
Impressing doc ;-) Will have a look. Thanks.
Here is the download page for "OpenVPN Connect" https://openvpn.net/download-open-vpn/
...and the version installed: https://swupdate.openvpn.net/downloads/connect/openvpn-connect-3.2.1.1484_signed.dmg
I do not have any problems.
app = App("OpenVPN Connect")
if app.isRunning():
# both variants work
#app.focus()
switchApp(app.getName())
else:
print "not running"
app.open() # works
Your example script runs, but adding the Debug.on(3)
statement still shows that the AppleScript errors each time and subsequent runs when the window is not visible fail.
More importantly, after the first run (which opens the window to the foreground), if the window is either sent behind another window or is closed (not exited) as the application stays running in the background, a second Sikuli run of the same above script does not have the window appear. Therefore, a find
or click
will then not work as expected (because it is not visible).
Debug.on(3) app = App("OpenVPN Connect") if app.isRunning(): # both variants work #app.focus() switchApp(app.getName()) else: print "not running" app.open() # works
[debug] AppleScriptRunner: AppleScript:
#!/usr/bin/osascript
tell application "OpenVPNConnect" to activate
returned:
*****error*****
/var/folders/rn/lxr8csm50jjcxwz2y5pg4h880000gn/T/Sikulix_475142172/sikulitemp-13007145423498924402.script:37:45: execution error: Can’t get application "OpenVPNConnect". (-1728)
Could it be that the generated AppleScript error is missing the space between "OpenVPN" and "Connect"?
Thanks for feedback.
I guess, I have to go a bit deeper ;-)
Again: I do not have any problems using the above script:
I did not find any place, where the space character might be lost on the way down from executing switchApp().
The application does not activate although it is running and has a window. The generated osascript does not adhere to the requested application (see the debug output below).
NOTE: This particular application is an application generally in the background and does not show on the taskbar unless opened.
FYI: An AppleScript with
tell application "OpenVPN Connect" to activate
works IF it is openOutput:
Somehow the AppleScriptRunner retrieves a name different from the
app.getName()
as output shows above during theswitchApp
?https://github.com/RaiMan/SikuliX1/blob/108f9acc739b0ae97c7131b98d7ec9c6b4f728d3/API/src/main/java/org/sikuli/natives/MacUtil.java#L149