using variables

I want to enter text by typing but there are many different scenarios so I want to create one named trigger where I can enter different text using variables. Is this possible?

As an explanation of the variables I have a bunch of paper sizes such as 8.5, 9, 11, 14, etc. instead of having a trigger for each size, I would like to choose a value and place it in the variable and use it in a "Insert/Type/Paste text" action.

How would you like to enter the variables? (There are many ways to achieve this)

I am using the new floating menu to make a choice and the choice I make will set the variables then run a named trigger which uses those variables.

I think I may have found the solution but haven’t had time to test it. I noticed there is a drop-down in the Insert/Paste/Type dialog for inserting special variables. At first it only showed BTT special variables and didn’t realize my own assigned variables would show up there after they had been assigned. It seems this should now work.

I got a chance to try out what I found and it works great. It seems much faster than having the code in each choice and if I need to edit something I can do it in one place.

I wish there was an action to click a certain button on the screen, similar to clicking a menu bar item but some buttons don't have a corresponding menu bar item. It sometimes works to find an image and click on it but if that even works it is too slow for me. Keyboard Maestro has that ability so for now I use that but it would be nice to have it natively in BTT.

Most buttons can be easily clicked via Apple Script, which is why I haven't included a dedicated action for this yet - but maybe I can reevaluate this :slight_smile:

Easiest way to get the code for such an Apple Script is to use Apple's Automator app and record the button click using the built in recorder. Then select the recorded actions and press cmd+c, this will copy the apple script to your clipboard

I tried your instruction on button pressing but it doesn't work in my situation. The action did nothing. It also appears like that script will only work when a specific file is open but I want it to work always since I usually work on a specific file only once.

Here is the code that comes up:

-- Click the “Edit...” button.
delay 1.661960
set timeoutSeconds to 2.000000
set uiScript to "click UI Element \"Edit...\" of UI element 3 of UI element 2 of UI element 1 of window \"Fiery Impose - 128502.pdf\" of application process \"Fiery Makeready\""
my doWithTimeout( uiScript, timeoutSeconds )

on doWithTimeout(uiScript, timeoutSeconds)
	set endDate to (current date) + timeoutSeconds
	repeat
		try
			run script "tell application \"System Events\"
" & uiScript & "
end tell"
			exit repeat
		on error errorMessage
			if ((current date) > endDate) then
				error "Can not " & uiScript
			end if
		end try
	end repeat
end doWithTimeout

This will not work with the "Fiery Impose - 128502.pdf" in the code as that is just one specific file and I don't know if wild card characters work. I tried messing around with the code and nothing worked. At this time the finding image works so I guess I will stick with that.

This particular button works to press with Keyboard Maestro so if the finding image quits working successfully for me I will go back to using KM to click the button.

In such scripts you can usually replace the specific window with (1st window whose value of attribute "AXMain" is true)

delay 1.661960
set timeoutSeconds to 2.000000
set uiScript to "click UI Element \"Edit...\" of UI element 3 of UI element 2 of UI element 1 of (1st window whose value of attribute \"AXMain\" is true) of application process \"Fiery Makeready\""
my doWithTimeout( uiScript, timeoutSeconds )

on doWithTimeout(uiScript, timeoutSeconds)
	set endDate to (current date) + timeoutSeconds
	repeat
		try
			run script "tell application \"System Events\"
" & uiScript & "
end tell"
			exit repeat
		on error errorMessage
			if ((current date) > endDate) then
				error "Can not " & uiScript
			end if
		end try
	end repeat
end doWithTimeout

or simplified

tell application "System Events"
	click UI element "Edit..." of UI element 3 of UI element 2 of UI element 1 of (1st window whose value of attribute "AXMain" is true) of application process "Fiery Makeready"
end tell