Apple Script does not launch

Hello everyone!

Just purchased recently the app. Actually everything works cool except Apple Scripts. I created a script, checked it separately - it works OK. Then i try to attach it to the hotkey. And... it attaches, but doesnt run. Not only when i click hotkey, but even when i try to run inside BTT, while i attach it to hotkey. I tried to launch it as external file, as a text - nothing works. Looks, like BTT just ignore it. The hotkey works, because i add HUD message after script laucnh and i see this message on the screen... All permissions BTT asked me to give him, i gave. What shold i check? Thanx!

Note:
Before bug reporting, please make sure you have tried the latest (alpha) version of BetterTouchTool and that you have already tried to restart your system :-). If you encounter a crash, please attach a crash log from the macOS Console.app from the "User Diagnostic Reports" section.


Describe the bug
A clear and concise description of what the bug is. Any bug reports that contain insults against me or my software will be deleted without warning (unfortunately this has become necessary to mention here).


Affected input device (e.g. MacBook Trackpad, Magic Mouse/Trackpad, Touch Bar, etc.):


Screenshots
If applicable, add screenshots to help explain your problem. (You can just paste or drag them here)


Device information:

  • Type of Mac:
  • macOS version:
  • BetterTouchTool version: (please post the exact version - not just "the latest one")

Additional information (e.g. crash logs, related issues, etc.):

can you post an example script that doesn’t work? then i can help

-- Настройки

set vpnMenuName to "Подключить L2TP Tallinn"

set appName to "ChatGPT"

set checkURL to "https://www.openai.com/"

set timeoutSeconds to 25

-- Проверка: подключён ли VPN

try

set vpnStatus to do shell script "scutil --nc status "L2TP Tallinn" | head -1"

on error

set vpnStatus to "Not Connected"

end try

-- Если уже подключено

if vpnStatus is equal to "Connected" then

do shell script "osascript -e 'display notification "VPN уже подключён" with title "VPN"'"

else

-- Подключение через GUI

do shell script "osascript -e 'display notification "Подключаю VPN..." with title "VPN"'"

tell application "System Events"

tell process "SystemUIServer"

set vpnMenuItem to (menu bar item 1 of menu bar 1 whose description contains "VPN")

click vpnMenuItem

delay 1

try

click menu item vpnMenuName of menu 1 of vpnMenuItem

on error errMsg

display dialog "Ошибка клика по меню VPN: " & errMsg

return

end try

end tell

end tell

-- Ожидание подключения (проверка по URL)

set waitTime to 0

repeat

delay 1

set waitTime to waitTime + 1

try

do shell script "curl -m 3 -s -I " & quoted form of checkURL

exit repeat

on error

if waitTime ≥ timeoutSeconds then

do shell script "osascript -e 'display notification "VPN не подключился за " & timeoutSeconds & " сек." with title "Ошибка VPN"'"

return

end if

end try

end repeat

do shell script "osascript -e 'display notification "VPN подключён" with title "VPN"'"

end if

-- Запуск приложения

tell application appName to activate

It checks. whether VPN Connection "L2TP Tallinn" is established or not. If not - it activates it, then launch ChatGPT app. If it runs already - script launch chatgpt immediately

ah you are calling some external tools, try to use their full path.

For example /usr/bin/osascript or /usr/bin/curl, /usr/bin/scutil

(you can get the path by running "which scutil" in terminal

Ok. I did. Nothing changed. Script works successfully separately, but BTT has no reaction, when i try to run it. If i press VERIFY - everything is ok, no messages or somth

-- Настройки

set vpnMenuName to "Подключить L2TP Tallinn"

set appName to "ChatGPT"

set timeoutSeconds to 15

set ipList to {"104.18.33.45", "172.64.154.211"}

-- Проверка: подключён ли VPN

try

set vpnStatus to do shell script "/usr/sbin/scutil --nc status "L2TP Tallinn" | /usr/bin/head -1"

on error

set vpnStatus to "Not Connected"

end try

-- Если уже подключено

if vpnStatus is equal to "Connected" then

do shell script "/usr/bin/osascript -e 'display notification "VPN уже подключён" with title "VPN"'"

else

-- Подключение через GUI

do shell script "/usr/bin/osascript -e 'display notification "Подключаю VPN..." with title "VPN"'"

tell application "System Events"

tell process "SystemUIServer"

set vpnMenuItem to (menu bar item 1 of menu bar 1 whose description contains "VPN")

click vpnMenuItem

delay 1

try

click menu item vpnMenuName of menu 1 of vpnMenuItem

on error errMsg

display dialog "Ошибка клика по меню VPN: " & errMsg

return

end try

end tell

end tell

-- Ожидание подключения (по ping к IP)

set waitTime to 0

set connected to false

repeat until connected or waitTime ≥ timeoutSeconds

repeat with ipAddr in ipList

try

do shell script "/sbin/ping -c 1 -W 3 " & ipAddr

set connected to true

exit repeat

on error

-- ping не прошёл

end try

end repeat

if not connected then

delay 1

set waitTime to waitTime + 1

end if

end repeat

if connected then

do shell script "/usr/bin/osascript -e 'display notification "VPN подключён" with title "VPN"'"

delay 5 -- Дополнительная задержка, чтобы маршруты перестроились

else

do shell script "/usr/bin/osascript -e 'display notification "VPN не подключился за " & timeoutSeconds & " сек." with title "Ошибка VPN"'"

return

end if

end if

-- Запуск приложения

tell application appName to activate

Looks like there are no permissions to run System Events or/and SystemUIServer, however all permission which BTT ask me go give it, i gave

mhm maybe it's because you are using osascript inside of your apple script, is there a reason for that?

do shell script "/usr/bin/osascript -e 'display notification "VPN подключён" with title "VPN"'"

You could do

display notification "blabla"

directly in your script.

If possible please post the script in a code block (three backticks at the start and three backticks at the end ```, otherwise the forum software breaks it.

Yeah. As i removed all lines with osascript display notification, next time i lunch the script under BTT it asks me to give a permisson to System Events. And as soon as i gave this permit, everything becomes good! So, as i guessed before, there was no enough permissions for BTT. But its strange, why the app did not ask me for these permissions before i removed all osascript commands. There were no any error or warning messages. BTT just ingored my script, like it was empty. But now its OK, thank you


Now this has been appeared in the Automation Settings. "System events" = ON. Before i could not make BTT to allow me to give it this permit. Also i could not add this permission manually before BTT asks me directly to do this. I have no idea, why osascript command prevented to do this before and no error or warning message occur at the same time