/*
关于链接直接入会的问题;(灵感来源于迅雷和百度:复制bt或者百度链接,在启动了迅雷百度网盘的时候
提醒你下载)
如果客户端已经运行
1.开启定时器,随时检测剪贴板
2.检测剪贴板是否有关键字符,如果有的话,就认为是一键入会链接,调用
*/
#include<iostream>
#include<thread>
#include<mutex>
#include <Windows.h>
using namespace std;
void SetClipBoard(string msg);
string GetClipBoard();
void Test();
int main()
{
thread t(Test);
while (1)
{
printf("...\n");
Sleep(1000);
}
system("pause");
return 0;
}
void Test()
{
while (1)
{
string msg = GetClipBoard();
if (msg.find("meet://") != string::npos)
{
printf("检测到需要启动的会议:%s\n", msg.c_str());
SetClipBoard(string());
}
printf(".run\n");
Sleep(1000);
}
return;
}
void SetClipBoard(string msg)
{
HGLOBAL hMemBin = NULL;
PCHAR LockBin = NULL;
OpenClipboard(NULL);
EmptyClipboard();
hMemBin = GlobalAlloc(GMEM_MOVEABLE, msg.size() + 1);
LockBin = (PCHAR)GlobalLock(hMemBin);
RtlMoveMemory(LockBin, msg.c_str(), msg.size() + 1);
GlobalUnlock(hMemBin);
LockBin = NULL;
SetClipboardData(CF_TEXT, hMemBin);
CloseClipboard();
}
string GetClipBoard()
{
HGLOBAL hMemBin = NULL;
PCHAR LockBin = NULL;
PCHAR TempBin = NULL;
OpenClipboard(NULL);
hMemBin = GetClipboardData(CF_TEXT);
string msg ;
if (hMemBin)
{
LockBin = (PCHAR)GlobalLock(hMemBin);
TempBin = (PCHAR)malloc(GlobalSize(hMemBin));
if (NULL != TempBin&&NULL != LockBin)
{
RtlMoveMemory(TempBin, LockBin, GlobalSize(hMemBin));
LockBin = NULL;
CloseClipboard();
msg = TempBin;
free(TempBin);
TempBin = NULL;
}
GlobalUnlock(hMemBin);
}
return msg;
}
定时检测剪贴板,并做出响应
于 2022-10-14 11:33:41 首次发布