SetControlText not working issue

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
DingDong
Newbie
Posts: 15
Joined: Tue May 11, 2010 11:28 am
Location: Canada

SetControlText not working issue

Post by DingDong » Fri May 21, 2010 12:10 pm

Hello,

With the following code I am able to identify a and move to a ThunderRT6TextBox. But when I use the SetControlText with a value from an Excel spreadsheet, that command does not work.
I have tried with a simple string an that does'nt work.
I have use the the View System Windows to confirm the instance of the ClassName.
Could someone tell me what am I missing.
Thank you!

Code: Select all

////Démarrer Trad T-20////
Let>RP_WAIT=2
Run Program>C:\Desjardins\Suvriq\Suvriq.exe /SUVRIQ /REP:100 /PROD:T20HARMTRAD
WaitReady>1
Wait>5
////////////Attendre l'ouverture de Traditionnel en Fr ou An
Let>WIN_USEHANDLE=0
WaitWindowOpen>Tradition*
SetFocus>Tradition*
////
GetWindowHandle>Traditionnel - version*,tfHandle
////
////Excel
//
Let>path=C:\Desjardins\ABF_au_décès\ABF_Décès.xls
DDERequest>Excel,%path%:Info,L3C8,Prénom_Client,1
StringReplace>Prénom_Client,CRLF,,Prénom_Client
//
DDERequest>Excel,%path%:Info,L4C8,Nom_Client,1
StringReplace>Nom_Client,CRLF,,Nom_Client
//
DDERequest>Excel,%path%:Info,L3C6,Sexe_Client,1
StringReplace>Sexe_Client,CRLF,,Sexe_Client
//
DDERequest>Excel,%path%:Info,L5C3,Statut_Client,1
StringReplace>Statut_Client,CRLF,,Statut_Client
//
DDERequest>Excel,%path%:Info,L1C13,Age_Client,1
StringReplace>Age_Client,CRLF,,Age_Client
//
//--------------------->
//
DDERequest>Excel,%path%:Fusion,L8C7,Montant_Client,1
StringReplace>Montant_Client,CRLF,,Montant_Client
//
DDERequest>Excel,%path%:Fusion,L9C7,Montant_Conj,1
StringReplace>Montant_Conj,CRLF,,Montant_Conj
//--------------------->
//
DDERequest>Excel,%path%:Fusion,L4C11,Montant_ConjDeuxDeces,1
StringReplace>Montant_ConjDeuxDeces,CRLF,,Montant_ConjDeuxDeces
//
DDERequest>Excel,%path%:Info,L8C9,Nb_Client,1
StringReplace>Nb_Client,CRLF,,Nb_Client
//
DDERequest>Excel,%path%:Info,L6C8,Prénom_Conj,1
StringReplace>Prénom_Conj,CRLF,,Prénom_Conj
//
DDERequest>Excel,%path%:Info,L7C8,Nom_Conj,1
StringReplace>Nom_Conj,CRLF,,Nom_Conj
//
DDERequest>Excel,%path%:Info,L6C6,Sexe_Conj,1
StringReplace>Sexe_Conj,CRLF,,Sexe_Conj
//
DDERequest>Excel,%path%:Info,L8C3,Statut_Conj,1
StringReplace>Statut_Conj,CRLF,,Statut_Conj
//
DDERequest>Excel,%path%:Info,L2C21,DDN_Cient_An,1
StringReplace>DDN_Cient_An,CRLF,,DDN_Cient_An
//
DDERequest>Excel,%path%:Info,L3C21,DDN_Cient_Mois,1
StringReplace>DDN_Cient_Mois,CRLF,,DDN_Cient_Mois
//
DDERequest>Excel,%path%:Info,L4C21,DDN_Cient_Jour,1
StringReplace>DDN_Cient_Jour,CRLF,,DDN_Cient_Jour
//
DDERequest>Excel,%path%:Info,L2C22,DDN_Conj_An,1
StringReplace>DDN_Conj_An,CRLF,,DDN_Conj_An
//
DDERequest>Excel,%path%:Info,L3C22,DDN_Conj_Mois,1
StringReplace>DDN_Conj_Mois,CRLF,,DDN_Conj_Mois
//
DDERequest>Excel,%path%:Info,L4C22,DDN_Conj_Jour,1
StringReplace>DDN_Conj_Jour,CRLF,,DDN_Conj_Jour
//
DDERequest>Excel,%path%:Info,L10C131,Prov,1
StringReplace>Prov,CRLF,,Prov
////
////Importer les données du preneur
//Accéder au bouton DDN et insérer la DDN
//
Wait>.3
LibFunc>User32,FindWindowExA,1_hwnd1,tfHandle,0,ThunderRT6Frame,
LibFunc>User32,FindWindowExA,2_hwnd1,tfHandle,1_hwnd1,ThunderRT6Frame,
LibFunc>User32,FindWindowExA,3_hwnd1,tfHandle,2_hwnd1,ThunderRT6Frame,Frame1
LibFunc>User32,FindWindowExA,4_hwnd1,tfHandle,3_hwnd1,ThunderRT6Frame,Clients
LibFunc>User32,FindWindowExA,5_hwnd1,tfHandle,4_hwnd1,ThunderRT6Frame,
LibFunc>User32,FindWindowExA,btnDDN,5_hwnd1,0,ThunderRT6CommandButton,DDN
LibFunc>User32,FindWindowExA,txtBox_1,5_hwnd1,0,ThunderRT6TextBox,
Let>WIN_USEHANDLE=1
GetWindowPos>txtBox_1,npX3,npY3
MessageModal>%npX3% et %npY3%
MouseMove>npX3,npY3
Wait>.3
SetControlText>txtBox_1,ThunderRT6TextBox,15,%Nom_Client%

