How to end an AppleScript using a keystroke?- please
I currently have the below code, I am trying to make it that if the keystroke "p" is clicked the apple script or repeat ends (this is made to repetitively click the space bar very fast for a long time) and I cant seem to get it to stop spamming without having to restart my computer (hence why I want it to be p that stops the command)
Thank you!
tell application "System Events"
display dialog "Enter message" default answer "example text"
set textToSay to the text returned of the result
display dialog "Interval " default answer ".1"
set int to the text returned of the result
set stopspam to the keystroke "p"
display dialog "Click to launch in 5 Seconds"
delay 5
repeat until stopspam
delay int
keystroke textToSay
end repeat
end tell