Jump to content

Cannot get script to continue after IF statement


Recommended Posts

Apologies in advance I am a noob! :">

For some reason the IF statement highlighted in bold below causes my script to pause... if I rem the statement out the script works fine.

I'm sure there is a very simple reason why and please excuse the amateur mess - so again sorry!

Cheers

CODE

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.2.2.0

Author: Ben Medder

Script Function:

Creates a Voicemail Inbox in Groupwise using an IMAP account.

#ce ----------------------------------------------------------------------------

dim $number

;WinWait

; Launches Groupwise

run("C:\Novell\GroupWise\grpwise.exe")

;Wait for dialog box and display message informing user to log in so a task can be performed.

WinWaitActive("GroupWise Password")

MsgBox(64, "IT Support - Ben Medder Ext. 6910", "A routine task is about to be performed, so that you can access Voicemail via Groupwise. Please log into Groupwise and follow any instructions.")

;Opens the "Accounts" menu and selects "Account Options"

WinWaitActive("Novell GroupWise - Ben Medder Home")

Send("{ALTDOWN}n{ALTUP}")

WinWait("Send items to and retrieve items from all marked accounts","All Day Event ")

Send("a")

WinWaitActive("Accounts")

;Adds an IMAP account called "Voicemail" and enters the relevant details

Send("!a")

WinWaitActive("Create Account","Type the name you wi")

Send("{SHIFTDOWN}v{SHIFTUP}oicemail{TAB}i{ALTDOWN}n{ALTUP}")

IF WinWaitActive("Internet Accounts", "The name")Then

WinClose("Internet Accounts")

WinWaitActive("Create Account")

Send("{TAB 2}{ENTER}")

WinWaitActive("Accounts")

Send("!c")

MsgBox(0, "Complete", "You already appear to have a Voicemail inbox setup. The task will close.")

Exit

EndIf

WinWaitActive("Create Internet Account", "Contact your Internet Service Provider")

Send("10.1.6.20{TAB}")

; Loop around until the user gives a valid voicemail ext.

$loop = 1

While $loop = 1

$number = InputBox("Ext. Number..?", "Please enter you extension number and click OK", "", " M4")

If @error = 1 Then

MsgBox(4096, "Error", "You pressed 'Cancel' - try again!")

Else

$loop = 0

EndIf

WEnd

ControlSend("Create Internet Account", "Contact your Internet Service Provider for mail server information and for your login name.", 221, $number)

Send("{TAB}{TAB}{TAB}{ALTDOWN}n{ALTUP}{ALTDOWN}n{ALTUP}")

WinWaitActive("Create IMAP Folder","Name the new folder ")

Send("{TAB}{UP 30}{DOWN}")

ControlSend("Create IMAP Folder","Name the new folder ", 12325, "{ENTER}")

WinWaitActive("Accounts","&General Options")

Send("{ALTDOWN}c{ALTUP}")

MsgBox(64, "Finished!", "You can now access your Voicemail messages by clicking the voicemail folder, directly under your mailbox.")

MsgBox(64, "Make sure...", "Please ensure you login with your correct ext number and VOCEMAIL PASSWORD.")

Link to comment
Share on other sites

Cannot see a line in bold and you cannot bold out something in code tags. :P

You may need to activate some of those windows so I added a function to help with it. This may help if that is the issue.

CODE
#cs ----------------------------------------------------------------------------
    
    AutoIt Version: 3.2.2.0
    Author: Ben Medder
    
    Script Function:
    Creates a Voicemail Inbox in Groupwise using an IMAP account.
    
#ce ----------------------------------------------------------------------------
Global $number
;WinWait

; Launches Groupwise
Run("C:\Novell\GroupWise\grpwise.exe")

;Wait for dialog box and display message informing user to log in so a task can be performed.
WinWaitActive("GroupWise Password")
MsgBox(64, "IT Support - Ben Medder Ext. 6910", "A routine task is about to be performed, so that you can access Voicemail via Groupwise. Please log into Groupwise and follow any instructions.")

;Opens the "Accounts" menu and selects "Account Options"
_WinWaitActive("Novell GroupWise - Ben Medder Home")
Send("{ALTDOWN}n{ALTUP}")
_WinWaitActive("Send items to and retrieve items from all marked accounts", "All Day Event ")
Send("a")
_WinWaitActive("Accounts")

;Adds an IMAP account called "Voicemail" and enters the relevant details
Send("!a")
_WinWaitActive("Create Account", "Type the name you wi")
Send("{SHIFTDOWN}v{SHIFTUP}oicemail{TAB}i{ALTDOWN}n{ALTUP}")
If _WinWaitActive("Internet Accounts", "The name") Then
    WinClose("Internet Accounts")
    _WinWaitActive("Create Account")
    Send("{TAB 2}{ENTER}")
    _WinWaitActive("Accounts")
    Send("!c")
    MsgBox(0, "Complete", "You already appear to have a Voicemail inbox setup. The task will close.")
    Exit
EndIf
_WinWaitActive("Create Internet Account", "Contact your Internet Service Provider")
Send("10.1.6.20{TAB}")

; Loop around until the user gives a valid voicemail ext.
While 1
    $number = InputBox("Ext. Number..?", "Please enter you extension number and click OK", "", " M4")
    If @error = 1 Then
        MsgBox(4096, "Error", "You pressed 'Cancel' - try again!")
    Else
        ExitLoop
    EndIf
