KraKaKaa icon

Removing Leading and Trailing White Spaces and Empty Characters AHK Script ( AutoHotKey Script)

KraKaKaa | PRO | 10/21/23 07:46:44 PM UTC (Edited) | 0 ⭐ | 12008 👁️ | Never ⏰ | [Script, ahk, autohotkey, .ahk]
Autohotkey |

1.06 KB

|

Source Code

|

0 👍

/

0 👎

; AutoHotKey Script to Trim White Spaces from Clipboard
 
#Persistent  ; Keep the script running
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory
 
; Hotkey: Ctrl + Shift + T
^+T::
    ; Backup the original clipboard content
    originalClipboard := ClipboardAll
    
    ; Wait for the clipboard to contain text
    ClipWait, 1
    
    ; Trim leading and trailing white spaces using RegEx
    Clipboard := RegExReplace(Clipboard, "^\s+|\s+$", "")
    
    ; Wait a moment for the clipboard content to be updated
    Sleep, 100
    
    ; Restore the original clipboard content if it was non-text
    if (Clipboard != originalClipboard) {
        Clipboard := originalClipboard
    }
    
    ; Notify the user
    ToolTip, Clipboard trimmed!
    SetTimer, RemoveToolTip, -2000  ; Show the tooltip for 2 seconds
return
 
RemoveToolTip:
    ToolTip
return
 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