cnergao 发表于 2010-4-6 21:46:45

请问如何右击IE中的图片链接

图片链接的HTML代码如下:
<LI id=3052062 sizcache="2045" sizset="0" jQuery1270550248875="1477">
<DIV style="CURSOR: move" sizcache="2045" sizset="0"><IMG class="toolTip isOperate" id=10026,11 title="" alt="" src="http://f1.uuplay.com/sys/img/icon/ls.png" type="11" tooltip='<ul class="goodsTip"><li class="q1"><h4>螺丝</h4></li><li><span class="Right"><可交易></span><span>【工程材料】</span></li><li class="description"><span>用于制造应急修补线的零件</span></li><li class="price">回收价格: <span class="moneyBottle">22</span></li><li class="tips">右键单击展开操作条</li></ul>' jQuery1270550248875="1574"><SPAN></SPAN></DIV></LI>
前台抓图操作已经可以顺利进行。但是不知道怎么后台抓图抓色。

我想要把这个换成后台右击操作它。不知道有没有什么好的方法可以实现。

cnergao 发表于 2010-4-7 19:03:31

下面是在国外网站上看到的。从内存中取色。不知道可不可以取图片。。。看介绍也是可以的。要先把抓的图片读放内存。不知道具体怎么操作。。大家一起来研究研究~

#include <ScreenCapture.au3>
#include <Misc.au3>
#include-once


$hDll = DllOpen("gdi32.dll")

$vDC = _PixelGetColor_CreateDC($hDll)

$vRegion = _PixelGetColor_CaptureRegion($vDC, 0,0,@DesktopWidth,@DesktopHeight,$hDll)

; click left mouse button to exit
While Not _IsPressed(0x01)
    $aPos = MouseGetPos()
    $sColor = _PixelGetColor_GetPixel($vDC, $aPos,$aPos, $hDll)

    ToolTip("The color under your mouse is: " & $sColor, $aPos+3, $aPos+3, "_PixelGetColor_GetPixel return",$hDll)
WEnd

_PixelGetColor_ReleaseRegion($vRegion)

_PixelGetColor_ReleaseDC($vDC,$hDll)

DllClose($hDll)










; #FUNCTION# ;===============================================================================
;
; Name...........: _PixelGetColor_CreateDC
; Description ...: Creates a DC for use with the other _PixelGetColor functions.
; Syntax.........: _PixelGetColor_CreateDC()
; Parameters ....: None.
; Return values .: Success - Returns the handle to a compatible DC.
;                  Failure - Returns 0 and Sets @error according to @error from the DllCall.
; Author ........: Jos van Egmond
; Modified.......:
; Remarks .......:
; Related .......: _PixelGetColor_CaptureRegion, _PixelGetcolor_GetPixel, _PixelGetColor_GetPixelRaw, _PixelGetColor_ReleaseRegion, _PixelGet_Color_ReleaseDC
; Example .......; No
;
; ;==========================================================================================
Func _PixelGetColor_CreateDC($hDll = "gdi32.dll")
        $iPixelGetColor_MemoryContext = DllCall($hDll, "int", "CreateCompatibleDC", "int", 0)
        If @error Then Return SetError(@error,0,0)
        Return $iPixelGetColor_MemoryContext
EndFunc

; #FUNCTION# ;===============================================================================
;
; Name...........: _PixelGetColor_CaptureRegion
; Description ...: Captures the user defined region and reads it to a memory DC.
; Syntax.........: _PixelGetColor_CaptureRegion($iPixelGetColor_MemoryContext, $iLeft = 0, $iTop = 0, $iRight = -1, $iBottom = -1, $fCursor = False)
; Parameters ....: $iPixelGetColor_MemoryContext        - The DC as returned by _PixelGetColor_CreateDC
;                                        $iLeft                - Left side of the screen for use with the region
;                                        $iTop                - Top side of the screen for use with the region
;                                        $iRight                - Right side of the screen for use with the region
;                                        $iBottom        - Bottom side of the screen for use with the region
;                                        $iCursor         - If this is true, then the cursor is also read into memory
; Return values .: Success - Returns the handle to a region.
;                  Failure -
; Author ........: Jos van Egmond
; Modified.......:
; Remarks .......:
; Related .......: _PixelGet_Color_CreateDC, _PixelGetcolor_GetPixel, _PixelGetColor_GetPixelRaw, _PixelGetColor_ReleaseRegion, _PixelGet_Color_ReleaseDC
; Example .......; No
;
; ;==========================================================================================
Func _PixelGetColor_CaptureRegion($iPixelGetColor_MemoryContext, $iLeft = 0, $iTop = 0, $iRight = -1, $iBottom = -1, $fCursor = False, $hDll = "gdi32.dll")
        $HBITMAP = _ScreenCapture_Capture("", $iLeft, $iTop, $iRight, $iBottom, $fCursor)
        DllCall($hDll, "hwnd", "SelectObject", "int", $iPixelGetColor_MemoryContext, "hwnd", $HBITMAP)
        Return $HBITMAP