WEnd
_WinWaitActive("Create Internet Account", "Contact your Internet Service Provider")
ControlSend("Create Internet Account", "Contact your Internet Service Provider for mail server information and for your login name.", 221, $number)
Send("{TAB 3}{ALTDOWN}n{ALTUP}{ALTDOWN}n{ALTUP}")
_WinWaitActive("Create IMAP Folder", "Name the new folder ")
Send("{TAB}{UP 30}{DOWN}")
ControlSend("Create IMAP Folder", "Name the new folder ", 12325, "{ENTER}")
_WinWaitActive("Accounts", "&General Options")
Send("{ALTDOWN}c{ALTUP}")
MsgBox(64, "Finished!", "You can now access your Voicemail messages by clicking the voicemail folder, directly under your mailbox.")
MsgBox(64, "Make sure...", "Please ensure you login with your correct ext number and VOCEMAIL PASSWORD.")

Exit

Func _WinWaitActive($title, $text = "", $timeout = 999999)
    WinWait($title, $text)
    WinActivate($title, $text)
    If WinWaitActive($title, $text, $timeout) Then
        Return True
    EndIf
EndFunc

Using an If with a WinWaitActive makes little sense unless you use a timeout parameter, but I chose not to add cause you have no Else condition.

:whistle:

Link to comment
Share on other sites

Thanks MHz - unfortunately I've still got the same problem after including your ammendments.

Re: not being able to see the line in question in bold - I can see them, there seems to be no problem with the bold tag embedded within the code tag..! but here it is again:-

IF WinWaitActive("Internet Accounts", "The name")Then
WinClose("Internet Accounts")
WinWaitActive("Create Account")
Send("{TAB 2}{ENTER}")
WinWaitActive("Accounts")
Send("!c")
MsgBox(0, "Complete", "You already appear to have a Voicemail inbox setup. The task will close.")
Exit
EndIf

If I rem the above out the cript executes to completion fine??!!

Thanks again.

Link to comment
Share on other sites

So, I am guessing this window may not arrive so you can use AdlbEnable() to handle it if it shows up.

CODE
#cs ----------------------------------------------------------------------------
    
    AutoIt Version: 3.2.2.0
    Author: Ben Medder
    
    Script Function:
    Creates a Voicemail Inbox in Groupwise using an IMAP account.
    
#ce ----------------------------------------------------------------------------
Global $number
;WinWait

; Launches Groupwise
Run("C:\Novell\GroupWise\grpwise.exe")

;Wait for dialog box and display message informing user to log in so a task can be performed.
WinWaitActive("GroupWise Password")
MsgBox(64, "IT Support - Ben Medder Ext. 6910", "A routine task is about to be performed, so that you can access Voicemail via Groupwise. Please log into Groupwise and follow any instructions.")

;Opens the "Accounts" menu and selects "Account Options"
_WinWaitActive("Novell GroupWise - Ben Medder Home")
Send("{ALTDOWN}n{ALTUP}")
_WinWaitActive("Send items to and retrieve items from all marked accounts", "All Day Event ")
Send("a")
_WinWaitActive("Accounts")

;Adds an IMAP account called "Voicemail" and enters the relevant details
Send("!a")
_WinWaitActive("Create Account", "Type the name you wi")
Send("{SHIFTDOWN}v{SHIFTUP}oicemail{TAB}i{ALTDOWN}n{ALTUP}")

AdlibEnable("_Adlib")

_WinWaitActive("Create Internet Account", "Contact your Internet Service Provider")
Send("10.1.6.20{TAB}")

AdlibDisable()

; Loop around until the user gives a valid voicemail ext.
While 1
    $number = InputBox("Ext. Number..?", "Please enter you extension number and click OK", "", " M4")
    If @error = 1 Then
        MsgBox(4096, "Error", "You pressed 'Cancel' - try again!")
    Else
        ExitLoop
    EndIf
WEnd
_WinWaitActive("Create Internet Account", "Contact your Internet Service Provider")
ControlSend("Create Internet Account", "Contact your Internet Service Provider for mail server information and for your login name.", 221, $number)
Send("{TAB 3}{ALTDOWN}n{ALTUP}{ALTDOWN}n{ALTUP}")
_WinWaitActive("Create IMAP Folder", "Name the new folder ")
Send("{TAB}{UP 30}{DOWN}")
ControlSend("Create IMAP Folder", "Name the new folder ", 12325, "{ENTER}")
_WinWaitActive("Accounts", "&General Options")
Send("{ALTDOWN}c{ALTUP}")
MsgBox(64, "Finished!", "You can now access your Voicemail messages by clicking the voicemail folder, directly under your mailbox.")
MsgBox(64, "Make sure...", "Please ensure you login with your correct ext number and VOCEMAIL PASSWORD.")

Exit

Func _Adlib()
    If WinExists("Internet Accounts", "The name") And _WinWaitActive("Internet Accounts", "The name") Then
        WinClose("Internet Accounts")
        _WinWaitActive("Create Account")
        Send("{TAB 2}{ENTER}")
        _WinWaitActive("Accounts")
        Send("!c")
        MsgBox(0, "Complete", "You already appear to have a Voicemail inbox setup. The task will close.")
        Exit
    EndIf
EndFunc

Func _WinWaitActive($title, $text = "", $timeout = 999999)
    WinWait($title, $text)
    WinActivate($title, $text)
    If WinWaitActive($title, $text, $timeout) Then
        Return True
    EndIf
EndFunc

:whistle:

Link to comment
Share on other sites

Works a treat - thank you very much - it's a bit above my head at the moment. From what I can understand you've done with your custom functions, is be a bit more methodical with waiting and activating windows?! Or am I way off track

The problem I face now in regards to Waiting for windows is one of the first lines:-

WinWaitActive("GroupWise Password - Ben Medder Home")

The problem I'll face using it with other users is obviously the name... is there not a wildcard or something I could put in e.g

WinWaitActive("GroupWise Password - * or %")

cheers

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