當前位置:首頁 » 操作系統 » 易語言gdi源碼

易語言gdi源碼

發布時間: 2025-08-18 13:06:05

㈠ 易語言截取鍵盤信息的代碼怎麼寫

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)

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:585
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:881
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:574
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:761
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:677
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:1005
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:249
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:108
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:799
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:705