Advertisement
Guest User

Untitled

a guest
Jan 26th, 2015
926
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. ;-Change Text Case-----------------------------------------
  2. cycleNumber := 1
  3.  
  4. #IfWinNotActive ahk_class XLMAIN
  5.  
  6. ^t::
  7. If (cycleNumber==1)
  8. {
  9. ConvertUpper()
  10. cycleNumber:= 2
  11. }
  12. Else If (cycleNumber==2)
  13. {
  14. ConvertLower()
  15. cycleNumber:= 3
  16. }
  17. Else If (cycleNumber==3)
  18. {
  19. ConvertTitleCase()
  20. cycleNumber:= 4
  21. }
  22. Else
  23. {
  24. ConvertSentence()
  25. cycleNumber:= 1
  26. }
  27. Return
  28.  
  29. ConvertUpper()
  30. {
  31. clipSave := Clipboard
  32. Clipboard = ; Empty the clipboard so that ClipWait has something to detect
  33. SendInput, ^c ;copies selected text
  34. ClipWait
  35. StringReplace, Clipboard, Clipboard, `r`n, `n, All ;Fix for SendInput sending Windows linebreaks
  36. StringUpper, Clipboard, Clipboard
  37. Len:= Strlen(Clipboard)
  38. SendInput, ^v ;pastes new text
  39. Send +{left %Len%}
  40. Clipboard := clipSave
  41. }
  42.  
  43. ConvertLower()
  44. {
  45. clipSave := Clipboard
  46. Clipboard = ; Empty the clipboard so that ClipWait has something to detect
  47. SendInput, ^c ;copies selected text
  48. ClipWait
  49. StringReplace, Clipboard, Clipboard, `r`n, `n, All ;Fix for SendInput sending Windows linebreaks
  50. StringLower, Clipboard, Clipboard
  51. Len:= Strlen(Clipboard)
  52. SendInput, ^v ;pastes new text
  53. Send +{left %Len%}
  54. Clipboard := clipSave
  55. }
  56.  
  57. ConvertTitleCase()
  58. {
  59. clipSave := Clipboard
  60. Clipboard = ; Empty the clipboard so that ClipWait has something to detect
  61. SendInput, ^c ;copies selected text
  62. ClipWait
  63. StringReplace, Clipboard, Clipboard, `r`n, `n, All ;Fix for SendInput sending Windows linebreaks
  64. StringLower, Clipboard, Clipboard, T
  65. Len:= Strlen(Clipboard)
  66. SendInput, ^v ;pastes new text
  67. Send +{left %Len%}
  68. Clipboard := clipSave
  69. }
  70.  
  71. ConvertSentence()
  72. {
  73. clipSave := Clipboard
  74. Clipboard = ; Empty the clipboard so that ClipWait has something to detect
  75. SendInput, ^c ;copies selected text
  76. ClipWait
  77. StringReplace, Clipboard, Clipboard, `r`n, `n, All ;Fix for SendInput sending Windows linebreaks
  78. StringLower, Clipboard, Clipboard
  79. Clipboard := RegExReplace(Clipboard, "(((^|([.!?]+\s+))[a-z])| i | i')", "$u1")
  80. Len:= Strlen(Clipboard)
  81. SendInput, ^v ;pastes new text
  82. Send +{left %Len%}
  83. VarSetCapacity(OutputText, 0) ;free memory
  84. Clipboard := clipSave
  85. }
  86.  
  87. #IfWinNotActive
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement