Sign in to follow this  
Followers 0
krokkie

Script not working properly

4 posts in this topic

#1 ·  Posted (edited)

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]
    EndIf
EndIf
$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
    Exit
EndIf
; Stop currently running instances of DM
While WinActivate("Dispatch Manager - ") = 1
    Send("!F")
    ;Exit
    Send("x")
WEnd
;$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
;EndIf
$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)
;WinWaitActive("DPMAIL.NEW","",2)
; Send("!e")
;If WinWaitActive("Dispmgr","",2) Then
; ControlFocus("Dispmgr","","TButton1")
; ControlClick("Dispmgr","","TButton1")
;Endif
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
ExitDM()
Func ChangeCompany($Company)
    ;Bring Menu into Focus
    WinActivate("Dispatch Manager - ")
    Send("!F")
    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
        ChangeCompany($NewCompany)
        $Company = $NewCompany
    EndIf
    DelFiles($Company) ; Delete remaining CrossRef files AWYXREF.*
    ;Select Navigation Menu
    Send("!N")
    ;Navigation Part 2
    Send("v")
    ;Navigation Reports
    Send("a")
    ;Airway CrossRef
    Send("A")
    ;Blank Airway
    WinWaitActive("Value Entry", "&OK", 2)
    Send("!O")
    ;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 - ")
    Send("!F")
    ;Exit
    Send("x")
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



krokkie,

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

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

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.

1 person likes this

When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

Thanks for the help, I've been busy with other projects, will hopefully get around to this one again soon

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  
Followers 0