text - How can I detect whether something is selected with AppleScript? -


i'm using software called controllermate allows customize behavior of buttons on keyboard or mouse. 1 of 'building blocks' can use in particular function in apple script. create custom behavior mouse such button execute cmd+c if can copied selected, otherwise execute different keyboard shortcut. seems have use applescript in order determine whether text selected, after reading other other people's solutions online unable figure out how implement myself. help.

here's solution:

put empty string clipboard, cmd+c, check clipboard.

set clipboard "" tell application "system events" keystroke "c" using command down delay 0.2  set b false try     set b (the clipboard string) not "" on error -- error when clipboard contains custom type (like copy in photos application)     set b true end try if b -- clipboard not contains empty string     -- *** script execute different keyboard shortcut ***     --tell application "system events" keystroke somechar using somemodifier end if 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -