Jump to content

Control Click Item using a wildcard


Recommended Posts

I am working on automating an application and need to be able to click on an item in a treeview. I can successfully select the item if I match the text perfectly but the problem is the text changes during each launch of the application. The end of the text takes on a date and state so the tail end of the control is always different. I am trying to figure out how to insert a wildcard so I can click on the treeview item regardless of what the date is.  The following code clicks on what I need but doesn't have a wildcard in it so it only works once.

$treeView_hnd = ControlGetHandle($title, "", $window)
$findItem = _GUICtrlTreeView_FindItem($treeView_hnd, "Scapa Test Trace - FullTest 20170530-090754")
_GUICtrlTreeView_ClickItem($treeView_hnd, $findItem)

 

Link to comment
Share on other sites

  • Moderators

I believe if you set the third parameter, $bInStr, you could search for your partial string.

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Thanks for your response, I tried the following but still no luck. 

$treeView_hnd = ControlGetHandle($title, "", $window)
$findItem = _GUICtrlTreeView_FindItem($treeView_hnd, "Scapa Test Trace - FullTest 20170605-11403", $bInStr = True)
_GUICtrlTreeView_ClickItem($treeView_hnd, $findItem)

Update, I failed to realize that the variable didn't need to be in the actual code. The following code worked.

 

$treeView_hnd = ControlGetHandle($title, "", $window)
$findItem = _GUICtrlTreeView_FindItem($treeView_hnd, "Scapa Test Trace - FullTest", True)
_GUICtrlTreeView_ClickItem($treeView_hnd, $findItem)

 

Edited by dubd83
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...