mgs2-007 发表于 2011-4-21 10:08:59

如何获取指定像素点的色彩值

请教如何用vbs获取指定坐标的像素点色彩值,谢谢

shanfeng1419 发表于 2011-4-25 08:39:37

能说的详细点么

mgs2-007 发表于 2011-4-25 11:24:21

换个问题获取static文本框的背景色。

lyscser 发表于 2011-4-25 13:29:58

考:
http://www.advancedqtp.com/knowledge-base/qtips/win32-id66/get-pixel-color/


Dim hDC, hWndDim iX, iY
'Declare win32 and gdi32 functions
Extern.Declare MicLong, "GetPixel", "gdi32″, "",MicLong, MicLong, MicLong
Extern.Declare MicLong, "GetDC", "user32″,"", MicLong
Extern.Declare micLong,"ReleaseDC","user32″,"",micLong,micLong
'Attach to the desktop graphical context
hWnd = cLng(0)
hDC = Extern.GetDC(hWnd)
iX = 10 'Change this to your relevant X coordinate
iY = 10 'Change this to your relevant Y coordinate
'Get the pixel color code
Print Extern.GetPixel (hDC, iX,iY)
'Release the graphical context
Extern.ReleaseDC hWnd, hDC

mgs2-007 发表于 2011-4-26 10:32:23

hWnd = cLng(0)

hDC = Extern.GetDC(hWnd)

这两行是获取屏幕设备吧。
我想要的可能会是被QTP遮盖住的软件的某个控件的颜色

lyscser 发表于 2011-5-9 15:50:09

hWnd = cLng(0)

hDC = Extern.GetDC(hWnd)

这两行是获取屏幕设备吧。
我想要的可能会是被QTP遮盖住 ...
mgs2-007 发表于 2011-4-26 10:32 http://bbs.51testing.com/images/common/back.gif

获取指定位置的颜色值

xorg = Browser("网易电子邮箱").Page("网易电子邮箱").Frame("index").Image("260x300").GetROProperty("abs_x")
yorg = Browser("网易电子邮箱").Page("网易电子邮箱").Frame("index").Image("260x300").GetROProperty("abs_y")

width = Browser("网易电子邮箱").Page("网易电子邮箱").Frame("index").Image("260x300").GetROProperty("width")
height = Browser("网易电子邮箱").Page("网易电子邮箱").Frame("index").Image("260x300").GetROProperty("height")

xnow = xorg + width/2
ynow = yorg + height/2

Extern.Declare micLong, "GetPixel","gdi32","",micLong,micLong,micLong
Extern.Declare micLong, "GetDC", "user32","",micLong
Extern.Declare micLong,"ReleaseDC","user32","",micLong, micLong

hWnd = cLng(0)
hDC = Extern.GetDC(hWnd)
Print Extern.GetPixel (hDC, xnow,ynow)
Extern.ReleaseDC hWnd, hDC
页: [1]
查看完整版本: 如何获取指定像素点的色彩值