User avatar
Marcus Tettmar
Site Admin
Posts: 7391
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri May 21, 2010 12:18 pm

Hi,

You won't be able to use SetControlText to set a value inside a spreadsheet.

Instead you should use XLSetCell if you're using v12, otherwise you can use DDEPoke or the vbscript methods which you can find in sample scripts and about this forum.

The caption text that Set/GetControlText refers to is not always the text you want. The spreadsheet control does not "publish" the data contents and it's "caption text" is probably nothing useful, if it exists at all. It refers to what Microsoft call the "title text", on a button this is the caption text, on a window the title bar text, but on many other controls it is empty/meaningless/invisible/useless/not-the-data-inside-it

Or perhaps you are referring to some other control inside Excel.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

DingDong
Newbie
Posts: 15
Joined: Tue May 11, 2010 11:28 am
Location: Canada

Post by DingDong » Fri May 21, 2010 12:45 pm

Thank you mtettmar for your quick reply.

What I want is to set set a value in the window control not to set a value in a spreadsheet cell.

By reading a thread on this forum about the SetControlText command to accelerate the automation of a gui instead of of sending keypress it gave me the idea to use it.

The script I wrote open the program and goes from one control to the other one and enter the data retreive from the excel cells. That works fine. But instead of looking the mouse moving from one control to the other one I figured it would be cleaner to look at a window populate with data.

Could tha be accomplish with the SetControlText?

Again, thank you for the help.

User avatar
Marcus Tettmar
Site Admin
Posts: 7391
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri May 21, 2010 12:55 pm

It will depend on the control. Sounds like you've already discovered it isn't.

Every control, every app, every programmer, every technology is different. That's why Macro Scheduler is a toolbox which offers more than one way to skin a cat, because, er, not every app can be skinned the same way.

But if you want me to have a look I need to know what version of Excel you are using and what control you are trying to set. I can help if you're using Excel 2007. A screenshot would help.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

DingDong
Newbie
Posts: 15
Joined: Tue May 11, 2010 11:28 am
Location: Canada

Post by DingDong » Fri May 21, 2010 1:34 pm

Thank you mtettmar for your reply.

The Excel version is 2003.

Here's a view of the textbox control (wich is ThunderRT6TextBox in the Viiew System Windows tool utility) where we see the label Nom.

Image

thank you!

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Post by gdyvig » Fri May 21, 2010 3:46 pm

Every control, every app, every programmer, every technology is different.
Windows Standard :)


Gale

DingDong
Newbie
Posts: 15
Joined: Tue May 11, 2010 11:28 am
Location: Canada

Post by DingDong » Fri May 21, 2010 3:56 pm

Hello,

I edit the script with the following:

Code: Select all

