Internal variables in "Variable Value Did Change"

I've removed some of the license info

btt_debug_20241209.zip (12.6 KB)

~12:43:47 - BTT restart
12:43:52 - view_count variable set to correct value - 148

~12:47:XX - new song started, view_count, floating menu was still showing 148. I cannot see any entries in the log to set/update view_count

~12:47:33 - skipped to next song
12:47:46 - view_count var set to correct value - 114

Ok then it seems is never calling the set_persistent_string_variable for the case were it doesn't work. Most likely the script doesn't find the view count and then bails out via the throw error. You could add some more logs (e.g. log the HTML or the result of your shell script)

I've tried to eliminate issue with the script, by replacing it with simple apple script:

on itemScript(itemUUID)
	set currentTime to do shell script "date '+%H:%M:%S'"
	-- Set the persistent string variable in BetterTouchTool
	tell application "BetterTouchTool"
		set_persistent_string_variable "custom_var_test_view_count" to currentTime
	end tell
	return currentTime
end itemScript

This use-case remains the same - script should run each time "BTTNowPlayingInfoTitle" is changed, but it is not. I've also tested with another variable to be "monitored", but again the same result - HUD is shown, the actual action (applescript) is not being executed.

Here's the trigger:
exported_automation_trigger_value_change.bttpreset (2.1 KB)

Ah I see. Unfortunately BTT can't handle this sort of apple script definition. Just remove the "on itemScript(itemUUID)" and "end itemScript". Also remove the function to call

This only works in specific contexts because in a variable value did change context, there is no itemUUID

I'm not sure what happened, but this now works 99% of the time. Thank you for your help @Andreas_Hegenberg .

There's however something which is bugging me - if I configure BTTNowPlayingInfoTitle to be the monitored variable - on pause/play or going into Safari's youtube tab, the trigger is triggered, but if I check the var's value it is still the same. If I use a persistent variable custom_var_test_title set like this (basically having the value of BTTNowPlayingInfoTitle):

set songTitle to get_string_variable "BTTNowPlayingInfoTitle"
set_persistent_string_variable "custom_var_test_title" to songTitle

this does not happen. Just reporting if this is unexpected.