Last active
February 20, 2025 09:55
-
-
Save ttscoff/5729733 to your computer and use it in GitHub Desktop.
Dial a phone number detected in text with Skype. Part of a [PopClip Extension](https://github.com/ttscoff/popclipextensions).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
input = ENV['POPCLIP_TEXT'] | |
# use a regex to locate all phone numbers | |
phone_numbers = input.scan(/(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?/) | |
# send the first one to Skype via AppleScript (osascript) | |
%x{/usr/bin/osascript -e 'set _cmd to "CALL #{phone_numbers[0].join("")}"' -e 'tell application "Skype" to send command _cmd script name "PCDIALER"'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment