Jump to content

Newbie help - get a value from a text field


Recommended Posts

Hi, I am extremely new to AutoIT (as you may be able to tell from my script) so I will give as much detail of what I am trying to do as well as the current version of the script.

Background:

This script will be opening a database file which contains at least 1 file (called model within the script) using our internal proprietary application. One of the things we can do with our models is to generate several different types of reports. The purpose of this script is to open a window (QC/TD Spreadsheet) that several values can be entered when running this specific report format. Please note that while the title of the window is QC/TD Spreadsheet, this is not an Excel spreadsheet. The purpose of this report, when exported, is to create a .csv file which we can run a custom made macro on.

If this is the first time you have opened the QC/TD Spreadsheet window for the specific model, then all the text fields (input fields?) will default to a blank value. If you have previously opened the QC/TD Spreadsheet window then the fields will retain the last entered value in each field. This may be blank if there had never been a previously entered value (or a value had existed and then been deleted).

Currently the script interacts with the application, and works properly as expected.

Problem:

I need to be able to evaluate the text fields current value when the QC/TD Spreadsheet opens and if a value exists in a field, then I need to get rid of it. (This could be a replace or delete and then the next line of code adds in the new value which is kind of how I have been doing it already)

The window does not allow CTRL-A to select the current value in the text box with focus.

The text box can contain a variety of character lengths (I am not sure of the current max length but there is not a minimum length for any field).

Double-click does work on the word hovered over, but triple-click does not work.

Tab into a field appears to set the cursor to the first position of the text box, does not select the current value.

The relevant code begins where I have blocked out a section titled "PROBLEM WITH FOLLOWING CODE".

Thank you in advance of any help you might be able to provide to me.

; Automate TestDirector Spreadsheet format

; Start and log into DTT
; Assumption - Open last model checkbox should be activated
; Assumption - The model should have been previously opened on the currently used machine
Run("C:\Program Files\Critical Logic\DTT.exe")
WinWaitActive("DTT Logon")
ControlClick("DTT Logon", "", "[CLASS:Edit; INSTANCE:1]")
ControlSend("DTT Logon", "", "[CLASS:Edit; INSTANCE:1]", "C:\Documents and Settings\Sean\Desktop\DTT Validation\Automation models\Automation_TestDirectorSpreadsheet.dtt")
Send("{ENTER}")

; Wait for DTT and model to open
; Assumption - The model being used should be the last opened model
; Assumption - The model has been generated
WinWaitActive("DTT - Functional Modeling")

; Open Reports menu
ControlClick("DTT - Functional Modeling", "", "[CLASS:ThunderRT6PictureBoxDC; INSTANCE:12]")
WinWaitActive("Reports")

ControlClick("Reports", "", "[CLASS:ThunderRT6OptionButton; INSTANCE:6]"); Activate TD Spreadsheet radio button
ControlClick("Reports", "", "[CLASS:ThunderRT6PictureBoxDC; INSTANCE:3]"); Trigger Reports button

WinWaitActive("QC/TD Spreadsheet")

;----------------------------- PROBLEM WITH FOLLOWING CODE -----------------------------------------------
ControlClick("QC/TD Spreadsheet", "", "[CLASS:ThunderRT6TextBox; INSTANCE:9]"); Target Subject textbox
ControlSend("QC/TD Spreadsheet", "", "[CLASS:ThunderRT6TextBox; INSTANCE:9]", "A Subject"); Enter Subject
;---------------------------------------------------------------------------------------------------------

ControlClick("QC/TD Spreadsheet", "", "[CLASS:ThunderRT6TextBox; INSTANCE:8]"); Target Test Name textbox
ControlSend("QC/TD Spreadsheet", "", "[CLASS:ThunderRT6TextBox; INSTANCE:8]", "Test@"); Enter TestName - Note that the test name should always end with "@"
ControlClick("QC/TD Spreadsheet", "", "[CLASS:ThunderRT6TextBox; INSTANCE:7]"); Target Designer textbox
ControlSend("QC/TD Spreadsheet", "", "[CLASS:ThunderRT6TextBox; INSTANCE:7]", "The Designer"); Enter Designer
ControlClick("QC/TD Spreadsheet", "", "[CLASS:ThunderRT6TextBox; INSTANCE:6]"); Target Status textbox
ControlSend("QC/TD Spreadsheet", "", "[CLASS:ThunderRT6TextBox; INSTANCE:6]", "The Status"); Enter Status
ControlClick("QC/TD Spreadsheet", "", "[CLASS:ThunderRT6TextBox; INSTANCE:3]"); Target Function textbox
ControlSend("QC/TD Spreadsheet", "", "[CLASS:ThunderRT6TextBox; INSTANCE:3]", "A Function"); Enter Function
ControlClick("QC/TD Spreadsheet", "", "[CLASS:ThunderRT6TextBox; INSTANCE:2]"); Target Creation Date textbox
ControlSend("QC/TD Spreadsheet", "", "[CLASS:ThunderRT6TextBox; INSTANCE:2]", "01/01/1970"); Enter Date
ControlClick("QC/TD Spreadsheet", "", "[CLASS:ThunderRT6TextBox; INSTANCE:5]"); Target the Description textarea
ControlSend("QC/TD Spreadsheet", "", "[CLASS:ThunderRT6TextBox; INSTANCE:5]", "A Description"); Enter Description

