Page 1 of 1

ThunderRT6TextBox

PostPosted: Fri Feb 05, 2010 2:54 am
by FrustratedNewb
I am trying to automate some tasks that use a program that was written in Visual. I am coming across a ThunderRT6TextBox when I do a declaration on several of the windows. I need to be able to select, read, and change the value in this box. I have no idea how to read in the value with PTD. I can get to the box using Typed Keys, but I can't find a way to read in the value or set it. Any help would be appreciated, Thanks!

Re: ThunderRT6TextBox

PostPosted: Fri Feb 05, 2010 2:54 pm
by john
Hello-

With a ThunderRT6TextBox, you should be able to use the built-in GetText() and SetText() methods. These methods work on any window, regardless of the class.

Code: Select all
use "MyThunderDecs.dec";  # The declarations file

string s = MyThunderWindow.MyThunderText.GetText();
disp(s);  # Displays the text from your text box

MyThunderWindow.MyThunderText.SetText("Hello");  # Sets the text of the box to 'Hello'



You could also use the 'define' keyword to trick Phantom into treating a ThunderRT6TextBox as a regular Edit, but this should not be necessary since GetText and SetText work on all windows, regardless of class.

I hope this helps!

-John

Re: ThunderRT6TextBox

PostPosted: Sat Feb 06, 2010 5:42 pm
by FrustratedNewb
Thanks, that did work, not sure what I was doing before. Now, I can't get the buttons to "Click()", any trick to that?

** ERROR: (1) from '\\vmware-host\Shared Folders\Desktop\Dropbox\Code\Automation\quickRun.psc' on line 12 - Function 'Click' is not a member of class 'ThunderRT6CommandButton'. (P00213)

use "advancedOptions.dec";
Advanced.Restrict.Click();


The declaration of the button is:
[ ]MainWin "Advanced"
( )Tag="Advanced Options"
( )Class="ThunderRT6FormDC"
( )Parent=1
( )Child=0
[ ]MainWin "Restrict"
( )Tag="Restrict Retrofits"
( )Class="ThunderRT6CommandButton"
( )Parent=0
( )Child=1

Re: ThunderRT6TextBox

PostPosted: Mon Feb 08, 2010 2:06 am
by FrustratedNewb
OK, I found a way around that one by using Select() and then TypeKeys("<SPACE>"). The final hangup, is the ThunderListBox. I can't seem to use GetCount or any of the other functions to get either the number of options or text of those in the list. If you can help me with this one I will be very

BTW, very impressed overall with Phantom and your help. I think if I can figure out the ThunderListBox that will be the last major hurdle. Thanks!

Re: ThunderRT6TextBox

PostPosted: Tue Feb 09, 2010 2:02 pm
by john
Hello-

You should be able to use the 'define' keyword to get Phantom to recognize non-MFC classes (like ThunderRT6CommandButton):

Code: Select all
use "Thunder.dec";

define ThunderRT6CommandButton=Button;
define ThunderListBox=ListBox;   # Or maybe SysListView32 if it is a ListView

# Now you can use Button and ListBox-specific methods
MyCommandButton.Click();
MyListBox.SelectString("My Item");


Basically, 'define' tricks Phantom into treating an un-recognized control class as a recognized (MFC) control class. This is not guaranteed to work on all non-MFC based classes. Unfortunately, it depends on the underlying implementation of the control. However, from prior experience, it should work for the ThunderRT6CommandButton, and I believe it will work for ThunderListBox.

I hope this helps. If the 'define' does not work in this case, let me know. There may be some other tricks we can use.

-John

Re: ThunderRT6TextBox

PostPosted: Wed Feb 17, 2010 9:52 pm
by FrustratedNewb
That seemed to do something, but it is tripping up on something. I can get the element names in one of the listboxes, but not the other one. Also, I can't select anything or get the currently selected item (returns -1). There are 2 ThunderRT6ListBoxes in the window. They both fall under the same AfxWnd40. I also tried SysListView to no avail.

Any other ideas? I can use the screen coordinates to click on things, but during the automation I won't be positive as the number of windows that will be open.

Re: ThunderRT6TextBox

PostPosted: Wed Feb 17, 2010 10:21 pm
by FrustratedNewb
John,
Amazing stuff. I found out that the window is actually changing once it is clicked. The listbox is jumping which variable it is. That is something that I would not have expected. Now it is working and I can try to move on! I'm sure I'll have some more questions in a few days, thanks!

Bryan