Idea: Highlight a number, call the script using a shortcut key, display the highlighted number + 1.
Problems:
How do I detect if it is actually a number? An analogous function would be IsNum().
If the user holds the shortcut key too long, the keystroke “c” is not detected. How do I determine if there is no keys pressed or something similar?
--Need to detect if all keys are up here
tell application "System Events"
keystroke "c" using {command down}
end tell
--Allow time for the clipboard contents to change.
delay 0.2
--Need to detect if the clipboard has a number in it.
set dRequest to ((the clipboard) as number) + 1
display dialog dRequest
-- Delay To Allow The User With Sausage Fingers To Let Go Of Hotkey
delay 0.5
-- Clear Clipboard
set the clipboard to null
-- Copy Selection To Clipboard
tell application "System Events"
keystroke "c" using {command down}
end tell
-- Allow Time For The Clipboard To Change
delay 0.2
-- Display And Test Result
try
set dRequest to ((the clipboard) as number) + 1
on error
display dialog "The current selection is not a number." buttons {"OK"}
return null
end try
display dialog dRequest buttons {"OK"}