; Following code will be used to change the displayed tab textarea box, all 3 tabs are currently the same CLASS/INSTANCE so
; solution will be needed to specifically identify selection of the CLASS/INSTANCE without accidentally selecting an
; unexpected tab. Possibilities could be mouse position or tab then right button. Best solution would be for TEXT to be
; added to the screen for each individual tab.

; Section of code commented until solution found!

;Send("{RIGHT}"); Change tab of textarea
;ControlSend("QC/TD Spreadsheet", "", "[CLASS:ThunderRT6TextBox; INSTANCE:4]", "A Test Objective"); Enter Test Objective
;Send("{RIGHT}"); Change tab of textarea
;ControlSend("QC/TD Spreadsheet", "", "[CLASS:ThunderRT6TextBox; INSTANCE:1]", "A Comment")

ControlClick("QC/TD Spreadsheet", "", "[TEXT:Show Technical Description]"); Activate the Show Technical Description radio button

; If statements to determine if Checkboxes are activated, if activated then deactivate
If(ControlCommand("QC/TD Spreadsheet", "", "[TEXT:Create line for Actual Results]", "IsChecked", ""))Then(ControlClick("QC/TD Spreadsheet", "", "[TEXT:Create line for Actual Results]")EndIf
If(ControlCommand("QC/TD Spreadsheet", "", "[TEXT:Show Context Once]", "IsChecked", ""))Then(ControlClick("QC/TD Spreadsheet", "", "[TEXT:Show Context Once]")EndIf
If(ControlCommand("QC/TD Spreadsheet", "", "[TEXT:Show Effects in Description]", "IsChecked", ""))Then(ControlClick("QC/TD Spreadsheet", "", "[TEXT:Show Effects in Description]")EndIf
If(ControlCommand("QC/TD Spreadsheet", "", "[TEXT:Show Trace Points]", "IsChecked", ""))Then(ControlClick("QC/TD Spreadsheet", "", "[TEXT:Show Trace Points]")EndIf

; Trigger Export button and Save
; Assumption - If this script has previously been run then the .csv file should be deleted before attempting to run this script again
ControlClick("QC/TD Spreadsheet", "", "[TEXT:Export]")
WinWaitActive("Export TD Spreadsheet")
ControlClick("Export TD Spreadsheet", "", "[TEXT:&Save]")

; Run the report comparison tool - Code may be added or included to this script
Link to comment
Share on other sites

  • Developers

Am I a little confusing about the help that I need? Are there any questions for me that could help clarify what I am trying to do here?

Thanks

How do you think we would be able to help you assuming we cannot see what you are seeing and test it ourselves?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Unfortunately you are right, I cannot provide the application I am trying to use the script on and maybe that means I won't be able to get any assistance. I guess I am looking for a generic "try something like this xyz"

I am able to target the text field successfully, so the starting point for me is to be able to evaluate that field for an existing value and then once I know if there is a value or not then I can continue on.

Link to comment
Share on other sites

As we can not see it, perhaps breaking it down... your first line under "problem code" is to click in the field you need (I presume). Is it doing that? Then you ask it to send text that is a subject is it doing that?

Link to comment
Share on other sites

@Stampy -

Yes the first thing is to click in the field. It does this fine. The second step is to enter the value, which it also does fine.

This particular screen is one of the many reports available in the application that can be run for a model (a model is like a flow chart that can be generated and then creates several variations from the flow chart that would be similar to pseudo code). One of the possible report formats is called TD Spreadsheet and will produce a .csv file. When you select the TD Spreadsheet report then a new window appears (titled QC/TD Spreadsheet).

If this is the first time you have ever run this report, for the model you are working with then all fields default to a blank value. In this scenario then the script is working perfectly as expected.

My problem is if you have ever opened the TD Spreadsheet report before then it retains previously entered values. If you previously left the field blank then it will still be blank as this would not cause an error (no required fields) and if you entered a value then it would display that value as the default. I cannot assume that the value is blank or contains a static value so I need to examine the field when the QC/TD Spreadsheet screen is displayed and if it is blank then enter the value but if it contains a value then remove the value and enter a new value.

Does that help at all?

EDIT: Let me pseudo code what I am trying to do -

Set focus to Subject textbox

If Subject textbox = ""

Then Enter "A Subject" in Subject textbox

Else

Delete all characters from Subject textbox

Enter "A New Subject" in Subject textbox

End If

Edited by MakinBaconNeked
Link to comment
Share on other sites

I understand. Perhaps a ControlCommand with the getSelected will work. It's hard to know as I don't know what kind of control it is. You mentioned a Ctrl-A won't work how about a shift-end and delete? Just trying to think outside the box and make it work.

Link to comment
Share on other sites

:blink:

Shift+End does work for selecting the entire string. So am I understanding your thought here that once I set focus to the field then then I would send Shift End and then I can use getSelected to evaluate if the string has a value or if it is null? I know that this was not how I originally thought it through but now I am thinking about the possibility of the future where maybe I would only want to delete or enter a new value if it didn't equal a certain value. (such as if it is not equal to "" and also not equal to "A Subject" then do something)

In the mean time I will move forward with your suggestion.

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...