跳到正文

剪贴板

剪贴板 ntivcb3s

原文
剪贴板信息

剪贴板信息

收录
更新

windows.h 模板

C++
#include<windows.h>
#include<cstdlib>
#define down(ch) keybd_event(ch,0,0,0)//按一个键
#define up(ch) keybd_event(ch,0,2,0)//弹起一个键
#define an(ch) down(ch),up(ch)//按下一个键
#define ctrl(ch) down(17),an(ch),up(17)//ctrl+一个键
#define key_down(key) ((GetAsyncKeyState(key)&0x8000)?1:0)//判断 key 是否被按下
#define box(top,text) MessageBox(NULL,text,top,MB_OK)//提示框
void set_pos(int x,int y){//移动鼠标并点击
    SetCursorPos(x,y);
    mouse_event(MOUSEEVENTF_LEFTDOWN,x,y,0,NULL);
    mouse_event(MOUSEEVENTF_LEFTUP,x,y,0,NULL);
}
void copy(string s){//复制字符串
	if(OpenClipboard(NULL)){
		HGLOBAL hMem=GlobalAlloc(GMEM_MOVEABLE,s.size()+1);
		GlobalUnlock(hMem);EmptyClipboard();
		memcpy(GlobalLock(hMem),s.c_str(),s.size()+1);
		SetClipboardData(CF_TEXT,hMem);
		CloseClipboard();GlobalFree(hMem);
	}
}
void hide(){//隐藏当前运行框
	HWND hwnd;
	if(hwnd=::FindWindow("ConsoleWindowClass",NULL))
		::ShowWindow(hwnd,SW_HIDE);
}

学习C/C++中的<Windows.h>库-CSDN博客