EndFunc

; #FUNCTION# ;===============================================================================
;
; Name...........: _PixelGetColor_GetPixel
; Description ...: Gets a pixel color from the DC in decimal BGR and converts it to RGB in 6 digit hexadecimal.
; Syntax.........: _PixelGetColor_GetPixel($iPixelGetColor_MemoryContext,$iX,$iY)
; Parameters ....: $iPixelGetColor_MemoryContext        - The DC as returned by _PixelGetColor_CreateDC
;                                        $iX                - The X coordinate in the captured region
;                                        $iY                - The Y coordinate in the captured regoin
; Return values .: Success - Returns the 6 digit hex BGR color.
;                  Failure - Returns -1 and Sets @error to 1.
; Author ........: Jos van Egmond
; Modified.......:
; Remarks .......:
; Related .......: _PixelGetColor_CreateDC, _PixelGetColor_CaptureRegion, _PixelGetColor_GetPixelRaw, _PixelGetColor_ReleaseRegion, _PixelGet_Color_ReleaseDC
; Example .......; Yes
;
; ;==========================================================================================
Func _PixelGetColor_GetPixel($iPixelGetColor_MemoryContext,$iX,$iY, $hDll = "gdi32.dll")
        $iColor = DllCall($hDll,"int","GetPixel","int",$iPixelGetColor_MemoryContext,"int",$iX,"int",$iY)
        If $iColor = -1 then Return SetError(1,0,-1)
        $sColor = Hex($iColor,6)
        Return StringRight($sColor,2) & StringMid($sColor,3,2) & StringLeft($sColor,2)
EndFunc

; #FUNCTION# ;===============================================================================
;
; Name...........: _PixelGetColor_GetPixelRaw
; Description ...: Gets a pixel color from the DC in decimal BGR.
; Syntax.........: _PixelGetColor_GetPixelRaw($iPixelGetColor_MemoryContext,$iX,$iY)
; Parameters ....: $iPixelGetColor_MemoryContext        - The DC as returned by _PixelGetColor_CreateDC
;                                        $iX                - The X coordinate in the captured region
;                                        $iY                - The Y coordinate in the captured regoin
; Return values .: Success - Returns the color in decimal BGR.
;                  Failure - Returns -1 and Sets @error to 1.
; Author ........: Jos van Egmond
; Modified.......:
; Remarks .......:
; Related .......: _PixelGetColor_CreateDC, _PixelGetColor_CaptureRegion, _PixelGetColor_GetPixel, _PixelGetColor_ReleaseRegion, _PixelGet_Color_ReleaseDC
; Example .......; No
;
; ;==========================================================================================
Func _PixelGetColor_GetPixelRaw($iPixelGetColor_MemoryContext,$iX,$iY, $hDll = "gdi32.dll")
        $iColor = DllCall($hDll,"int","GetPixel","int",$iPixelGetColor_MemoryContext,"int",$iX,"int",$iY)
        Return $iColor
EndFunc

; #FUNCTION# ;===============================================================================
;
; Name...........: _PixelGetColor_ReleaseRegion
; Description ...: Releases a region previously created by calling _PixelGetColor_CaptureRegion
; Syntax.........: _PixelGetColor_ReleaseRegion($HBITMAP)
; Parameters ....: $HBITMAP - Previously returned by _PixelGetColor_CaptureRegion
; Return values .: None.
; Author ........: Jos van Egmond
; Modified.......:
; Remarks .......:
; Related .......: _PixelGetColor_CreateDC, _PixelGetColor_CaptureRegion, _PixelGetcolor_GetPixel, _PixelGetColor_GetPixelRaw, _PixelGet_Color_ReleaseDC
; Example .......; No
;
; ;==========================================================================================
Func _PixelGetColor_ReleaseRegion($HBITMAP)
        _WinAPI_DeleteObject($HBITMAP)
