Hi!
I'm a huge BTT fan. However, I've run into a bug today that is reproducible. Essentially, I have a case where running an AppleScript using a keyboard shortcut causes the AppleScript to run differently than if I run it using the "Run Script" button in BTT. The script itself is identical in both cases. Hopefully I'm just missing something simple, but I've been banging my head against this for a few hours now.
Describe the bug
Here is the script. I tried to reduce it to the simplest case. Essentially, the script sends a keystroke to copy the selected text. It then displays a dialogue box with the length of the text and the selected text itself (see screenshots below).
set the clipboard to ""
tell application "Notes"
activate
end tell
tell application "System Events"
keystroke "c" using {command down}
delay 0.1
repeat 10 times -- poll clipboard for ~1 seconds. Sometimes setting x to the clipboard might throw exception
try
set selectionText to the clipboard
if selectionText is not equal to "" then
exit repeat
end if
end try
delay 0.1
end repeat
end tell
set myStringLength to length of selectionText
display dialog "The length of the string is " & myStringLength & " and the string is: " & selectionText
When I run this using the "Run Script" button, it works perfectly every time. However, when I use the assigned keyboard shortcut trigger (ctrl-cmd-o), it fails to copy any text and keeps the clipboard as the empty string, returning a length of 0.
I know this issue is not limited to the Notes app because I swapped out Notes for a different app in the script, and I had the same issue. I've also tried a few different keyboard shortcut triggers for it and had the same result.
EDIT: This same script also works if I use a trackpad trigger. I'm unsure if this is helpful to know.
Affected input device (e.g. MacBook Trackpad, Magic Mouse/Trackpad, Touch Bar, etc.):
Keyboard shortcuts
Screenshots


Device information:
- Type of Mac: 2021 M1 Pro MacBook Pro
- macOS version: Ventura 13.3.1
- BetterTouchTool version: 4.075
*Note: I cannot restart my system today to debug this because of a long process I have running, otherwise I would.