找回密码
 加入
搜索
查看: 7310|回复: 20

如何获取鼠标点击IE控件的名字?

[复制链接]
发表于 2009-6-22 22:10:50 | 显示全部楼层 |阅读模式
如何获取鼠标点击IE控件的名字?比如说我的鼠标点了一下IE的RADIO控件,AU3就会返回这个RADIO控件的名字?
谢谢:)
发表于 2009-6-22 22:35:42 | 显示全部楼层
应该没有那么智能的东西吧??反过来我就知道..
 楼主| 发表于 2009-6-22 22:43:56 | 显示全部楼层
=。=!反过来我也知道。。。
目前我有1个方法可以实现,但是遇到一些非TXT文本的控件就不灵了,具体方法如下:
遍历一次表单控件,然后将控件的名字(TXT类型的)写入INPUT框,然后再运行一个程序监控,如果里面的文字变了,那么这个控件就是被修改的,但是如果是BUTTON类的,或者是CHECKBOX类的我就没招了,寻求高手指点...
发表于 2009-6-22 22:53:03 | 显示全部楼层
如果楼主研究出来,还真是一个不错的工具了
支持原创,继续研究
发表于 2009-6-24 12:29:49 | 显示全部楼层
=。=!反过来我也知道。。。
目前我有1个方法可以实现,但是遇到一些非TXT文本的控件就不灵了,具体方法如下:
遍历一次表单控件,然后将控件的名字(TXT类型的)写入INPUT框,然后再运行一个程序监控,如果里面的 ...
35888894 发表于 2009-6-22 22:43

可以用该部分HTML代码的改变作为思考方向
 楼主| 发表于 2009-6-24 19:03:04 | 显示全部楼层
可以用该部分HTML代码的改变作为思考方向
liongodmien 发表于 2009-6-24 12:29

非常感谢老哥给予指点,那么能否再具体点的来点实例呢?小弟不胜感激!
发表于 2009-6-25 12:21:30 | 显示全部楼层
是否可以用正则匹配需要监控改变的源代码字符段
然后stringcompara来对
呢?
 楼主| 发表于 2009-6-27 20:30:00 | 显示全部楼层
是否可以用正则匹配需要监控改变的源代码字符段
然后stringcompara来对
呢?
autoit3CN 发表于 2009-6-25 12:21

好像不行,单位的系统是Struts框架的。。。抓取很难....VERY难....嗷嗷难.....
发表于 2009-6-27 21:42:28 | 显示全部楼层
本帖最后由 zengjinbai 于 2009-6-27 21:44 编辑

我个人的看法:
  可以修改网页源码,比如增加个点击事件,让控件点击时候就运行JS代码,用JS返回控件名字。
  就我了解,这可以实现。
 楼主| 发表于 2009-6-27 22:05:48 | 显示全部楼层
我个人的看法:
  可以修改网页源码,比如增加个点击事件,让控件点击时候就运行JS代码,用JS返回控件名字。
  就我了解,这可以实现。
zengjinbai 发表于 2009-6-27 21:42

如何实现呢?能否来个例子?这个问题困扰我NNNNN久了
发表于 2009-6-27 23:06:46 | 显示全部楼层
其实网上已经有类似的工具了。叫做:  IE WebDeveloper   我一直用这个东西。非常好用啊!强力推荐!
发表于 2009-6-27 23:08:04 | 显示全部楼层
可不可以用这个http://www.autoitx.com/forum.php ... &extra=page%3D2?我不懂哦,这是觉得类似
 楼主| 发表于 2009-6-27 23:17:26 | 显示全部楼层