EndFunc

; #FUNCTION# ;===============================================================================
;
; Name...........: _PixelGetColor_ReleaseDC
; Description ...: Releases a region previously created by calling _PixelGetColor_CreateDC
; Syntax.........: _PixelGetColor_ReleaseDC($iPixelGetColor_MemoryContext)
; Parameters ....: $iPixelGetColor_MemoryContext - Previously returned by _PixelGetColor_CreateDC
; Return values .: None.
; Author ........: Jos van Egmond
; Modified.......:
; Remarks .......:
; Related .......: _PixelGetColor_CreateDC, _PixelGetColor_CaptureRegion, _PixelGetcolor_GetPixel, _PixelGetColor_GetPixelRaw, _PixelGetColor_ReleaseRegion
; Example .......; No
;
; ;==========================================================================================
Func _PixelGetColor_ReleaseDC($iPixelGetColor_MemoryContext, $hDll = "gdi32.dll")
        DllCall($hDll, "int", "DeleteDC", "hwnd", $iPixelGetColor_MemoryContext)
EndFunc

newuser 发表于 2010-4-8 08:47:39

回复 2# cnergao
要是能用中文注释讲解一下就太感谢了!

cnergao 发表于 2010-4-8 09:43:10

本人英文也不是太好。只能看个大概。

crkey12345 发表于 2010-4-8 16:29:42

发送右键菜单可以吗?

cnergao 发表于 2010-4-8 17:35:56

发送右键菜单,首先你要如何给图片定位?怎么确定是这张图片?

补充一下。图片的位置不是固定的。随时变动

crkey12345 发表于 2010-4-12 17:44:04

图片的位置不是固定的,那图片的url地址呢?是变化的吗?
历遍img应该可以找到吧。

cnergao 发表于 2010-4-12 19:31:44

可以找到。但是找到了也无法操作。。。代码如下;红色标志的就是图的地址。
<DIV style="CURSOR: move" sizcache="280" sizset="4"><IMG class="toolTip isOperate" id=22080,4 alt="" src="http://f1.uuplay.com/sys/img/icon/jsfl1.png" type="4" jQuery1270541908890="1018" tooltip="{isMaterials:true,name:'大坨垃圾',quality:'q1',oType:'废料',bindType:'可交易',description:'在挖撒星球上随处可见的金属垃圾',recyclePrice:26}"><SPAN></SPAN></DIV></LI>
<LI id=3052063 jQuery1270541908890="992" sizcache="280" sizset="5">
<DIV style="CURSOR: move" sizcache="280" sizset="5"><IMG class="toolTip isOperate" id=10026,11 alt="" src="http://f1.uuplay.com/sys/img/icon/ls.png" type="11" jQuery1270541908890="1022" tooltip="{isMaterials:true,name:'螺丝',quality:'q1',oType:'工程材料',bindType:'可交易',description:'用于制造应急修补线的零件',recyclePrice:22}"><SPAN></SPAN></DIV></LI>
<LI id=3052082 jQuery1270541908890="994" sizcache="280" sizset="6">

crkey12345 发表于 2010-4-13 10:55:37

网页地址是什么?貌似其中有框架

cnergao 发表于 2010-4-14 09:59:34

http://f1.uuplay.com/main.aspx
是有框架的。网页游戏

clshuai 发表于 2010-4-14 21:00:57

楼主可以通过IE.au3中的_IEImgClick()函数,这个操作很方便

menfan 发表于 2010-4-14 21:07:57

呵呵,学习一下。。

cnergao 发表于 2010-4-15 10:10:54

本帖最后由 cnergao 于 2010-4-15 10:12 编辑

_IEImgClick()这个是左击的吧。他这个只能是右击才有操作反应。左击没用的。。我要的是右击图片。。IE.au3里有没有右击的操作?

zengjinbai 发表于 2010-4-27 00:05:10

其实这个有个办法解决,改变网页的代码,把右击触发的代码改为左击触发,.这个可以成功,因为以前有写过,.

lanfengc 发表于 2010-4-27 12:16:36

回复 2# cnergao


    本人不才,简单翻译一下,如有不对,请见谅!#include <ScreenCapture.au3>
#include <Misc.au3>
#include-once


