Jump to content
Sign in to follow this  

Script not working properly

Recommended Posts

I have recently added a new airline to my script, and noticed that it does not run properly

Here is the script:

AutoItSetOption("WinTitleMatchMode", 4)
AutoItSetOption("MustDeclareVars", 1)
Dim $Company, $User, $Pwd, $Drive, $WorkingDir, $AppName, $Result
$Company = "ANZ"
$User = "AUTI"
$Pwd = "A"
$Drive = "P"
$WorkingDir = "[url=null]\\aklaq811.corp.ad.airnz.co.nz\sdmq\FltCtrl[/url]"
; Check Parameters and set Drive Letter to
If ($CmdLine[0] = 1) Then
    If StringLen($CmdLine[1]) = 1 Then
        $Drive = $CmdLine[1]
$Result = MsgBox(1, "Airway Cross Ref", "Run on " & $Drive & " Drive and stop " & _
        @LF & "current instances of DM", 10)
WinActivate("Airway Cross Ref")
If $Result = -1 Or $Result = 2 Then
; Stop currently running instances of DM
While WinActivate("Dispatch Manager - ") = 1
;$AppName = $Drive &":\FltCtrl\Bin\DISPMGR.exe N " & $User & "PPPCAANZPOXz FLTCTRL EAGLEOX P"
;If MsgBox(1,"Airway Cross Ref","Running on " & $Drive & " Drive",10) = 2 Then
; Exit
$AppName = $Drive & ":\FltCtrl\Bin\DISPMGR.exe N " & $User & $Drive & $Drive & $Drive & "CAANZ" _
         & $Drive & "OXz FLTCTRL EAGLEOX " & $Drive
; Start Dispatch Manager
;MsgBox(0,"Airway Cross Ref",$Company & " " & $AppName & " " & $WorkingDir)
;MsgBox(0,"Airway Cross Ref",$AppName)
Run($AppName, $WorkingDir)
;Sign In
WinWaitActive("Dispatch Manager Sign In")
Send($Pwd & "{Tab 4}" & $Company & "{Enter}")
;Clear Email (Not Required for AUTI User)
; Send("!e")
;If WinWaitActive("Dispmgr","",2) Then
; ControlFocus("Dispmgr","","TButton1")
; ControlClick("Dispmgr","","TButton1")
WinWaitActive("Dispatch Manager - ")
;Create_CrossRef("ANZ") ; Cross Reference ANZ
;Create_CrossRef("ANG") ; Cross Reference ANG
;Create_CrossRef("FJI") ; Cross Reference FJI
;Create_CrossRef("OZW") ; Cross Reference OZW
;Create_CrossRef("UTY") ; Cross Reference UTY
Create_CrossRef("TMN") ; Cross Reference TMN
MsgBox(0, "Airway Cross Ref", "Cross Reference Complete")
;Exit DM
Func ChangeCompany($Company)
    ;Bring Menu into Focus
    WinActivate("Dispatch Manager - ")
    Send("C" & $Pwd & "{Tab 4}" & $Company & "{Enter}")
EndFunc   ;==>ChangeCompany
Func DelFiles($Company)
    FileDelete($Drive & ":\FltCtrl\Reports\" & $Company & "\AWYXREF.*")
EndFunc   ;==>DelFiles
Func MoveFiles($Company)
    FileMove($Drive & ":\FltCtrl\Reports\" & $Company & "\AWYXREF.*", $Drive & ":\DisInfo\Airway CrossRef\Reports\" & $Company & "AWYXREF.txt", 1)
EndFunc   ;==>MoveFiles
Func Create_CrossRef($NewCompany)
    If $Company <> $NewCompany Then
        $Company = $NewCompany
    DelFiles($Company) ; Delete remaining CrossRef files AWYXREF.*
    ;Select Navigation Menu
    ;Navigation Part 2
    ;Navigation Reports
    ;Airway CrossRef
    ;Blank Airway
    WinWaitActive("Value Entry", "&OK", 2)
    ;Wait for completion of Cross Reference
    WinWaitClose("DispatchManager Console")
    MoveFiles($Company) ; Move and rename CrossRef files
    ;Bring Menu into Focus
    WinActivate("Dispatch Manager - ")
EndFunc   ;==>Create_CrossRef
Func ExitDM()
    ;Exit Dispatch Manager
    ;Bring Menu into Focus
    WinActivate("Dispatch Manager - ")
EndFunc   ;==>ExitDM
The problem seems to occur in the Create_CrossRef func, for some reason that bit only seems to start after the MsgBox(0,"Airway Cross Ref","Cross Reference Complete") part

I've tried by moving the MsgBox section to the end, made no difference.

I've also tried changing the company to the newly added TMN, still made no difference.

It does work sometimes, but not always, which means if I get the "Cross Reference Complete" message, the MoveFiles has not run

It would appear the WinWaitActive command is the culprit, is there a better way of doing this part?

Edited by Melba23
Fixed tags

Share this post

Link to post
Share on other sites


Please us the default font - it makes your post much easier to read. And when you post code please use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. ;)


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Share this post

Link to post
Share on other sites
It would appear the WinWaitActive command is the culprit, is there a better way of doing this part?



If it is hanging at WinWaitActive, then the problem is the window is now active (intuitive). Try looking at TrayIconDebug in the help file; this will at least confirm which line the script is hanging at.

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
Sign in to follow this  

  • Create New...