我也知道有这样的工具,不过我想实现的项目是
用户操作完一次IE,然后自动纪录修改的控件名称,自动生成一个配制文件,然后通过这个配制文件再进行回放,就是类似于QTP的功能,不过我们单位的系统是STRUTS框架生成的,NND都是JS脚本,我跟踪只能跟踪到前台登陆,登陆然后就不能再继续跟踪了,下面贴下我写的代码
#include <ie.au3>
#include <WinAPI.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Dim $inipath=@ScriptDir&"/peizhi.ini";检测用
Dim $inipath4=@ScriptDir&"/peizhi4.ini";检测用
Dim $inipath2=@ScriptDir&"/peizhi2.ini";排序用
Dim $inipath3=@ScriptDir&"/peizhi3.ini";检测类型用
Dim $show=0
Dim $mem=0
Dim $step=1
Dim $exit=0
Dim $url=""
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("表单控件跟踪测试", 361, 91, 283, 234)
$Input1 = GUICtrlCreateInput("http://tg1a146.mail.163.com/a/j/js3/main.jsp?sid=qCVFwVbbDFmCmtQnWHbbXBKQAgVkXzOb", 11, 23, 337, 21)
GUICtrlSetTip($Input1, "GOOD")
$Button1 = GUICtrlCreateButton("开始", 79, 49, 65, 33, 0)
$Button2 = GUICtrlCreateButton("退出", 215, 49, 65, 33, 0)
$Group1 = GUICtrlCreateGroup("输入要跟踪的IE地址:", 2, 4, 356, 84)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
AdlibRegister("OK123",50)
_IEErrorHandlerRegister()
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Button1
    $oIE = _IECreate(GUICtrlRead($Input1), 0, 1, 1,0)
   bdshuaxin()
   
   
   
  $show=1;=1开启追踪
  Case $Button2
 ; $oForm = _IEFormGetObjByName ($oIE, "register")
 ; $oText = _IEFormElementGetObjByName ($oForm, "username")
 ; MsgBox(0, "Form Element Value", _IEFormElementGetValue ($oText))
 $exit=1
EndSwitch

WEnd





Func bdshuaxin();表单刷新
                         
                         
                         
        $oForms = _IEFormGetCollection($oIE)
   $CONTER = @extended
  ; MsgBox(0, "表单信息", "这个页面上共有" & $CONTER & "个表单", 3)
  TrayTip("提示","准备就绪,可以进行文本控件监控",6,1)
  $file=FileOpen($inipath,2)
  FileClose($file)
  
   $file=FileOpen($inipath2,2)
  FileClose($file)
   $file=FileOpen($inipath3,2)
  FileClose($file)
     $file=FileOpen($inipath4,2)
  FileClose($file)
  
  IniWriteSection ( $inipath2, "步骤", "0="&_IEPropertyGet ($oIE, "locationurl"))

  For $Form In $oForms
        IniWriteSection ($inipath, $Form.name, "")
        IniWriteSection ($inipath4, $Form.name, "")
        IniWriteSection ($inipath3, $Form.name, "")
    $oQuerys = _IEFormElementGetCollection($Form)
   For $Query In $oQuerys
   IniWrite($inipath,$Form.name,$Query.name,"")
    IniWrite($inipath4,$Form.name,$Query.name,"")
   IniWrite($inipath3,$Form.name,$Query.name,$Query.type)
 Next
   Next
   $url=_IEPropertyGet ($oIE, "locationurl")
   ; MsgBox(0,"",$url)
        EndFunc




Func OK123()
 If $show=1 Then
         biandanshuaxin2();是否增加表单监控
$var = IniReadSectionNames($inipath)
If @error Then 
 Else