$hDll = DllOpen("gdi32.dll")
$vDC = _PixelGetColor_CreateDC($hDll)
$vRegion = _PixelGetColor_CaptureRegion($vDC, 0,0,@DesktopWidth,@DesktopHeight,$hDll)
;点击鼠标左键退出。
While Not _IsPressed(0x01)
    $aPos = MouseGetPos()
    $sColor = _PixelGetColor_GetPixel($vDC, $aPos,$aPos, $hDll)

    ToolTip("鼠标下的颜色是: " & $sColor, $aPos+3, $aPos+3, "数据由 _PixelGetColor_GetPixel 函数返回",$hDll)
WEnd
_PixelGetColor_ReleaseRegion($vRegion)
_PixelGetColor_ReleaseDC($vDC,$hDll)
DllClose($hDll)

; #子函数# ;===============================================================================
;
; 函数名.........: _PixelGetColor_CreateDC
; 作用 ..........: 创建一个DC供另外的函数 _PixelGetColor 使用。
; 用法...........: _PixelGetColor_CreateDC()
; 参数 ..........: 无.
; 返回数据..... .: 成功 - 返回一个公用的DC 句柄指针.
;                  失败 - 返回0并将@error 设置成DLLCALL返回的@error值.
; 作者? ........: Jos van Egmond
; Modified.......:
; 修改    .......:
; 相关函数.......: _PixelGetColor_CaptureRegion, _PixelGetcolor_GetPixel, _PixelGetColor_GetPixelRaw, _PixelGetColor_ReleaseRegion, _PixelGet_Color_ReleaseDC
; 例子    .......; 无
;
; ;==========================================================================================
Func _PixelGetColor_CreateDC($hDll = "gdi32.dll")
      $iPixelGetColor_MemoryContext = DllCall($hDll, "int", "CreateCompatibleDC", "int", 0)
      If @error Then Return SetError(@error,0,0)
      Return $iPixelGetColor_MemoryContext
EndFunc

; #FUNCTION# ;===============================================================================
;
; 函数名.......: _PixelGetColor_CaptureRegion
; 作用 ........: 抓取用户定义的一个区域并将之放置到一个内存DC中.
; 用法.........: _PixelGetColor_CaptureRegion($iPixelGetColor_MemoryContext, $iLeft = 0, $iTop = 0, $iRight = -1, $iBottom = -1, $fCursor = False)
; 参数 ....: $iPixelGetColor_MemoryContext      - 由函数 _PixelGetColor_CreateDC 返回的DC
;            $iLeft         - 用户定义的矩形区域的左边
;            $iTop            - 用户定义的矩形区域的上边
;            $iRight          - 用户定义的矩形区域的右边
;            $iBottom         - 用户定义的矩形区域的底部
;            $iCursor         - 如果这个值是TRUE, 那么鼠标也会被抓取到内存中。
; 返回数据 .: 成功 - 返回矩形区域的HANDLE(句柄).
;             失败 -
; 作者 ........: Jos van Egmond
; Modified.......:
; 修改 ..........:
; 相关函数 ......: _PixelGet_Color_CreateDC, _PixelGetcolor_GetPixel, _PixelGetColor_GetPixelRaw, _PixelGetColor_ReleaseRegion, _PixelGet_Color_ReleaseDC
; 例子    .......; 无
;
; ;==========================================================================================
Func _PixelGetColor_CaptureRegion($iPixelGetColor_MemoryContext, $iLeft = 0, $iTop = 0, $iRight = -1, $iBottom = -1, $fCursor = False, $hDll = "gdi32.dll")
      $HBITMAP = _ScreenCapture_Capture("", $iLeft, $iTop, $iRight, $iBottom, $fCursor)
      DllCall($hDll, "hwnd", "SelectObject", "int", $iPixelGetColor_MemoryContext, "hwnd", $HBITMAP)
      Return $HBITMAP
EndFunc

