Update of the documentation for the new variable?

Have you already update the documentation for the possibility of storing some variable.
This sounds very exciting but I do not find it in the documentation. Since this is still alpha, it fully makes sense
that this is not include (and I do not want to rush you) but i just want to be sure that I'm not just missing it.

Thanks,

Olivier

Hi Olivier,

I have not done that yet (will do sometime today but I'll probably rename variable_value to just "to").

However it's relatively easy. Here are the currently possible combinations (persistent should be kept after restarting BTT, non-persistent are just stored for the time BTT is running)

tell application "BetterTouchTool"
	set_persistent_string_variable "variableName" variable_value "variableValue"
end tell

tell application "BetterTouchTool"
	set_string_variable "variableName" variable_value "variableValue"
end tell




tell application "BetterTouchTool"
	set variable to get_string_variable "variableName"
	return variable
end tell

//edit ah, and it's still buggy and the actions that really make this powerful have not yet been added to BTT. So maybe wait 1-2 versions until really using it :slight_smile:

Amazing, that's all the information that I was missing.
(but with the way to get access to such variable but with I found it with some small test)

tell application "BetterTouchTool"
	set myvar to get_string_variable "variableName"
end tell 

You intrigue me. This is already extremely powerful. But ok I will wait.

I'm building a way to make it possible to hide/show/allow/prevent or interrupt action sequences under certain conditions, which includes variables (also other things like what kind of element is currently hovered with the mouse or which element has keyboard focus).
However it may still take a bit until I can ship that. Just started working on the UI for the rule editor.

With the next alpha it will be save to use the variables in Apple Script already. The syntax will change to this:

tell application "BetterTouchTool"
	set_string_variable "variableName" to "variableValue"
end tell

tell application "BetterTouchTool"
	set_persistent_string_variable "variableName" to "variableValue"
end tell

tell application "BetterTouchTool"
	set_number_variable "variableName" to 123
end tell

tell application "BetterTouchTool"
	set_persistent_number_variable "variableName" to 123
end tell

tell application "BetterTouchTool"
	set var to get_number_variable "variableName"
	return var + 100
end tell

sorry for changing a topic slightly in here, but I just wanted to ask: do you plan on creating an BTT built in webserver API endpoints for that? Because it really seems like a super powerfull feature, but I don't use apple script that much and I wonder if I'd have to create some abstraction for my use cases, or do you plan to make it managable via webserver (which, ofc would be great)

I mean, setting and getting a variable. Something like
http://127.0.0.1:12345/set_variable/?variable_name=foo&value=x
http://127.0.0.1:12345/set_persistent_variable/?variable_name=bar&value=baz

and getting a variable:

http://127.0.0.1:12345/get_variable/?variable_name=foo -> would return 'x'

Also with persistent variables, it'd make sense to somehow "delete" them or unset them, probably

This should already work with the string variables, but the syntax will change the same as described in Update of the documentation for the new variable?

Adding onto this thread on the use of variables within BTT...

Can we use a string variable in the "Show HUD Overlay" action?

It wasn't immediately obvious to me reading the posts here on the forum.

Thanks!

1 Like

Exactly what brought me here.

It would be excellent if these variables could be extended into the BTT application. For example, in the Insert / Type / Paste Custom has an Insert Special option which references the clipboard as:

(BTT)@clipboard(BTT)

Could we reference our custom variables in a similar manner?

(BTT)@my_custom_var(BTT)

Which could then work in Paste Custom, in HUD text, Open URL input, etc..

Cheers

1 Like