Jump to content

[- Release -] Clipboard Tool


FinalVersion
 Share

Recommended Posts

Notes: Simple, but I find this extremely useful.

Hotkeys:

  • Ctrl + Home (Clear the clipboard)
  • Ctrl + Page Up (Read the clipboard)
  • Ctrl + End (Exit the program)
ToDo:

  • Load File Into Clipboard With Hotkey.
  • Your Suggestions!
#cs ----------------------------------------------------------------------------
    
    Author:     -> Final Version
    Version:    -> 3.3.5.6 <Beta>
    Function:   -> Simple clipboard tool, but could potentially but useful for nurmerous people.s
    
#ce ----------------------------------------------------------------------------

#include <Misc.au3>

Opt("TrayMenuMode", 3)

$tClear = TrayCreateItem("-> Clear The Clipboard")
$tRead = TrayCreateItem("-> Read The Clipboard")
$tExit = TrayCreateItem("-> Exit Program")

While 1
    $tMsg = TrayGetMsg()
    Select
        Case $tMsg = $tClear
            ClearTheClip()
        Case $tMsg = $tRead
            ReadTheClip()
        Case $tMsg = $tExit
            End()
    EndSelect

    If _IsPressed("11") And _IsPressed("24") Then
        ClearTheClip()
    ElseIf _IsPressed("11") And _IsPressed("21") Then
        ReadTheClip()
    ElseIf _IsPressed("11") And _IsPressed("23") Then
        End()
    EndIf
WEnd

Func ClearTheClip()
    ClipPut("");
EndFunc ;==>ClearTheClip

Func ReadTheClip()
    $sRead = ClipGet();
    If $sRead = "" Then
        TrayTip("Current Clip Contents", "Clipboard doesn't contain anything!", 3, 1);
    ElseIf $sRead = " " Then ;==> This is for my personal use, I got into the habit of clearing my clipboard by cutting a space in a text field.
        TrayTip("Current Clip Contents", "Clipboard contained a space, I'll empty it for you...", 3, 1);
        ClipPut("")
    Else
        TrayTip("Current Clip Contents", $sRead, 3, 1);
    EndIf
EndFunc ;==>ReadTheClip

Func End()
    Exit
EndFunc ;==>End
Edited by FinalVersion
Link to comment
Share on other sites

I'd prefer using ispressed() udf or wm events instead of hotkeyset to avoid blocking functionality of other software using the same hotkey. I know this because I made the same mistake once.

[Not using this account any more. Using "iShafayet" instead]

Link to comment
Share on other sites

That's kinda of a cool idea. I like the adding support to load a file to the clipboard. (even though I'm sure it's been done before).

#cs ----------------------------------------------------------------------------
    
    Author:     -> Final Version
    Version:    -> 3.3.5.6 <Beta>
    Function:   -> Simple clipboard tool, but could potentially but useful for nurmerous people.s
    
#ce ----------------------------------------------------------------------------

#include <Misc.au3>

Opt("TrayMenuMode", 3)

$tClear = TrayCreateItem("-> Clear The Clipboard")
$tRead = TrayCreateItem("-> Read The Clipboard")
$tReadfile = TrayCreateItem("-> Load File to Clipboard")
$tExit = TrayCreateItem("-> Exit Program")


While 1
    $tMsg = TrayGetMsg()
    Select
        Case $tMsg = $tClear
            ClearTheClip()
        Case $tMsg = $tRead
            ReadTheClip()
        Case $tMsg = $tReadfile
            AddFileToClip()
        Case $tMsg = $tExit
            End()
    EndSelect

    If _IsPressed("11") And _IsPressed("24") Then
        ClearTheClip()
    ElseIf _IsPressed("11") And _IsPressed("21") Then
        ReadTheClip()
    ElseIf _IsPressed("11") And _IsPressed("23") Then
        End()
    ElseIf _IsPressed("11") And _IsPressed("22") Then
        AddFileToClip()
    EndIf
WEnd

Func ClearTheClip()
    ClipPut("");
EndFunc ;==>ClearTheClip

Func ReadTheClip()
    $sRead = ClipGet();
    If $sRead = "" Then
        TrayTip("Current Clip Contents", "Clipboard doesn't contain anything!", 3, 1);
    ElseIf $sRead = " " Then ;==> This is for my personal use, I got into the habit of clearing my clipboard by cutting a space in a text field.
        TrayTip("Current Clip Contents", "Clipboard contained a space, I'll empty it for you...", 3, 1);
        ClipPut("")
    Else
        TrayTip("Current Clip Contents", $sRead, 3, 1);
    EndIf
EndFunc ;==>ReadTheClip

Func AddFileToClip()
    
    Local $filename, $filehand, $filedata
    
    $filedata = ""
    
    $filename = FileOpenDialog("Choose file", "./", "All (*.*)", 1+2)
    If $filename = "" Then Return
    
    $filehand = FileOpen($filename, 0)
    If $filehand = -1 Then
        MsgBox(0, "Error", "Unable to open file.")
        Return
    EndIf

    While 1
        $filedata = $filedata & FileRead($filehand, 1024)
        If @error = -1 Then ExitLoop
    Wend

    FileClose($filehand)

    ClipPut($filedata)
    TrayTip("Loaded into Clipboard", $filedata, 3, 1);
    
EndFunc ;==>AddFileToClip
    
    

Func End()
    Exit
EndFunc ;==>End
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...