zaraijamel

Make Condition on windows layout change.

4 posts in this topic

#1 ·  Posted (edited)

Hello Guys, 

I am trying to write a script to mass load data into a desktop Application. My application is developed in DotNet. I managed to write the script to do the mass load but when an error occurs there an error frame that's displayed in the down side of the main window. Both screenshots will be attached before the error and after. also i will attach the Windows info output.

My question is how to detect this frame change and get the error message then abort the load when error occurs.

Best regards And thank you in advance.

 

#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>
#include <AutoItConstants.au3>

RunQAD()
MenuSelect()
RunLoad()

Func RunLoad()
    WinWait("test: QAD System Domain [USD] > 999 - SYSADM SYSTEM")
    WinActivate("test: QAD System Domain [USD] > 999 - SYSADM SYSTEM ")


 ;Global $aCA = WinGetClientSize($hErrWnd); Width, height


    Global $aRetArray, $sFilePath = "C:\Users\Jamel\Documents\role.txt"
    _FileReadToArray($sFilePath, $aRetArray, $FRTA_NOCOUNT + $FRTA_ENTIRESPLIT, ";")
    Global $iRows = UBound($aRetArray, $UBOUND_ROWS)
    Global $iCols = UBound($aRetArray, $UBOUND_COLUMNS)

    For $i = 0 To $iRows - 1
        For $j = 0 To $iCols - 1
            $a =$aRetArray[$i][$j]
            Send($a)
            Sleep(800)
            Send("{TAB}")
            Sleep(500)
        Next
        Sleep(800)
        Send("{TAB}")
        ;ConsoleWrite(WinWait('test: QAD System Domain [USD] > 999 - SYSADM SYSTEM','Error Viewer - Role Create Close Detail Processes ultraStatusBar1'))
        Sleep(800)
        Sleep(800)
    Next

EndFunc   ;==> RunLoad

;Input File Read Function
Func InputFileRead()
 Global $aRetArray, $sFilePath = "C:\Users\Jamel\Documents\role.txt"
 _FileReadToArray($sFilePath, $aRetArray, $FRTA_NOCOUNT + $FRTA_ENTIRESPLIT, ";")
; _ArrayDisplay($aRetArray, "Split on full delimiter", Default, 2)

EndFunc   ;==> InputFileRead

;========================================================================================
; Run QAD Function
;========================================================================================
Func RunQAD()
    ;;Run("C:\Program Files (x86)\QAD\QAD EE 2016\QAD.Applications.exe")
    ;;Global $hWnd = WinWait("Login")
    ;;WinActivate($hWnd)
    ;;Send ("mfg")
    ;;Send ("{Enter}")
    If WinExists("test: QAD System Domain [USD] > 999 - SYSADM SYSTEM") Then
        WinActivate("test: QAD System Domain [USD] > 999 - SYSADM SYSTEM")
    Else
    WinWait("test: QAD System Domain [USD] > 999 - SYSADM SYSTEM")
    WinActivate("test: QAD System Domain [USD] > 999 - SYSADM SYSTEM ")
    MsgBox('','Done Waitin','2454')
    EndIf
EndFunc   ;==>RunQAD

;========================================================================================
; Menu Selection Func
;========================================================================================
Func MenuSelect()
    Sleep(1000)
    Send ("{CTRLDOWN}")
    Send ("m")
    Send ("{CTRLUP}")
    Send ("Role Create")
    Sleep(500)
    Send ("{Enter}")
    Sleep(500)
    Sleep(500)
EndFunc ;===> MenuSelect


 

AutoITError.docx

Edited by JLogan3o13
Added code tags

Share this post


Link to post
Share on other sites



#2 ·  Posted

@zaraijamel it appears that the error produces some unique text, as evidenced by your last screenshot 0 "Error Viewer - Role Create" etc,etc,etc

Have you tried doing a WinExists loop, looking specifically for this text? Something like:

If WinExists("test: QAD System Domain [USD] > 999 - SYSADM SYSTEM", "Error Viewer - Role Create") Then ...

 


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#3 ·  Posted

Hi @JLogan3o13

Thank you for you quick answer,

I will test this right away and keep you posted.

Best regards.

Share this post


Link to post
Share on other sites

#4 ·  Posted

8 minutes ago, JLogan3o13 said:

Hi @JLogan3o13

I added this condition but i noticed that the text tooks be the same with slight change in th order level (between the OK and KO cases).

Could you please advise if i can use any other detail.

degards.

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