////Démarrer Trad T-20////
Let>RP_WAIT=2
Run Program>C:\Desjardins\Suvriq\Suvriq.exe /SUVRIQ /REP:100 /PROD:T20HARMTRAD
WaitReady>1
Wait>5
////////////Attendre l'ouverture de Traditionnel en Fr ou An
Let>WIN_USEHANDLE=0
WaitWindowOpen>Tradition*
SetFocus>Tradition*
////
GetWindowHandle>Traditionnel - version*,tfHandle
////
////Excel
//
Let>path=C:\Desjardins\ABF_au_décès\ABF_Décès.xls
DDERequest>Excel,%path%:Info,L3C8,Prénom_Client,1
StringReplace>Prénom_Client,CRLF,,Prénom_Client
//
DDERequest>Excel,%path%:Info,L4C8,Nom_Client,1
StringReplace>Nom_Client,CRLF,,Nom_Client
//
DDERequest>Excel,%path%:Info,L3C6,Sexe_Client,1
StringReplace>Sexe_Client,CRLF,,Sexe_Client
//
DDERequest>Excel,%path%:Info,L5C3,Statut_Client,1
StringReplace>Statut_Client,CRLF,,Statut_Client
//
DDERequest>Excel,%path%:Info,L1C13,Age_Client,1
StringReplace>Age_Client,CRLF,,Age_Client
//
//--------------------->
//
DDERequest>Excel,%path%:Fusion,L8C7,Montant_Client,1
StringReplace>Montant_Client,CRLF,,Montant_Client
//
DDERequest>Excel,%path%:Fusion,L9C7,Montant_Conj,1
StringReplace>Montant_Conj,CRLF,,Montant_Conj
//--------------------->
//
DDERequest>Excel,%path%:Fusion,L4C11,Montant_ConjDeuxDeces,1
StringReplace>Montant_ConjDeuxDeces,CRLF,,Montant_ConjDeuxDeces
//
DDERequest>Excel,%path%:Info,L8C9,Nb_Client,1
StringReplace>Nb_Client,CRLF,,Nb_Client
//
DDERequest>Excel,%path%:Info,L6C8,Prénom_Conj,1
StringReplace>Prénom_Conj,CRLF,,Prénom_Conj
//
DDERequest>Excel,%path%:Info,L7C8,Nom_Conj,1
StringReplace>Nom_Conj,CRLF,,Nom_Conj
//
DDERequest>Excel,%path%:Info,L6C6,Sexe_Conj,1
StringReplace>Sexe_Conj,CRLF,,Sexe_Conj
//
DDERequest>Excel,%path%:Info,L8C3,Statut_Conj,1
StringReplace>Statut_Conj,CRLF,,Statut_Conj
//
DDERequest>Excel,%path%:Info,L2C21,DDN_Cient_An,1
StringReplace>DDN_Cient_An,CRLF,,DDN_Cient_An
//
DDERequest>Excel,%path%:Info,L3C21,DDN_Cient_Mois,1
StringReplace>DDN_Cient_Mois,CRLF,,DDN_Cient_Mois
//
DDERequest>Excel,%path%:Info,L4C21,DDN_Cient_Jour,1
StringReplace>DDN_Cient_Jour,CRLF,,DDN_Cient_Jour
//
DDERequest>Excel,%path%:Info,L2C22,DDN_Conj_An,1
StringReplace>DDN_Conj_An,CRLF,,DDN_Conj_An
//
DDERequest>Excel,%path%:Info,L3C22,DDN_Conj_Mois,1
StringReplace>DDN_Conj_Mois,CRLF,,DDN_Conj_Mois
//
DDERequest>Excel,%path%:Info,L4C22,DDN_Conj_Jour,1
StringReplace>DDN_Conj_Jour,CRLF,,DDN_Conj_Jour
//
DDERequest>Excel,%path%:Info,L10C131,Prov,1
StringReplace>Prov,CRLF,,Prov
////
////Importer les données du preneur
//Accéder au bouton DDN et insérer la DDN
//
Wait>.3
LibFunc>User32,FindWindowExA,1_hwnd1,tfHandle,0,ThunderRT6Frame,
LibFunc>User32,FindWindowExA,2_hwnd1,tfHandle,1_hwnd1,ThunderRT6Frame,
LibFunc>User32,FindWindowExA,3_hwnd1,tfHandle,2_hwnd1,ThunderRT6Frame,Frame1
LibFunc>User32,FindWindowExA,4_hwnd1,tfHandle,3_hwnd1,ThunderRT6Frame,Clients
LibFunc>User32,FindWindowExA,5_hwnd1,tfHandle,4_hwnd1,ThunderRT6Frame,
LibFunc>User32,FindWindowExA,btnDDN,5_hwnd1,0,ThunderRT6CommandButton,DDN
LibFunc>User32,FindWindowExA,txtBox_1,5_hwnd1,0,ThunderRT6TextBox,
Let>WIN_USEHANDLE=1
GetWindowPos>txtBox_1,npX3,npY3
MouseMove>npX3,npY3
Wait>.3
Add>npX3,15
Add>npY3,10
MouseMove>npX3,npY3
Wait>.3
LClick
Send>%Nom_Client%
Wait>.1
MessageModal>%Nom_Client%
GetControlText>txtBox_1,ThunderRT6TextBox,15,txtBoxText
MessageModal>%txtBoxText%
The excel cell value is inserted in the textbox but when I retrived the textbox text value with the GetControlText, the last messagemodal will show the NOSUCHWINDOW message content but this object exist and I can pinpoint it.

DingDong
Newbie
Posts: 15
Joined: Tue May 11, 2010 11:28 am
Location: Canada

Post by DingDong » Fri May 21, 2010 4:24 pm

Hello,

I finally manage it.

The help file says:

Code: Select all

If WIN_USEHANDLE is set to 1 WindowTitle must be a window handle.
I followed it and it did not worked.

I edit the script with the following:

Code: Select all

Let>WIN_USEHANDLE=0
SetControlText>Tradition*,ThunderRT6TextBox,15,%Nom_Client%
and the SetControlText worked.

Is that normal or not?

Thank you all for your help.

DingDong
Newbie
Posts: 15
Joined: Tue May 11, 2010 11:28 am
Location: Canada

Post by DingDong » Fri May 21, 2010 4:29 pm

Sorry but the help is OK. I repeat the help file is OK.
My mistake. I was not using the proper handle. By using it:

Code: Select all

Let>WIN_USEHANDLE=1
SetControlText>tfHandle,ThunderRT6TextBox,15,%Nom_Client%
Everything worked as the helpfile says it.

There is always something to learn.

DingDong

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts