The following Script works as expected in Script Editor:
tell application "System Events"
set nord to menu bar item 1 of menu bar 2 of application process "NordVPN IKE"
ignoring application responses
click nord
end ignoring
end tell
do shell script "killall System\\ Events"
tell application "System Events"
set nord to menu bar item 1 of menu bar 2 of application process "NordVPN IKE"
tell menu 1 of nord
if exists menu item "Disconnect" then
click menu item "Disconnect"
else
click menu item "Connect"
end if
end tell
end tell
When I export it to a .app
and double click on it to execute, I get the following error:
Can’t get «class menE» 1 of «class mbri» 1 of «class mbar» 2 of «class pcap» "NordVPN IKE" of application "System Events". Invalid index.
System Events got an error: Can’t get menu 1 of menu bar item 1 of menu bar 2 of application process "NordVPN IKE". Invalid index. (-1719)
How can I change the script so it works as a .app
?
Thanks
tell application "NordVPN IKE" to activate
line at the beginning of your program.