Jump to content

Help for new AutoIt User with "if", "Then"


dreadx
 Share

Recommended Posts

What I need help with is creating an "if" statement that changes the behavior of the program if a box pops up on the screen. I need to program to stop and start over if the box pops up or continue if it does not. The box I am referring to is pictured in the attached file. I have also included my very simple code.

Thank you in advance for any help.

HotKeySet("x", "MyExit")
For $i = 0 to 214

WinActivate("[CLASS:XLMAIN]", "") ;Activates Excel
    Sleep(100)
    Send("^c")  ;copy SID
    Sleep(100)
    Send("{Down}")  
WinActivate("[CLASS:ThunderRT6FormDC]", "") ;Activates Citrix Window
    Sleep(300)
ControlClick("Application Access Administration - UAT", "", "[ID:3]")
    Sleep(200)
    Send("{TAB 6}")
    Sleep(200)
    Send("{Down 2}")
    Sleep(200)  
    Send("{TAB 6}")
    Sleep(100)
    Send("^v") ;paste SID
    Send("{TAB 6}")
    Sleep(100)
    Send("{Enter}")
    Sleep(500)
    Send("{Enter}")
    Sleep(500)
    Send("{TAB 8}")
    Sleep(100)
    Send("{Enter}") 
    Sleep(200)
    Send("{Enter}" ) ;Clears error if there is one
    Sleep(100)
    Send("{TAB 8}") ;moves to cost center
    Sleep(100)
    Send("{up}")
    Sleep(300)
    Send("{down}")
    Sleep(100)
    Send("{TAB 1}") ; moves to user status
    Sleep(100)
    Send("{Down}") ;Changes to Inactive
    Sleep(100)
    Send("{TAB 5}") ;Moves to Save
    Sleep(100)
    Send("{Enter}")
    Sleep(100)
    Send("{Enter}")
    Sleep(100)
    Send("{TAB 17}") ; Move to close
    Sleep(500)
    Send("{Enter}") ;Back to main search screen
    Sleep(500)
    Send("{TAB}")
    Sleep(100)

Next
Func MyExit()
    Exit 
EndFunc
Link to comment
Share on other sites

Personally I wouldn't make the script use all those tabs and you should see if you can ControlSend your text to the field that you want to put the SID in. You could also use the excel UDF to open the document and copy the cells to a variable then ControlSend it to where you need it. As far as your if then statement it looks like your error comes up once you press search after you pasted the SID well if it always looks like that then you could do something like this

Send("{TAB 6}")
 Sleep(100)
 Send("^v") ;paste SID
 Send("{TAB 6}")
 Sleep(100)
 Send("{Enter}")
 If WinExists("User Maintenance") Then
 WinClose("User Maintenance") ; or could do a Send("^{F4}") or Send("{ENTER}")
 EndIf
Edited by Onichan
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...