Sign in to follow this  
Followers 0
SorryButImaNewbie

Writing down a variable as string from ControlGetText

17 posts in this topic

Hello

I'm trying to write down a variable ($VJszam) to a MsgBox for testing to see if the GetText has saved it correctly.

Later I want to use it to be written in to a textbox.

 
Global $VJszam = ControlGetText($handle2, "", "[CLASSNN:TDEdit4]")
MsgBox(0,"Test","$VJszam is:" & $VJszam)
 

 

The MsgBox shows only:  $VJszam:

For a time i thought that i cant write it to the textbox (this could still be a problem), but I can't seems to pop it up to a MsgBox correctly neither so I assume that i made a mistake with ControlGetText.

I use Global because I may need to use this number in some other function and i thought it would be good to be able to just simply call it from here, I got the same results with Local

Also the variable $VJszam is a number with 11 digit, like 10234567893

BTW I tried to write it in to the TextBox with ControlSetText/ControlSend/Send. None of them worked (They didn't really had a chance since It seems to me that the $VJszam isn't saved properly) but just so I don't end up posting a 2. question. This is how i tried to write it to the textbox, I'm pretty sure that there is some other way to write down variables as strings, like String($VJszam), but since I can't seem to save it I'm not sure if my code would run correctly if i had the variable saved properly.

ControlSetText($handle, "", "[CLASSNN:TEdit1]",$VJszam)

 

Thank you for your help!

Share this post


Link to post
Share on other sites



According to the help file ControlGetText sets @error if something went wrong. So what is the value of @error?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

When I run the code, I don't get any error, It just doesn't seems to have the $VJszam, or it is in some format that I can't use in a MsgBox and a TextBox (since then I checked if i can just write a string on the textbox after i set the focus on it or not, I wrote the "test string" down).

When i finish the function (I only run it so I don't have to go through the entire script,only the function wich i have a problem with) I get the "usually good" 

+>11:26:43 AutoIt3.exe ended.rc:0
+>11:26:43 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 11.79
 
lines from autoIT

Share this post


Link to post
Share on other sites

You need to write the value of @error to a MsgBox:

Global $VJszam = ControlGetText($handle2, "", "[CLASSNN:TDEdit4]")
MsgBox(0,"Test","@error: " & @error & @CRLF & "$VJszam is:" & $VJszam)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

&error: 0

That means no error. (VJszam: is still empty) So I don't get it, is my code correct?

Could it be that the control from which i try to read is the problem? I'm thinking about trying to get the text with AU3Recorder, since the program that i try to automatet pop up this window i use at the same place everytime. However the script have to work on different machines, will it be a problem if i use the Recorder? would The coordinates be the same on an other machine with an other monitor with (probably) different resolution? Or I should't try that in my level since it will only get more complicated later, and essentially track me back to this same problem again?

Thanks for the help and for any tips you guys can give! 

Edited by SorryButImStupid

Share this post


Link to post
Share on other sites

Use the "AutoIt Window Info" tool to check if it can see the control.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

It can see it (i used it to get its class), I'm not sure but could that be a problem, that the window is a TMultiDataSheetForm? So now I realize that I dont really read from a textbox, I hope taht helps

Share this post


Link to post
Share on other sites

As far as I know: If the AutoIt Window Info Tool can't see the Control then you can't access it by AutoIt.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

The Window Info Tool can see it.

Share this post


Link to post
Share on other sites

Then please post a screenshot of the Window Info Tool pointing to the Control.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Sorry I needed sometime to figure out how to attach it :)

post-88591-0-01943600-1415621521_thumb.p

post-88591-0-65869500-1415621524_thumb.p

Share this post


Link to post
Share on other sites

Can you please show the code where you fill variable $handle2?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

The handle works with other commands (like controlclick) while the script works on other controls on the window
 
WinWaitActive("Something something")
Local $handle2 = WinGetHandle("Something something")
ControlClick($handle2, "", "[CLASSNN:TAdvBitBtn4]")
Edited by SorryButImStupid

Share this post


Link to post
Share on other sites

Thank you for your help water,

you are not just the quintessence of life on this planet, but also you help those who write a bit of code and thats some nice diversification if you ask me!

I kinda gave up on a "normal" or "professional" solution. Right now i just set the focus on the text box and use 

Send("{CTRLDOWN}c{CTRLUP}")

and 

Send("{CTRLDOWN}v{CTRLUP}")

it on the other control

I know that this isn't an elegant solution but hey, it works.

Do you happen to know if I can save from the clipboard? I would still like to save it as a variable, it would be usefull down the path.

Thank you!

Share this post


Link to post
Share on other sites

Thanks for the kind words! When I started here many years ago I was glad that so many people helped to answer my newbie questions. As I have made progress over the years I can now return what I know.

So access the content of the Clipboard please have a look at function ClipGet.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

I just read the first line of ClipGet, and yup, I think this is what i'll need :) thy again

Edited by SorryButImStupid

Share this post


Link to post
Share on other sites

Glad I could at least help with this problem :)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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