Skip to content
/ flip Public

Windows command-line tool to copy files to the clipboard

License

Notifications You must be signed in to change notification settings

lotkey/flip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Nov 25, 2023
aa58cbc · Nov 25, 2023

History

5 Commits
Nov 25, 2023
Nov 24, 2023
Nov 24, 2023
Nov 25, 2023
Nov 24, 2023
Nov 25, 2023

Repository files navigation

flip

flip is a Windows command-line tool that copies files to the clipboard. The name is derived from the Windows tool clip, which copies text to the clipboard.

Examples

  1. Print usage

    $> flip --help
    USAGE: flip [OPTION]... FILE...
    A Windows command-line tool to copy files to the clipboard.
    
    OPTIONS:
        -h, --help      Print the usage and exit
        -v, --verbose   Print verbose logs
  2. Copy multiple files to the clipboard

    $> flip .\test C:\Users\Lotkey\Desktop\awesome_file.png
  3. Copy a file to the clipboard with verbose logging

    $> flip -v C:\Users\Lotkey\Desktop\awesome_file.png
    Copying files: [C:\Users\Lotkey\Desktop\awesome_file.png]
    Filename list: [C, :, \, U, s, e, r, s, \, L, o, t, k, e, y, \, D, e, s, k, t, o, p, \, a, w, e, s, o, m, e, _, f, i, l, e, ., p, n, g, , ]
    dropfiles: {pFiles: 20, pt: {x: 0, y: 0}, fNC: 0, fWide: 0}

Installing

  1. Download a prebuilt executable from the Releases page.
  2. Move the executable. If you're not sure where to put it, C:\Program Files\flip\bin is the default chosen by cmake.
  3. Add the path to the executable to the PATH environment variable.

Building

Requirements:

  • cmake
  • A C++17 compiler

If neither of these are installed you can visit this link to download the Visual Studio Build Tools. This includes the Microsoft C++ compiler and cmake. Run any build or install steps from the newly installed Developer Command Prompt for VS. Running install steps will require administrator privileges.

Clone the Repository

If git is installed:

$> git clone https://github.com/lotkey/flip.git

Otherwise, manually download and unzip the zipped repository.

After cloning the repository, navigate into the root of the repository:

$> cd flip

Configure the Build

Create and navigate into a build directory:

$> mkdir build
$> cd build

To configure a 64-bit executable, run:

$> cmake .. -A x64

To configure a 32-bit executable, run:

$> cmake .. -A Win32

In the output from the cmake command there will be a line similar to:

Add ... to your PATH variable.

The output will show the install directory for flip instead of .... Make note of this directory for the install step.

Build the Executable

To build the executable for release, run:

$> cmake --build . --config Release

Install the Executable

To install the executable, run:

$> cmake --install .

Add the directory from the cmake output in the configure step to your PATH environment variable to make flip executable from anywhere within cmd or powershell.

How It Works

The Windows clipboard supports data in many formats. For example, the CF_TEXT format is used for copying plain text to the clipboard.

The CF_HDROP format is used for copying files to the clipboard in drag-and-drop operations. The HDROP structure is written to the clipboard and the receiving application is responsible for parsing it.

Along with the HDROP structure, a list of paths of the files to copy is written to the clipboard. The paths are written as a contiguous, null-terminated array of null-terminated C-strings. This list of paths is written directly after the HDROP structure in memory.

In order to copy files C:\picture.png and C:\text.txt, the following structure is written to the clipboard:

Type Data
DROPFILES
Type Data
DWORD Offset to the start of the file list
POINT
Type Data
LONG x-coordinate of the drop-point
LONG y-coordinate of the drop-point
BOOL true if the drop-point is on a non-client area and the drop-point is in screen coordinates
BOOL true if using Unicode characters
char *
C
:
\\
p
i
c
t
u
r
e
.
p
n
g
\0
C
:
\\
t
e
x
t
.
t
x
t
\0
\0

About

Windows command-line tool to copy files to the clipboard

Resources

License

Stars

Watchers

Forks

Packages

No packages published