Jump to content

Recommended Posts

Posted

Hello all,

I'm a newbie to AutoIt, and I'm trying to detect whether I currently have text in a field?

It's an automation program that is tabbing through boxes, entering text if it does not already exist.

TIA!

  • Moderators
Posted

lastlight,

Welcome to the AutoIt forum. :mellow:

You may well have to a bit more than just TAB through the boxes if that is what you want to do. :lol: The command to do what you want is ControlGetText, but you need to define the control to read.

Have you used the Au3 Window Info Tool yet? You should find it at "C:\Program Files\AutoIt3\Au3Info.exe" if you have a standard install. It should enable you to get enough information on the boxes you are trying to fill to correctly identify them - and so allow you to read the contents. Look for the CLASS and INSTANCE details on the Control tab whan you are over the various boxes.

Give it a try and come back if you have problems. :(

M23

P.S. All the above assumes that it is a standard Windows App that you are automating - is that correct?

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

  • 1 year later...
Posted

This is exactly what I need - but all control ID's or other parameters seem to be changing dynamically. Every time the application is started, the Control IDs are different. How can I code for this? Is there a function to first get the ControlID and than pass it to the next function? I would be nice if there was something like ' IF current_control.visible_text="bla, bla" then ...else...'

Thanks a lot for any tips.

Posted (edited)

Control ID's usually are different, which is why...

  On 3/1/2010 at 4:56 PM, 'Melba23 said:

Look for the CLASS and INSTANCE details on the Control tab whan you are over the various boxes.

For example, if you were checking the edit control of notepad, in the id param you could put "[CLASS:Edit; INSTANCE:1]" (literally and with quotes) Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Posted

So, I should use a variable to store the value from the Control (using Class and Instance)and then use the StringInStr to check if it matches what I am looking for? Can you use variables for the string/substring parts of StringInStr? Like: StringInStr ( "$abc", "$efg")?. I could then use InputBox to enter the values.

Thanks much for everyones help.

Posted

Yes, you can use variables as parameters for StringInStr. For example, I have a line of code like this in one of my scripts: If StringInStr($Source, GUICtrlRead($Input_Text)) = 0 Then.

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Posted

  On 5/23/2011 at 1:35 PM, 'somdcomputerguy said:

Yes, you can use variables as parameters for StringInStr. For example, I have a line of code like this in one of my scripts: If StringInStr($Source, GUICtrlRead($Input_Text)) = 0 Then.

Thanks. This may be exactly what I need.

  • 3 years later...
Posted

Hi,

ControlGetText is very inflexible for me.  I am not able to verify the existence of whatever text that I want.  It just gets a specific text and none other.  Is this true, or am I not using it right?

Thanks

Posted

When I run the code below I get the error that I have attached.  This code is meant to click on the "Open with..." radio button in the screen that pops up in FireFox when trying to open a file, click on the "OK" button to open the PDF file, then verify the existence of the text "Cover Sheet" in the PDF file.

#region --- Au3Recorder generated code Start (v3.3.9.5 KeyboardLayout=00000409)  ---

#region --- Internal functions Au3Recorder Start ---
Func _Au3RecordSetup()
Opt('WinWaitDelay',100)
Opt('WinDetectHiddenText',1)
Opt('MouseCoordMode',0)
Local $aResult = DllCall('User32.dll', 'int', 'GetKeyboardLayoutNameW', 'wstr', '')
If $aResult[1] <> '00000409' Then
  MsgBox(64, 'Warning', 'Recording has been done under a different Keyboard layout' & @CRLF & '(00000409->' & $aResult[1] & ')')
EndIf

EndFunc

Func _WinWaitActivate($title,$text,$timeout=0)
    WinWait($title,$text,$timeout)
    If Not WinActive($title,$text) Then WinActivate($title,$text)
    WinWaitActive($title,$text,$timeout)
EndFunc

_AU3RecordSetup()
#endregion --- Internal functions Au3Recorder End ---

_WinWaitActivate("Opening","")
MouseClick("left",46,176,1)
MouseClick("left",287,297,1)
Opt("WinTitleMatchMode", 2)
ControlGetText("pdf". "Cover Sheet". "[CLASS:AVL_AVView; INSTANCE:17]")
#endregion --- Au3Recorder generated code End ---

post-87121-0-72255600-1424202430_thumb.p

Posted

Thanks, I don't get that error anymore, but how do I verify that the text "Cover Sheet" exists in the PDF file.  I tried to do what you see in the code below, but no indication appears as to whether it passed. I don't get an error either if I try to compare $text with a text that doesn't exist in the PDF.

Local $text = ControlGetText("pdf", "Cover Sheet", "[CLASS:AVL_AVView; INSTANCE:17]")
StringInStr($text, "Cover Sheet")
  • 4 years later...
Posted

i have got multiple line of text using wingettext()  for getting the text but i want to validate if few lines are present in that text how do i do it i m stuck please someone help?

  • Developers
Posted

@shreya,

I realize you just posted in a 9 years old thread which is totally unrelated to your question?
Anyways: Post your current script and show some more detailed information about the information you (want to) retrieve and what isn't working.

Jos

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

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
  • Recently Browsing   0 members

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