Jump to content

Writing down a variable as string from ControlGetText


Recommended Posts

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!

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

&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
Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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!

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Glad I could at least help with this problem :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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