; #FUNCTION# ;===============================================================================
;
; 函数名...........: _PixelGetColor_GetPixel
; 作用 ...: 从DC句柄读取一个坐标的10进制BGR格式的颜色值然后将之转换成6位16进制的RGB格式的颜色值.
; 用法.........: _PixelGetColor_GetPixel($iPixelGetColor_MemoryContext,$iX,$iY)
; 参数 ....: $iPixelGetColor_MemoryContext      - 由函数 _PixelGetColor_CreateDC 返回的DC句柄
;            $iX                - 抓取点的X坐标
;            $iY                - 抓取点的Y坐标
; 返回数据 .: 成功 - 返回6位16进制RGB格式的颜色值.
;             失败 - 返回-1并将@error设置为 1.
; 作者 ........: Jos van Egmond
; Modified.......:
; 修改 ..........:
; 相关函数 ......: _PixelGetColor_CreateDC, _PixelGetColor_CaptureRegion, _PixelGetColor_GetPixelRaw, _PixelGetColor_ReleaseRegion, _PixelGet_Color_ReleaseDC
; 例子    .......; 是
;
; ;==========================================================================================
Func _PixelGetColor_GetPixel($iPixelGetColor_MemoryContext,$iX,$iY, $hDll = "gdi32.dll")
      $iColor = DllCall($hDll,"int","GetPixel","int",$iPixelGetColor_MemoryContext,"int",$iX,"int",$iY)
      If $iColor = -1 then Return SetError(1,0,-1)
      $sColor = Hex($iColor,6)
      Return StringRight($sColor,2) & StringMid($sColor,3,2) & StringLeft($sColor,2)
EndFunc

; #FUNCTION# ;===============================================================================
;
; 函数名...........: _PixelGetColor_GetPixelRaw
; 作用 ...: 从DC句柄中获取一个点的10进制BGR格式的颜色值.
; 用法.........: _PixelGetColor_GetPixelRaw($iPixelGetColor_MemoryContext,$iX,$iY)
; 参数 ....: $iPixelGetColor_MemoryContext      - 函数_PixelGetColor_CreateDC返回的DC句柄
;            $iX                - 抓取点的X坐标
;            $iY                - 抓取点的Y坐标
; 返回数据 .: 成功 - 返回10进制BGR格式的颜色.
;             失败 - 返回-1并将@error设置为 1.
; 作者 ........: Jos van Egmond
; Modified.......:
; 修改 ..........:
; 相关函数.......: _PixelGetColor_CreateDC, _PixelGetColor_CaptureRegion, _PixelGetColor_GetPixel, _PixelGetColor_ReleaseRegion, _PixelGet_Color_ReleaseDC
; 例子.......; 无
;
; ;==========================================================================================
Func _PixelGetColor_GetPixelRaw($iPixelGetColor_MemoryContext,$iX,$iY, $hDll = "gdi32.dll")
      $iColor = DllCall($hDll,"int","GetPixel","int",$iPixelGetColor_MemoryContext,"int",$iX,"int",$iY)
      Return $iColor
EndFunc

; #FUNCTION# ;===============================================================================
;
; 函数名...........: _PixelGetColor_ReleaseRegion
; 作用 ...: 释放一个被_PixelGetColor_CaptureRegion函数创建的选区
; 用法.........: _PixelGetColor_ReleaseRegion($HBITMAP)
; 参数 ....: $HBITMAP - 由函数 _PixelGetColor_CaptureRegion 创建的区域
; 返回数据.: 无.
; 作者 ........: Jos van Egmond
; Modified.......:
; 修改 ..........:
; 相关函数. .......: _PixelGetColor_CreateDC, _PixelGetColor_CaptureRegion, _PixelGetcolor_GetPixel, _PixelGetColor_GetPixelRaw, _PixelGet_Color_ReleaseDC
; 例子.......; 无
;
; ;==========================================================================================
Func _PixelGetColor_ReleaseRegion($HBITMAP)
      _WinAPI_DeleteObject($HBITMAP)
EndFunc

; #FUNCTION# ;===============================================================================
;
; 函数名..........: _PixelGetColor_ReleaseDC
; 作用 ...: 释放一个由 _PixelGetColor_CreateDC函数创建的DC句柄
; 用法.........: _PixelGetColor_ReleaseDC($iPixelGetColor_MemoryContext)
; 参数....: $iPixelGetColor_MemoryContext - 由_PixelGetColor_CreateDC函数创建的内存指针
; 返回数据 .: 无.
; 作者 ........: Jos van Egmond
; Modified.......:
; 修改 ..........:
; 相关函数. .......: _PixelGetColor_CreateDC, _PixelGetColor_CaptureRegion, _PixelGetcolor_GetPixel, _PixelGetColor_GetPixelRaw, _PixelGetColor_ReleaseRegion
; 例子.......; 无
;
; ;==========================================================================================
Func _PixelGetColor_ReleaseDC($iPixelGetColor_MemoryContext, $hDll = "gdi32.dll")
      DllCall($hDll, "int", "DeleteDC", "hwnd", $iPixelGetColor_MemoryContext)
EndFunc
页: [1] 2
查看完整版本: 请问如何右击IE中的图片链接