lastlight Posted March 1, 2010 Share Posted March 1, 2010 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! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 1, 2010 Moderators Share Posted March 1, 2010 lastlight,Welcome to the AutoIt forum. You may well have to a bit more than just TAB through the boxes if that is what you want to do. 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. M23P.S. All the above assumes that it is a standard Windows App that you are automating - is that correct? 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: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
vojnet Posted May 22, 2011 Share Posted May 22, 2011 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. Link to comment Share on other sites More sharing options...
JohnOne Posted May 22, 2011 Share Posted May 22, 2011 (edited) Control ID's usually are different, which is why... 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 May 22, 2011 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Qvintus Posted May 22, 2011 Share Posted May 22, 2011 StringInStr(WhereToSearch, WhatToSearchFor) Link to comment Share on other sites More sharing options...
JohnOne Posted May 22, 2011 Share Posted May 22, 2011 StringInStr(WhereToSearch, WhatToSearchFor) That's fine, once the OP can read a string but the problem is getting the text from a GUI control at this point. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
vojnet Posted May 23, 2011 Share Posted May 23, 2011 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. Link to comment Share on other sites More sharing options...
somdcomputerguy Posted May 23, 2011 Share Posted May 23, 2011 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. Link to comment Share on other sites More sharing options...
vojnet Posted May 23, 2011 Share Posted May 23, 2011 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. Link to comment Share on other sites More sharing options...
somdcomputerguy Posted May 23, 2011 Share Posted May 23, 2011 You bet. Good luck with your project. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
amirmahallati Posted February 17, 2015 Share Posted February 17, 2015 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 Link to comment Share on other sites More sharing options...
JohnOne Posted February 17, 2015 Share Posted February 17, 2015 Post code. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
amirmahallati Posted February 17, 2015 Share Posted February 17, 2015 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 --- Link to comment Share on other sites More sharing options...
JohnOne Posted February 17, 2015 Share Posted February 17, 2015 ControlGetText("pdf". "Cover Sheet". "[CLASS:AVL_AVView; INSTANCE:17]") You have "." where you should have "," AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
amirmahallati Posted February 17, 2015 Share Posted February 17, 2015 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") Link to comment Share on other sites More sharing options...
JohnOne Posted February 17, 2015 Share Posted February 17, 2015 (edited) I don't you believe can access a PDF like a standard win32 control, you should search for a pdf UDF. Edited February 17, 2015 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
shreya Posted October 21, 2019 Share Posted October 21, 2019 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? Link to comment Share on other sites More sharing options...
Developers Jos Posted October 21, 2019 Developers Share Posted October 21, 2019 @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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now