Advertisement
congdantoancau

UpperLower - Capslock auto convert

Aug 19th, 2018
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. ; #Warn  ; Enable warnings to assist with detecting common errors.
  3. SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
  4. SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
  5.  
  6. ; Uppercase/Lowercase text converter
  7. ~CapsLock::
  8.     ; Save clipboard
  9.     ClipSaved := Clipboard
  10.     ; Clear clipboard
  11.     Clipboard :=
  12.     ; Copy selected text (if available)
  13.     Send, ^c
  14.     Sleep, 100
  15.    
  16.     If (Clipboard == "") ; There are no selected texts
  17.     {  
  18.         ; If clipsaved is not null
  19.         if (ClipSaved != "") {
  20.             ; return the clipboard
  21.             Clipboard := ClipSaved
  22.        
  23.             ; handle clipboard
  24.             If Getkeystate("Capslock", "T") ; Convert text to upper
  25.             {
  26.              StringUpper Clipboard, Clipboard
  27.              ToolTip, Converted Clipboard to upper
  28.             }
  29.             else ; Convert text to lower
  30.             {
  31.              StringLower Clipboard, Clipboard
  32.              ToolTip, Converted Clipboard to lower
  33.             }
  34.         } else {
  35.             ToolTip, There are no texts to convert in the Clipboard.
  36.             Sleep, 1000
  37.         }
  38.         Sleep, 1000
  39.         ToolTip
  40.        
  41.     }
  42.     else ; The texts selected is available to convert
  43.     {
  44.         If Getkeystate("Capslock", "T") ; Convert text to upper
  45.         {
  46.          StringUpper Clipboard, Clipboard
  47.          Send %Clipboard%
  48.         }
  49.         else ; Convert text to lower
  50.         {
  51.          StringLower Clipboard, Clipboard
  52.          Send %Clipboard%
  53.         }
  54.     }
  55. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement