-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClipboardManager.h
More file actions
113 lines (96 loc) · 3.74 KB
/
ClipboardManager.h
File metadata and controls
113 lines (96 loc) · 3.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/**
* @file ClipboardManager.h
* @brief Header file for the ClipboardManager class.
*
*
* @author Yaopeng Xie
* @date 2023/11/14
*/
#ifndef CLIPBOARDMANAGER_H
#define CLIPBOARDMANAGER_H
#include "ClipboardContent.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
/**
* @brief Manages clipboard operations.
*
* This class provides static methods to interact with the system clipboard, including reading and writing content.
*/
class ClipboardManager {
private:
static DWORD lastClipboardSequenceNumber; ///< Last known clipboard sequence number
public:
static std::string lastUpdateTime; ///< Last update time of the clipboard content
/**
* @brief Checks if the clipboard content has changed.
* @return True if the clipboard content has changed, false otherwise.
*/
static bool HasClipboardChanged();
/**
* @brief Gets the current time as a string.
* @return The current time in a human-readable string format.
*/
static std::string GetCurrentTimeAsString();
/**
* @brief Retrieves the handle to the window that currently owns the clipboard.
*
* This method is used to obtain the handle of the window that is currently interacting with the clipboard.
* It is typically used in conjunction with other clipboard operations.
*
* @return The handle to the window owning the clipboard, or NULL if no window owns the clipboard.
*/
static HWND GetClipboardWindowHandle();
/**
* @brief Gets the last update time of the clipboard content.
*
* This method retrieves the timestamp of when the clipboard content was last updated.
*
* @return A string representing the last update time of the clipboard content.
*/
static std::string GetLastUpdateTime();
/**
* @brief Gets the format of the current data on the clipboard.
*
* This method checks the clipboard and identifies the format of the data currently stored on it.
* Supported formats include text, images, and file handles.
*
* @return The clipboard format identifier of the current clipboard data.
*/
static UINT GetClipboardFormat();
/**
* @brief Sets the given text onto the clipboard.
*
* This method places a Unicode text string onto the system clipboard. If successful,
* the text can be pasted from the clipboard into other applications.
*
* @param hWindow A handle to the window that currently owns the clipboard.
* @param s The Unicode text string to be placed onto the clipboard.
*/
static void SetClipboardText(HWND hWindow, const std::wstring &s);
/**
* @brief Retrieves text from the clipboard.
*
* This method fetches a Unicode text string from the system clipboard, if available.
*
* @param hWindow A handle to the window that currently owns the clipboard.
* @return A Unicode string containing the text retrieved from the clipboard.
*/
static std::wstring GetClipboardText(HWND hWindow);
/**
* @brief Retrieves the current content of the clipboard.
*
* This method fetches the current content of the clipboard and encapsulates it in a ClipboardContent object.
* The content can include text, images, or files.
*
* @param hWindow A handle to the window that currently owns the clipboard.
* @return A ClipboardContent object containing the current clipboard content.
*/
static ClipboardContent GetClipboardContent(HWND hWindow);
/**
* @brief Pushes a string to the system clipboard.
* @param str The string to be pushed to the clipboard.
*/
static void PushStringToClipboard(const std::string& str);
static std::string convertToUtf8(const std::wstring &unicodeText);
};
#endif // CLIPBOARDMANAGER_H