易语言gdi源码
㈠ 易语言截取键盘信息的代码怎么写
MS VC++ 的 c 程序可以实现。
方法哗哗:
(1)用键盘按键程序模拟法,把图像发送到clipboard
(2)把clipboard图像存入.bmp 图像文件(或别的格式)。
编译:
cl simu_keyboard.c user32.lib Gdi32.lib
特殊头文件:
#include <Windows.h>
#include <Winuser.h>
#include <memory.h>
提示:
(1)按键程序模拟子程序:
void snapscreen_2_clipboard()
{
keybd_event(VK_SNAPSHOT,0x2C,0,0);
keybd_event(VK_SNAPSHOT,0x2C,KEYEVENTF_KEYUP,0);
}
(2)clipboard图像存入.bmp 图像乱桐行文件
FILE *fout;
/* --------------------------------------------------------------
* dib
int GetBytesPerPixel(int depth);
int GetBytesPerRow(int width, int depth);
int GetBitmapBytes(int width, int height, int depth);
* --------------------------------------------------------------*/
int GetBytesPerPixel(int depth)
{ return (depth==32 ? 4 : 3);
}
int GetBytesPerRow(int width, int depth)
{
int bytesPerPixel = GetBytesPerPixel(depth);
int bytesPerRow = ((width * bytesPerPixel + 3) & ~3);
return bytesPerRow;
}
// bmi.bmiHeader.biWidth, bmi.bmiHeader.biHeight, bmi.bmiHeader.biBitCount
int GetBitmapBytes(int width, int height, int depth)
{
return height * GetBytesPerRow(width, depth);
}
void save_clipboard_img_to_bmp()
{
char nameout[80];
HANDLE h_bitmap,h_dib;
BITMAPINFO bmi;
HDC hDC;
int imageBytes;
BITMAPFILEHEADER hdr;
int scanLineCount;
unsigned char *img;
if (!OpenClipboard(NULL)) {
printf("Can not open clipboard\n");
exit(0);
};
if (DEBUG ==1) printf("pass open clipboard\n");
// HANDLE GetClipboardData(UINT uFormat);
h_bitmap = GetClipboardData(CF_BITMAP);
h_dib = GetClipboardData(CF_DIB);
if (h_bitmap ==NULL || h_dib ==NULL){
printf("I got NULL bitmap: ");
} else { printf("I got bitmap: ");};
memcpy(&bmi,h_dib,sizeof(bmi));
printf("%d x %d \n",bmi.bmiHeader.biWidth, bmi.bmiHeader.biHeight);
hDC = CreateCompatibleDC(NULL); //轮枣 Gdi32.lib.
CloseClipboard();
bmi.bmiHeader.biCompression = BI_RGB;
// possible to use part of imgage with img_w,img_h
imageBytes = GetBitmapBytes(bmi.bmiHeader.biWidth, bmi.bmiHeader.biHeight, bmi.bmiHeader.biBitCount);
printf("pass GetBitmapBytes=%d \n",imageBytes);
img = (char *) malloc(imageBytes);
if (!img) {
printf("No enought memory for img !\n"); exit(0);
}
// BITMAPFILEHEADER hdr;
hdr.bfType = ((WORD) ('M' << 8) | 'B'); // is always "BM"
hdr.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER)
+ (bmi.bmiHeader.biClrUsed * sizeof(RGBQUAD)) + bmi.bmiHeader.biSizeImage;
hdr.bfReserved1 = 0;
hdr.bfReserved2 = 0;
hdr.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER)
+ (bmi.bmiHeader.biClrUsed * sizeof(RGBQUAD));
scanLineCount = GetDIBits(hDC,h_bitmap,0,bmi.bmiHeader.biHeight, img, &bmi, DIB_RGB_COLORS);
strcpy(nameout,"keyb_tmp.bmp");
if ( (fout = fopen(nameout,"wb") ) == NULL ) {
printf("\007Cann't open output file: %s ", nameout);exit(1);
};
fwrite( &hdr, sizeof(BITMAPFILEHEADER ), 1, fout );
fwrite( &bmi, sizeof(BITMAPINFO), 1, fout );
fwrite( img, sizeof(unsigned char),imageBytes, fout );
fclose(fout);
printf("Output in %s\n",nameout);
}
/* -------end dib and bmp ----- */
㈡ 易语言怎么写刷新游戏窗口和绑定窗口 最好有源码参考
易语言可以调用大漠模块实现各种模式的窗口绑定操作,列举各种模式:
// display: 前台 鼠标:前台键盘:前台 模式0
dm_ret = dm.BindWindow(hwnd,"normal","normal","normal",0)
// display: gdi 鼠标:前台 键盘:前台 模式1
dm_ret = dm.BindWindow(hwnd,"gdi","normal","normal",1)
// display: dx 鼠标:前台 键盘:前台 模式0
dm_ret = dm.BindWindow(hwnd,"dx","normal","normal",0)
// display: dx 鼠标:windows后台 键盘:windows后台 模式1
dm_ret = dm.BindWindow(hwnd,"dx","windows","windows",1)
// display: dx 鼠标:dx 后台 键盘: dx后台 模式1
dm_ret = dm.BindWindow(hwnd,"dx","dx","dx",1)
// display: dx 鼠标:windows3后台 键盘:windows后台 模式1
dm_ret = dm.BindWindow(hwnd,"dx","windows3","windows",1)