Alternative method for CallBTT not working on run real javascript

BetterTouchTool >= 4.191 (August, 26, 2023)

  • All BTT scripting functions can now be called from JavaScript without using "callBTT" (e.g. await get_string_variable({'variable_name': "test"})

this one is not workin for real javascript

running latest alpha

working code

(async()=>{
	n=(await callBTT("get_string_variable",{variableName:"hovered_element_details"})).split('<AXApplication: "')[1].split('"')[0]
	callBTT('trigger_named_async_without_response',{trigger_name:'swmfloat'})
	callBTT('set_persistent_string_variable',{variable_name:'SWM-FA',to:(await runAppleScript(`
		tell app "System Events"
			tell process "BetterTouchTool"
				tell (first window whose size is {280,150}) to try
					set {x,y} to position
					set position to {x+50,y+60}
				end try
				set frontmost to true
			end tell
			tell (first process where displayed name is "`+n+`")
				short name  & ":" & (value of attribute "AXFullScreen" of window 1)
			end tell
		end tell
	`))})
	returnToBTT(1)
})()

i guess only trigger_named_async_without_response working on this code
am i missing something? i tried object key without quotes but result same

(async()=>{
	n=(await get_string_variable({'variableName':"hovered_element_details"})).split('<AXApplication: "')[1].split('"')[0]
	trigger_named_async_without_response({'trigger_name':"swmfloat"})
	set_persistent_string_variable({'variable_name':"SWM-FA",'to':(await runAppleScript(`
		tell app "System Events"
			tell process "BetterTouchTool"
				tell (first window whose size is {280,150}) to try
					set {x,y} to position
					set position to {x+50,y+60}
				end try
				set frontmost to true
			end tell
			tell (first process where displayed name is "`+n+`")
				short name  & ":" & (value of attribute "AXFullScreen" of window 1)
			end tell
		end tell
	`))})
	returnToBTT(1)
})()

I think i missed the set_persistent_string_variable. However get_string_variable should also already work.

I'll fix that asap, thanks for reporting!

thanks

this one works

PV=(k,c)=>{

if(c==undefined){return callBTT('get_string_variable',{variable_name:'SWM-'+k})}

callBTT('set_persistent_string_variable',{variable_name:'SWM-'+k,to:c})

}

i get "cant find variable get_string_variable" error on this one, running latest alpha
i shared because get_string_variable not works too, i guess you didn't add support for set_persistent_string_variable yet. Or is this related with code

PV=(k,c)=>{

if(c==undefined){return get_string_variable({variable_name:'SWM-'+k})}

set_persistent_string_variable({variable_name:'SWM-'+k,to:c})

}

Sorry for the delay, I had to finish some big junk of refactoring work before I could release a new version. This should be fixed in 4.274 alpha I think.