Sign in to follow this  
Followers 0
olo

Control Wont get text :P

9 posts in this topic

Hey folks,

Im trying to use a controlgettext function on a TrichEdit form. Now I get text except I get everything in the visible text tab as displayed in the info tool and not the specific words I want, "C:ACRAkProgramkc.exe"

.

 

$olo = ControlGetText( "[CLASS:" & $MsgSvrclass & "]", "C:\ACRA\kProgram\kc.exe", "[CLASS:TRichEdit; INSTANCE:1]" )
        ACRAOutputWarning($olo)

Share this post


Link to post
Share on other sites



You misunderstand what the text parameter is used for. It's looking for that text to match the window, it's not getting the text from it. What would be the point getting text you already have?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

You misunderstand what the text parameter is used for. It's looking for that text to match the window, it's not getting the text from it. What would be the point getting text you already have?

oh ok I thought it would retrieve the text for me? What other function would be able to do that or is there another alternative?

Share this post


Link to post
Share on other sites

Are you able to get the text from the control? If you can, then all you have to do is figure out what part of the text you need, what part you don't, and figure out what would make them different. You'd probably need a RegEx to find what you're looking for, or even something as simple as a stringinstr or _stringbetween.

Because I don't know what it is you're trying to accomplish, what it looks like when you get the text, or what you want to get from that text, there's not much I can offer besides telling you to show us an example of the text in the control, and what you're looking for out of it.

1 person likes this

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Are you able to get the text from the control? If you can, then all you have to do is figure out what part of the text you need, what part you don't, and figure out what would make them different. You'd probably need a RegEx to find what you're looking for, or even something as simple as a stringinstr or _stringbetween.

Because I don't know what it is you're trying to accomplish, what it looks like when you get the text, or what you want to get from that text, there's not much I can offer besides telling you to show us an example of the text in the control, and what you're looking for out of it.

 

In the control tab in the window info tool there is nothing in the text field. However if you switch to the visible text tab there are 4 paragraphs with text present. I want a single sentence from one of those paragraphs.

Now with my above code I get returned the full 4 paragraphs and not the single sentence

Share this post


Link to post
Share on other sites

In the control tab in the window info tool there is nothing in the text field. However if you switch to the visible text tab there are 4 paragraphs with text present. I want a single sentence from one of those paragraphs.

Now with my above code I get returned the full 4 paragraphs and not the single sentence

Ok, so you need to extract something from this 4 paragraphs of text. So as I said previously, you need to define what it is you want, what you don't want, and how to differentiate between the 2.

What are you trying to get from this text, and what is the full text that you get?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Here is a snippet of the long text:

Calling command line: "C:ACRAkProgramDb2PCM -v1 -n1 -f0 -dC:ACRADatabase -mC:ACRAkProgramScribe -oC:ACRAkProgramXidBCU101C_DSI002.xid"
Process started successfully
Db2PCM.exe :
Version 1.0.0.1349 (Release ) for Win32 Built on builder2 using cg2k7

Looking for scribe module entries and recording them...
Done.
Found and recorded 373 module entries


C:ACRAkProgramDb2PCM.exe : 0 hint(s), 0 warning(s) and  0 error(s).  <------ I want his line, However the values of hints, warnings and errors may change.

Share this post


Link to post
Share on other sites

Perhaps something like this will get you what you're looking for.
 

#include <array.au3>
Global $String = 'Calling command line: "C:\ACRA\kProgram\Db2PCM -v1 -n1 -f0 -dC:\ACRA\Database -mC:\ACRA\kProgram\Scribe -oC:\ACRA\kProgram\Xid\BCU101C_DSI002.xid' & @CRLF
$String &= 'Process started successfully' & @CRLF
$String &= @crlf & 'Db2PCM.exe :' & @CRLF
$String &= 'Version 1.0.0.1349 (Release ) for Win32 Built on builder2 using cg2k7' & @CRLF

$String &= 'Looking for scribe module entries and recording them...' & @CRLF
$String &= 'Done.' & @CRLF
$String &= 'Found and recorded 373 module entries' & @CRLF & @CRLF


$String &= 'C:\ACRA\kProgram\Db2PCM.exe : 0 hint(s), 10 warning(s) and  0 error(s).'& @CRLF
$array = StringRegExp($String, "C:\\ACRA\\kProgram\\Db2PCM.exe : \d+ hint\(s\), \d+ warning\(s\) and .+\d+ error\(s\)", 2)
_ArrayDisplay($array)

I'm sure one of the RegEx gurus will be able to make that more universal, but it is a starting point. You might notice you can change the number in the string (hints, warnings, errors) and it should still pick it up.

1 person likes this

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Thanks mate Ill give that a go

Share this post


Link to post
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
Sign in to follow this  
Followers 0