我有個笨辦法,先用API抓圖到內(nèi)存里,然后再在根據(jù)你點鼠標的屏幕工作區(qū)坐標,去那圖里取色。
為烏翠等地區(qū)用戶提供了全套網(wǎng)頁設計制作服務,及烏翠網(wǎng)站建設行業(yè)解決方案。主營業(yè)務為網(wǎng)站制作、網(wǎng)站建設、烏翠網(wǎng)站設計,以傳統(tǒng)方式定制建設網(wǎng)站,并提供域名空間備案等一條龍服務,秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務。我們深信只要達到每一位用戶的要求,就會得到認可,從而選擇與我們長期合作。這樣,我們也可以走得更遠!
-----------------------
'抓圖所需的API
Private Declare Function CreateCompatibleDC Lib "GDI32" (ByVal hDC As Integer) As Integer
Private Declare Function CreateCompatibleBitmap Lib "GDI32" (ByVal hDC As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer) As Integer
Private Declare Function SelectObject Lib "GDI32" (ByVal hDC As Integer, ByVal hObject As Integer) As Integer
Private Declare Function BitBlt Lib "GDI32" (ByVal srchDC As Integer, ByVal srcX As Integer, ByVal srcY As Integer, ByVal srcW As Integer, ByVal srcH As Integer, ByVal desthDC As Integer, ByVal destX As Integer, ByVal destY As Integer, ByVal op As Integer) As Integer
Private Declare Function DeleteDC Lib "GDI32" (ByVal hDC As Integer) As Integer
Private Declare Function DeleteObject Lib "GDI32" (ByVal hObj As Integer) As Integer
Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As Integer) As Integer
Const SRCCOPY As Integer = HCC0020
'抓圖的部分
Dim hDC, hMDC As Integer
Dim hBMP, hBMPOld As Integer
Dim sw, sh As Integer
hDC = GetDC(0)
hMDC = CreateCompatibleDC(hDC)
sw = Screen.PrimaryScreen.Bounds.Width
sh = Screen.PrimaryScreen.Bounds.Height
hBMP = CreateCompatibleBitmap(hDC, sw, sh)
hBMPOld = SelectObject(hMDC, hBMP)
BitBlt(hMDC, 0, 0, sw, sh, hDC, 0, 0, SRCCOPY)
hBMP = SelectObject(hMDC, hBMPOld)
Dim bmp As Bitmap = Image.FromHbitmap(New IntPtr(hBMP))
DeleteDC(hDC)
DeleteDC(hMDC)
DeleteObject(hBMP)
......
'取點的顏色
bmp.GetPixel(e.X, e.Y)
----------------------------
關鍵就是這些你自己組合吧,你分給的太少了,很麻煩,恕我不幫你改全了。如果要仔細幫你改,請另開高分貼,不要用新馬甲來
既然能夠取得整個屏幕,可以取到整個屏幕以后創(chuàng)建一個全屏窗體顯示靜態(tài)的屏幕圖像,然后在窗體上實現(xiàn)部分截取。
估計別的截圖也是這個原理,因為一點開始截圖屏幕就變?yōu)殪o態(tài)不動了,肯定是在截圖初期復制了當時的屏幕場景
INTOUCH自帶的就有,打印屏幕的命令
自己寫個時間條件運行那命令就可以了
PRINTSCREEN這個命令 具體怎么用 看下幫助
希望我的回答對你有所幫助
如有其他問題,可以繼續(xù)追問,您的采納是我前進的動力!
屏幕抓圖至少分為3個步驟:
(1) 啟用鼠標指針捕獲。
(2) 在鼠標指針所在處的窗口進行繪圖,提示抓圖的目標。
(3) 選定目標窗口時,將目標窗口的畫面保存為自定義的位圖并終止鼠標指針捕獲。
以下是具體的編程步驟:
(1)在Visual C++ .NET中按照GDI+程序的框架新建一個基于對話框的項目ScreenCapture,然后準備好一個外形為相機的光標文件(*.cur),將之引入資源管理器(IDC_CAMERA)。接著在CScreenCaptureDlg類中加入以下兩個全局變量:
HWND hwndCapture;
Crect rectCapture;
(2)通過類向導加入對WM_MOUSEMOVE及WM_LBUTTONUP事件的響應函數(shù),分別如下所示。
void CScreenCaptureDlg::OnMouseMove(UINT nFlags, CPoint point)
{
//如果用戶按隹鼠標左鍵不放,則開始抓取圖片
if(nFlags==MK_LBUTTON){
//隱藏程序窗口,以免影響在抓取時的“視野”
ShowWindow(SW_HIDE);
//載入“照相機”鼠標指針,開始追蹤鼠標指針的移動
HCURSOR cur=LoadCursor(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDC_CAMERA));
SetCursor(cur);
SetCapture();
//獲得鼠標指針所在窗口的句柄
this-ClientToScreen(point);
hwndCapture=(HWND)::WindowFromPoint(point);
//取得屏幕的設備環(huán)境句柄,以便在屏幕的任何位置繪圖
HDC hDC=::GetDC(NULL);
//建立一個紅色的畫筆
HPEN hPen=CreatePen(PS_INSIDEFRAME,6,RGB(255,0,0));
//將繪圖模式設為R2_NOTXORPEN,在繪圖時可以不破壞原有的背景
int nMode=SetROP2(hDC,R2_NOTXORPEN);
HPEN hpenOld=(HPEN)SelectObject(hDC,hPen);
//得到鼠標指針所在窗口的區(qū)域
::GetWindowRect(hwndCapture,rectCapture);
//在鼠標指針所在處的窗口四周畫一紅色的矩形,做為選定時的提示
POINT pt[5];
pt[0]=CPoint(rectCapture.left,rectCapture.top);
pt[1]=CPoint(rectCapture.right,rectCapture.top);
pt[2]=CPoint(rectCapture.right,rectCapture.bottom);
pt[3]=CPoint(rectCapture.left,rectCapture.bottom);
pt[4]=CPoint(rectCapture.left,rectCapture.top);
::Polyline(hDC,pt,5);
//延時后再重繪紅色矩形,這樣不會破壞原有的內(nèi)容
Sleep(100);
::Polyline(hDC,pt,5);
::SelectObject(hDC,hpenOld);
::ReleaseDC(NULL,hDC);
}
CDialog::OnMouseMove(nFlags, point);
}
void CScreenCaptureDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
// 得到鼠標指針所在窗口的區(qū)域寬、高
int nWidth=rectCapture.Width();
int nHeight=rectCapture.Height();
HDC hdcScreen,hMemDC;
HBITMAP hBitmap,hOldBitmap;
//建立一個屏幕設備環(huán)境句柄
hdcScreen=CreateDC("DISPLAY",NULL,NULL,NULL);
hMemDC=CreateCompatibleDC(hdcScreen);
//建立一個與屏幕設備環(huán)境句柄兼容、與鼠標指針所在窗口的區(qū)域等大的位圖
hBitmap=CreateCompatibleBitmap(hdcScreen,nWidth,nHeight);
//把新位圖選到內(nèi)存設備描述表中
hOldBitmap=(HBITMAP)SelectObject(hMemDC,hBitmap);
//把屏幕設備描述表拷貝到內(nèi)存設備描述表中
BitBlt(hMemDC,0,0,nWidth,nHeight,hdcScreen,rectCapture.left,rectCapture.top,SRCCOPY);
DeleteDC(hdcScreen);
DeleteDC(hMemDC);
//返回位圖句柄
//打開剪貼板,并將位圖拷到剪貼板上
OpenClipboard();
EmptyClipboard();
SetClipboardData(CF_BITMAP,hBitmap);
//關閉剪貼板
CloseClipboard();
MessageBox("屏幕內(nèi)容已經(jīng)拷到剪貼板!");
ReleaseCapture();
//恢復窗口顯示模式
ShowWindow(SW_NORMAL);
CDialog::OnLButtonUp(nFlags, point);
}
至此,一個具有專業(yè)效果的屏幕抓圖程序的核心已經(jīng)搞定。
'沒辦法,需的把窗口隱藏一下,還的隱藏后延遲一下再截圖。
Dim?WithEvents?Timer1?As?New?Timer?With?{.Interval?=?30,?.Enabled?=?False}
Dim?Imgrect?As?Rectangle
Dim?img?As?Bitmap
Private?Sub?Button1_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.Click
Imgrect?=?Me.RectangleToScreen(Me.ClientRectangle)
img?=?New?Bitmap(Imgrect.Width,?Imgrect.Height)
Me.Hide()
Timer1.Start()
End?Sub
Private?Sub?Timer1_Tick(ByVal?sender?As?Object,?ByVal?e?As?System.EventArgs)?Handles?Timer1.Tick
Timer1.Stop()
Graphics.FromImage(img).CopyFromScreen(Imgrect.X,?Imgrect.Y,?0,?0,?Imgrect.Size)
Me.BackgroundImage?=?img
Me.Show()
End?Sub