Apple Script not working

Env

  • macOS 13.2.1 (22D68)
  • BTT 4.028

Problem

I have button with apple script widget for control VPN State

-- SET YOUR CONFIG NAME BELOW
set tunnelBlickConfigName to "YOUR_VPN_NAME"
tell application "Tunnelblick"
	set vpnState to get state of first configuration where name = tunnelBlickConfigName
	if vpnState = "CONNECTED" then
		return vpnState
	end if
	return "OFF"
end tell

this code run every 5 sec and result is EMPTY, but when I run this code in Apple Script editor, result is OK.

Also i have Actions assigned to this button.

-- SET YOUR CONFIG NAME BELOW
set tunnelBlickConfigName to "YOUR_VPN_NAME"
tell application "Tunnelblick"
	set vpnState to get state of first configuration where name = tunnelBlickConfigName
	
	if vpnState = "CONNECTED" then
		disconnect tunnelBlickConfigName
	end if
	
	if vpnState ≠ "CONNECTED" then
		connect tunnelBlickConfigName
	
	end if
	
end tell

result aslo EMPTY, but in Apple Script all works fine.

Some apps can not accept the async Apple Script, have you tried the "Run Apple Script (blocking)" action in BTT?

Yes, action Run Apple Script (blocking)
It's normal worked, before I re-install BTT ¯_(ツ)_/¯

Mb, I need setup additional privacy&security settings on macOS?

BTT might need permissions in Privacy & Security => Automation and in Privacy & Security => Accessibility

I re-check all switch

When I restart BTT, my button shows for 1 second on touch bar then hide.

Do simple scripts like e.g. just return "test" work?

Yes, when setup new trigger and select Apple Script Widget result return Value
also it's work for actions

But my previous trigger with access for Tunnelblick app doesn't work


Is the Tunnelblick app running?

I just restarted macOS then update Tunnelblick, and everything works fine. Thanks for your time!

1 Like