vb.net屏幕抓图 vbs截图代码

VB.NET当鼠标停在屏幕任意地方,得到该点的颜色我有个笨办法,先用API抓图到内存里,然后再在根据你点鼠标的屏幕工作区坐标,去那图里取色 。
-----------------------
'抓图所需的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)
----------------------------
关键就是这些你自己组合吧,你分给的太少了 , 很麻烦,恕我不帮你改全了 。如果要仔细帮你改,请另开高分贴,不要用新马甲来
vb.net 2008 如何将指定的窗体截图并保存INTOUCH自带的就有,打印屏幕的命令
自己写个时间条件运行那命令就可以了
PRINTSCREEN这个命令 具体怎么用 看下帮助
希望我的回答对你有所帮助
如有其他问题,可以继续追问,您的采纳是我前进的动力!
如何在VB中执行屏幕捕捉在很多情况下捕捉屏幕上的画面是非常有用的,比如:记录电脑失灵或者写技术手册和软件文档 。你可以运用两种方法从vb程序中捕捉屏幕图片 。一种是复杂的方法,包含windows的设备描述表和API组件,还有一种简单的方法运用windows内置的屏幕捕捉能力 。按下PrintScrn键将整个屏幕复制到剪贴板中,而[Alt]+[PrintScrn]键只能复制现用视窗 。理论上,所有的vb程序都需要用到这个键 。但是,你不能用SendKeys函数来完成这个功能 。ByVal dwExtraInfo As Long) 下面是介绍如何将捕获的图片复制到剪贴板中,首先声明一个常量:Const VK_SNAPSHOT As Byte = H2C然后使用下面的代码将现用视窗复制到剪贴板中:Call keybd_event(VK_SNAPSHOT, 0, 0, 0) 如果你想捕获整个屏幕,你可以这么做:Call keybd_event(VK_SNAPSHOT, 1, 0, 0)一旦屏幕的图片复制到了剪贴板中,你将会运用剪贴板的对象的GetData方法检索它 。
VB截取屏幕[DllImport("user32.dll", EntryPoint = "GetDC")]
public static extern IntPtr GetDC(IntPtr hWnd);
[DllImport("user32.dll", EntryPoint = "ReleaseDC")]
public static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDC);
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("user32.dll", SetLastError = true)]
【vb.net屏幕抓图 vbs截图代码】static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

推荐阅读