Jump to content

Get a name or ID by the last 3 characters in Internet Explorer [Solved]


Recommended Posts

I am trying to grab the id "in2xk_26" however it the characters before the underscore always change. (in the name too)

Is there a way I can find a id or name by the last 3 charcters?

Using something like "stringright?"

So I would want to search for just "_26" in this case.

This is assuming that there are no other _26

 

example.PNG.0ef042f8df6f6a0a24da82fa8dd254ae.PNG

#include <Excel.au3>
#include <IE.au3>
#include <GUIConstantsEx.au3>

Global $iMousespeed = 25,$target = "",$TagName = "",$Value = "",$Atrribute = ""



$oIE = _IEAttach("MEDITECH")

$TagName = "input"
$Value = "in2xk_26"
$Attribute = "id"


$tags = $oIE.document.GetElementsByTagName($TagName) ;TagName  ------ MAKE SURE TO NAME THESE
For $tag in $tags
$class_value = $tag.GetAttribute($Attribute)    ;Attribute ------ MAKE SURE TO NAME THESE
If string($class_value) = $Value Then           ;Value  ------ MAKE SURE TO NAME THESE
    $target = $tag

      $iScreenX = _IEPropertyGet($target, "screenx")
      $iScreenY = _IEPropertyGet($target, "screeny")
      $iWidth   = _IEPropertyGet($target, "width")
      $iHeight  = _IEPropertyGet($target, "height")

      $oMouseCords = MouseMove($iScreenX + $iWidth / 2, $iScreenY + $iHeight / 2, $iMousespeed)

      MouseClick($MOUSE_CLICK_LEFT)

    ExitLoop

EndIf
Next

 

 

Edited by SkysLastChance

You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott

Link to comment
Share on other sites

You will need to grab all and loop through to find your specific one.   if you can create an xpath, you can use my signature to do the loops for you.

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

I believe this would be my xpath? However, the Id and name are always changing so I am not sure how this would work???

//*[@id="in2xk_26"]
Edited by SkysLastChance

You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott

Link to comment
Share on other sites

Ah, dynamic.  won't work for that.  try going up a level and look for something static.  or something from a sibling node

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

That td is also only displaying dynamic data.  do any of the other td nodes have text?

Maybe a screenshot of the actual rendered table.

 

You are on the right track.   when you can find the right tr, you can dig intoit's child nodes to get the proper cell

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

So, if you are looking for the first name input, you can find the label next to it by the innertext firstname....then .getparent, and get the childnode for the input....or use .nextsibling

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

14 hours ago, SkysLastChance said:

So I would want to search for just "_26" in this case.
This is assuming that there are no other _26

Couldn't such a simple workaround be used ?

$var = "_26"

; $sHTML = '<input name="in2xk_92" class="navitem s_147" id="in2xk_26" style="..." etc>'
$sHTML = _IEDocReadHTML($oIE)
$id = StringRegExpReplace($sHTML, '(?s).*?id="(\w+' & $var & ').*', "$1")
; Msgbox(0,"", $id)
$oInput = _IEGetObjById($oIE, $id)
; etc

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...