分类:
2008-09-17 11:13:03
()
- ()
-- ()
[分享] 远程桌面操作的模拟实现
1.主要思路就是先将远程桌面捕获,再发回本地,在对话框中显示出来,将本地鼠标和盘键输入,变成命令,发到远程主机执行,以模拟出鼠标和键盘的操作,再将远程桌面捕获,再发回本地,在对话框中显示出来.
2.桌面捕获关键代码:
HWND hWnd = ::GetDesktopWindow();//获得屏幕的HWND.
HDC hScreenDC = ::GetDC(hWnd); //获得屏幕的HDC.
HDC MemDC = ::CreateCompatibleDC(hScreenDC);
RECT rect;
::GetWindowRect(hWnd,&rect);
SIZE screensize;
screensize.cx=rect.right-rect.left;
screensize.cy=rect.bottom-rect.top;
hBitmap = ::CreateCompatibleBitmap(hScreenDC,screensize.cx,screensize.cy);
HGDIOBJ hOldBMP = ::SelectObject(MemDC,hBitmap);
::BitBlt(MemDC,0,0,screensize.cx,screensize.cy,hScreenDC,rect.left,rect.top,SRCCOPY);
::SelectObject(MemDC,hOldBMP);
::DeleteObject(MemDC);
::ReleaseDC(hWnd,hScreenDC);
3.鼠标左击的模拟
SetCursorPos (point.x, point.y);
mouse_event (MOUSEEVENTF_LEFTDOWN, 0,0,0,0);
mouse_event (MOUSEEVENTF_LEFTUP, 0,0,0,0);
4.A输入方法:
::keybd_event(0x61,0,0,0);
::keybd_event(0x61,0,KEYEVENTF_KEYUP,0);
5.完完整的代码请访问
[/IMG]
__________________
电脑迷
感谢分享!~
全部时间均为北京时间. 现在时间是15:05 . |
Powered by: vBulletin Version 2.2.8
Translated and hacked by:
Copyright © Jelsoft Enterprises Limited 2000, 2001.