"Prompt" action: OK or Cancel

Hi! I'm wondering if there's an action that will create a "OK to continue?" prompt.

I'd like to trigger a keyboard shortcut and see a prompt. If I click OK, the subsequent actions continue. If I click Cancel the subsequent actions don't run.

Thanks!

If you build buttons on the Touch Bar for your "Ok to continue" Prompt, then that would be easy.

If you want an on screen Dialog, then you can complete this using AppleScript depending on your subsequent actions.

Here is an applescript example that I'm using to confirm if I really want to delete an entry in my database.

tell application "BetterTouchTool"
	set rid to get_number_variable "timeE_entryid"
end tell

set theResponse to display dialog "Confirm to remove entry (" & rid & ")" with icon note buttons {"Cancel", "Continue"} default button "Continue"

if button returned of theResponse is not "Continue" then
	return
end if

That's a good solution. In case you want to continue with BTT actions after the dialog I'd assign them to a named trigger and trigger it like this:

set theResponse to display dialog "Confirm bla bla" with icon note buttons {"Cancel", "Continue"} default button "Continue"

if button returned of theResponse is not "Continue" then
	return
end if

tell application "BetterTouchTool"
trigger_named_async_without_response "TheNameOfTheNamedTrigger" 
end tell


That is awesome, exactly what I was looking for. Thanks guys!

I want this same feature for an otherwise simple action. I want a trackpad gesture to close a browser window. But only after I OK it with a prompt dialog to avoid unintentional closure. I can execute Andreas's script from 2020, but it only works in BTT, not from the browser.

Here's an Apple Script that doesn't really work in that it fails to prevent the subsequent action if the user cancels in the dialog. Also, it often requires 2 to 4 clicks on a button in the dialog before there is any response. Then, if I click another application window afterward, that window doesn't become active until I click that window again. Any thoughts on why this fails?

BTW, if I use Apple Script to send keystrokes to accomplish what I want, this works, other than the need to repeat execution of the clicks on the buttons. But I can't get BTT to ignore actions subsequent to the Apple Script in the Actions column.

tell application "System Events"
	set frontmostProcess to first process where it is frontmost
	set appName to name of frontmostProcess
end tell

tell application appName	
	set theResponse to display dialog "Should I?" with icon note buttons {"Cancel", "OK"} default button "OK"	
	if button returned of theResponse is not "OK" then
		return
	end if	
end tell


In case it matters to anyone, I switched the version of the Apple Script action from blocked to async. That sped things up and made this usable. What I thought was a need to click the dialog box multiple times was not the issue. It's that there were long delays from the time the dialog appeared until it was able to accept input, like 5-6 seconds at times.