Jump to content

Test calculator app in Win10


Kanako
 Share

Recommended Posts

please help me, i try to get the result from calculator but it's not working, it's not some kind of error, just only didn't show the result from app 

i think my problem with the code  $result = ControlGetText("Calculator","","Static5") 

below is my whole code:

#include<File.au3> 
$fileInput = FileOpen("D:\input.txt",0)
$fileOutput = FileOpen("D:\output.txt",1)

Run("calc.exe") ;chay app calc
WinActivate("Calculator") 
Sleep(500)

for $i=1 to _FileCountLines($fileInput) 
    $line= FileReadLine($fileInput,$i)
    AutoItSetOption("SendKeyDelay",200)

    Send(StringMid($line, 1,1)) 

    $operate=StringMid($line, 2,1) 

    ;Autoit ko hieu dau + nen phai convert (+)
    if(StringCompare($operate,"+",0)) Then
         Send(StringMid($line, 2,1))

    Else
         Send("{+}")
    EndIf

    Send(StringMid($line, 3,1))
    Send("=") ;truyen dau =
    Sleep(1000)
    $actualResult = StringSplit($line,"=") 

    $result = ControlGetText("Calculator","","Static5")

    $out= StringTrimRight($result,1)

    
    If (StringCompare($actualResult[2],$out)) < 1 Then
       ;FileWriteLine($fileOutput)
       FileWriteLine($fileOutput,"Expected Result "&$actualResult[2]&"| Actual Result "&out&"| Pass")
    Else
       ;FileWriteLine($fileOutput)
       FileWriteLine($fileOutput,"Expected Result "&$actualResult[2]&"| Actual Result "&$out&"| Fail")
    EndIf
    Send("{DEL}") 
 Next
 WinClose("Calculator")
 

3.png

4.png

Link to comment
Share on other sites

 

$result = ControlGetText("Calculator","","Static4")

#include<File.au3>
#RequireAdmin
$fileInput = FileOpen("D:\input.txt",0)
$fileOutput = FileOpen("D:\output.txt",1)
Run("calc.exe") ;chay app calc
WinActivate("Calculator")
Sleep(500)
for $i=1 to _FileCountLines($fileInput)
    $line= FileReadLine($fileInput,$i)
    AutoItSetOption("SendKeyDelay",200)

    Send(StringMid($line, 1,1))

    $operate=StringMid($line, 2,1)

    ;Autoit ko hieu dau + nen phai convert (+)
    if(StringCompare($operate,"+",0)) Then
         Send(StringMid($line, 2,1))

    Else
         Send("{+}")
    EndIf

    Send(StringMid($line, 3,1))
    Send("=") ;truyen dau =
    Sleep(1000)
    $actualResult = StringSplit($line,"=")

    $result = ControlGetText("Calculator","","Static4")
    $out= StringTrimRight($result,1)

    If StringCompare($actualResult[1],$out) < 1 Then
       ;FileWriteLine($fileOutput)
    ;   MsgBox(0,"",$actualResult[2])
       FileWriteLine($fileOutput,"Expected Result "&$actualResult[2]&"| Actual Result "&$out&"| Pass")
    Else
       ;FileWriteLine($fileOutput)
    ;     MsgBox(0,"",$actualResult[2])
       FileWriteLine($fileOutput,"Expected Result "&$actualResult[2]&"| Actual Result "&$out&"| Fail")
    EndIf
    Send("{DEL}")
 Next
 WinClose("Calculator")

 

Edited by ad777

iam ِAutoit programmer.

best thing in life is to use your Brain to

Achieve

everything you want.

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