capitanves Posted May 29, 2015 Share Posted May 29, 2015 Hi, I am a newbie.My task is to read the display value in calc.exe. I use AutoItInfo for getting oriented. What I see is:1-The display value is contained under the tab "Visible Text"2- The display control has the property text= nothing3-The CalcFrame window has the property text =nothing The main question is:1- How can I get the text from calc display? Why Can't I get the "visible text" from of the windows? Here the code I usedThank you guys for the support :-)#include <Constants.au3> Local $strCalcClass = "[CLASS:CalcFrame]" Run('calc.exe') ; Wait for the calculator to become active. The classname "CalcFrame" is monitored instead of the window title $hCalcWnd = WinWaitActive("[CLASS:CalcFrame]") ; Now that the calculator window is active type the values 2 x 4 x 8 x 16 ; Use AutoItSetOption to slow down the typing speed so we can see it AutoItSetOption("SendKeyDelay", 10) Send("2*4*8*16=") Sleep(200) WinWait("[CLASS:CalcFrame]") ConsoleWrite('Ciccio franco va in vacanza'& @CRLF) ; this "works" in the sense that, in spite of what I see, AutoInfo says that there is ; no text in the contro Local $myText = ControlGetText($hCalcWnd, "", "[CLASS:#32770; INSTANCE:1]") ; this works nicely Local $strButton = ControlGetText($hCalcWnd,'', '[CLASS:Button; INSTANCE:29]') ; does not work Local $strWinText = WinGetText('ACTIVE') ConsoleWrite('====> mhCalcWnd=' & $hCalcWnd& @CRLF) ConsoleWrite('====> Control Text=' & $myText& @CRLF) ConsoleWrite('====> Window Text=' & $strWinText & @CRLF) ConsoleWrite('====> Button Text=' & $strButton & @CRLF) Link to comment Share on other sites More sharing options...
czardas Posted May 29, 2015 Share Posted May 29, 2015 (edited) I'm not sure of the reason, but some custom controls can be tricky. This is a work around which seems to work with calc.exe but the method used is unlikely to work with other programs in similar situations (not so often at least without modification). #include <Constants.au3> #include <StringConstants.au3> Local $strCalcClass = "[CLASS:CalcFrame]" Run('calc.exe') ; Wait for the calculator to become active. The classname "CalcFrame" is monitored instead of the window title Local $hCalcWnd = WinWaitActive($strCalcClass) ; Use AutoItSetOption to slow down the typing speed so we can see it AutoItSetOption("SendKeyDelay", 10) ; Now that the calculator window is active type the values 2 x 4 x 8 x 16 Send("2*4*8*16=") Sleep(200) Local $myText = StringStripWS(WinGetText($strCalcClass, ""), BitOR($STR_STRIPLEADING, $STR_STRIPTRAILING)) ConsoleWrite('====> mhCalcWnd=' & $hCalcWnd& @CRLF) ConsoleWrite('====> Control Text=' & $myText& @CRLF)I imagine someone will post a better solution. There ought to be one and I would like to know what it is myself. In any case you are unlikely to need calc.exe since there are a variety maths functions available in AutoIt which will suffice in most situations.Edit : The forum highlighting has gone nuts. Edited May 29, 2015 by czardas operator64 ArrayWorkshop 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