Guest User

AutoHotkey replacement for Windows 11 Suggested Actions

a guest
Jun 17th, 2025
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | Software | 0 0
  1. #Requires AutoHotkey v2.0
  2. #SingleInstance Force
  3.  
  4. ; Variable to store the last clipboard content
  5. lastClipboard := ""
  6.  
  7. ; Set up a timer to monitor the clipboard every 500ms
  8. SetTimer(CheckClipboardAndWindow, 500)
  9.  
  10. CheckClipboardAndWindow() {
  11. global lastClipboard
  12.  
  13. ; Get the current clipboard content
  14. clipboardContent := A_Clipboard
  15.  
  16. ; Check if the clipboard content has changed
  17. if (clipboardContent != lastClipboard) {
  18. ; Update the last clipboard content
  19. lastClipboard := clipboardContent
  20.  
  21. ; Clean the text (remove spaces, dashes, parentheses, dots)
  22. CleanText := RegExReplace(clipboardContent, "[\s\-\(\)\.]", "")
  23.  
  24. ; Check if it's a phone number (various formats)
  25. if (IsPhoneNumber(CleanText)) {
  26. ; Format the phone number for tel
  27. FormattedNumber := FormatPhoneNumber(CleanText)
  28.  
  29. ; Create tel link
  30. telLink := "tel:" . FormattedNumber
  31.  
  32. ; Show notification
  33. TrayTip("Phone Number Detected", "Opening tel link for: " . FormattedNumber, "Iconi Mute")
  34.  
  35. ; Open the tel link
  36. Run(telLink)
  37. }
  38.  
  39.  
  40. ; Function to check if text is a phone number
  41. IsPhoneNumber(Text) {
  42. ; Remove any remaining non-numeric characters except +
  43. NumericText := RegExReplace(Text, "[^\d\+]", "")
  44.  
  45. ; Check various phone number patterns:
  46. ; - 10 digits (US format): 1234567890
  47. ; - 11 digits starting with 1: 11234567890
  48. ; - International format starting with +: +11234567890, +441234567890, etc.
  49.  
  50. if (RegExMatch(NumericText, "^\d{10}$")) ; 10 digits
  51. return true
  52. if (RegExMatch(NumericText, "^1\d{10}$")) ; 11 digits starting with 1
  53. return true
  54. if (RegExMatch(NumericText, "^\+\d{10,15}$")) ; International format
  55. return true
  56.  
  57. return false
  58. }
  59.  
  60. ; Function to format phone number for tel
  61. FormatPhoneNumber(Text) {
  62. ; Remove any non-numeric characters except +
  63. NumericText := RegExReplace(Text, "[^\d\+]", "")
  64.  
  65. ; If it's a 10-digit US number, add +1
  66. if (RegExMatch(NumericText, "^\d{10}$"))
  67. return "+1" . NumericText
  68.  
  69. ; If it's 11 digits starting with 1, add +
  70. if (RegExMatch(NumericText, "^1\d{10}$"))
  71. return "+" . NumericText
  72.  
  73. ; If it already starts with +, return as is
  74. if (RegExMatch(NumericText, "^\+"))
  75. return NumericText
  76.  
  77. ; Default: return with + prefix
  78. return "+" . NumericText
  79. }
  80. }
  81. }
Tags: autohotkey
Advertisement
Add Comment
Please, Sign In to add comment