If $var[0]>=1 Then;表单个数大于1
 For $i=1 To $var[0]
   $oForm = _IEFormGetObjByName ($oIE, $var[$i])
   $var2 = IniReadSection($inipath, $var[$i]);获得表单名称为$var[$i]中的全部控件名称集合$var2
   If @error Then 
   Else
   For $j=1 To $var2[0][0];控件个数大于1
    
     $oText = _IEFormElementGetObjByName ($oForm, $var2[$j][0])
      $ml=_IEFormElementGetValue ($oText)
      
        If $mem=0 Then IniWrite($inipath,$var[$i],$var2[$j][0],$ml)
    
     If IniRead($inipath,$var[$i],$var2[$j][0],"")<>$ml Then;发现此时控件内容不等于预设内容
      
      TrayTip("提示",$var2[$j][0]&"控件名被改变,目前值为:"&$ml,6,1)
          IniWrite($inipath,$var[$i],$var2[$j][0],$ml);将值写入INI文件,不能为0
     If ($ml<>0 Or IniRead($inipath,$var[$i],$var2[$j][0],"")="") Then IniWrite($inipath4,$var[$i],$var2[$j][0],$ml)
      
      $var3 = IniReadSection($inipath2,"步骤") ;步骤中的全部变量集合$var3
       If @error Then 
       Else
        
       Local $sfy=0
       For $z=1 To $var3[0][0]
                   
                ;$s=StringRegExp($var3[$z][1], "\S+\s+\控件名称:+(.)", 3)
                ;MsgBox(0,"",$s)
        If StringRight($var3[$z][1],StringLen($var3[$z][1])-StringInStr($var3[$z][1],":",0,-1))=$var2[$j][0] And StringMid($var3[$z][1],6,StringInStr($var3[$z][1],"控件名称:")-7)=$var[$i] Then $sfy=1
        ;MsgBox(0,$var3[0][0],$var3[$z][0])
       Next
        If $sfy=0 Then 
         ;MsgBox(0,"","写入")
         IniWrite($inipath2,"步骤",String($step),"表单名称:"&$var[$i]&" 控件名称:"&$var2[$j][0])
        $step+=1
                EndIf
         
       EndIf
      
          
          
     EndIf
   Next
   EndIf
 Next
EndIf
EndIf
$mem=1
EndIf
If $exit=1 Then Exit
 EndFunc



        
        
Func biandanshuaxin2();表单刷新2
        ;If $url<>_IEPropertyGet ($oIE, "locationurl")Then
        ;_IENavigate ($oIE, _IEPropertyGet ($oIE, "locationurl"))
        ;        $oResult=_IEAttach ( _IEPropertyGet ($oIE, "locationurl"),"url")
        ;        If IsObj($oResult) Then
        ;                WinActivate(HWnd($oResult.HWND))
        ;                SetError($_IEStatus_Success)
        ;                SetExtended(1)
        ;                $oIE=$oResult
        ;        EndIf
        ;$oIE=_IECreate(_IEPropertyGet ($oIE, "locationurl"),1, 1, 0)
        ;_IEAttach ("The quick brown fox", "text")
        $oIE=_IECreate(_IEAttach ($oIE, "text"),1, 1, 0)
        
        
        
        
;         $url=_IEPropertyGet ($oIE, "locationurl")
         ;MsgBox(0,"",$url)
;        EndIf
        
        
        $oForms = _IEFormGetCollection($oIE)
        $var = IniReadSectionNames($inipath)
        If @error Then 
        Else
                
        For $Form In $oForms;这是个循环,察看INI文件中是否包括本表单
                Local $vpo=0
                For $i=1 To $var[0]
                        If $Form.name=$var[$i] Then $vpo=1
                Next
                If $vpo=0 Then 
                        IniWriteSection ($inipath, $Form.name, "")
                        IniWriteSection ($inipath4, $Form.name, "")
                        IniWriteSection ($inipath3, $Form.name, "")
                        $oQuerys = _IEFormElementGetCollection($Form)
                   For $Query In $oQuerys
                   IniWrite($inipath,$Form.name,$Query.name,"")
                   IniWrite($inipath4,$Form.name,$Query.name,"")
                   IniWrite($inipath3,$Form.name,$Query.name,$Query.type)
                        Next
           
           EndIf
                Next
                         
        EndIf                 
        EndFunc
发表于 2009-6-27 23:40:44 | 显示全部楼层
不懂,我是只垃圾菜鸟,帮不了你,等高手来解决吧

pcbar应该能帮上你的忙,你自己联系下,呵呵
 楼主| 发表于 2009-6-28 11:40:02 | 显示全部楼层

那个大哥能帮下小弟,不胜感激
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-23 01:23 , Processed in 0.083752 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表