Jump to content

StatusBarGetText == "TEXT"


reh1996
 Share

Recommended Posts

Hi all,

First of all apologies for my lack of knowledge, I am rather new to AutoIT and so I am still learning.

I am trying to set up a program for work however I seem to be having some trouble.

I am basically setting up 2 Global statements, 1 is StatusBarGetText ("window", "", Status bar field) and the other is just plain text.

Global $totalshipments = StatusbarGetText ("UPS WorldShip - Administrative Workstation", "", 4)
Global $totalshipments2 = ("0 total shpmt(s)  Collection Rec: 0 00 0")

I am then doing the below.

Sleep (120000)
Send ("{F2}")
Sleep (10000)
Send ("{F3}")
Sleep (10000)


if $totalshipments == $totalshipments2 Then
Exit
Else
   ShellExecuteWait("UPS EOD.msg", "", "Q:\mezzanine\Desktop\AutoIT tools\", "", @SW_MAXIMIZE)
   Sleep(2000)
   ControlClick ("UPS EOD - Message (HTML) ", "", 4256, "left", 1)
   Sleep(2000)
EndIf
Exit

So basically it detects if a manifest has been produced. If it has then it should exit the script, if it hasn't then it will send an email to someone stating the manifest has not been produced and needs to be done.

I am not getting any errors however the email is being sent even though the manifest has been produced.

Can someone help ?

Thanks,

-R

Edited by reh1996
Link to comment
Share on other sites

String comparison using == is a case sensitive operator.  Could that be the issue?

Show us the output of $totalshipments and $totalshipments2 please.

Link to comment
Share on other sites

Sleep (120000)
Send ("{F2}")
Sleep (10000)
Send ("{F3}")
Sleep (10000)


if $totalshipments == $totalshipments2 Then
MsgBox(0,"Result 1",$totalshipments, & " " & $totalshipments2);Debug line
Exit
Else
   MsgBox(0,"Result 2",$totalshipments, & " " & $totalshipments2);Debug line
   ;ShellExecuteWait("UPS EOD.msg", "", "Q:\mezzanine\Desktop\AutoIT tools\", "", @SW_MAXIMIZE)
   Sleep(2000)
   ControlClick ("UPS EOD - Message (HTML) ", "", 4256, "left", 1)
   Sleep(2000)
EndIf
Exit

You first need to know that what you are comparing is actually exactly the same. add some sleep lines or whatever to further help debug your code. Is the status bar the only constant trigger to know that it has been done?

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

Hi.

Jaberwacky:

the output for $totalshipments should be the same as the text stated in $totalshipments2. hence why i have done ==

computergroove:

both $totalshipments and $totalshipments2 should match after the beginning of the code is finished. 

here is the full code for both of you, you may be able to help better if you see the whole thing.

Global $totalshipments = StatusbarGetText ("UPS WorldShip - Administrative Workstation", "", 4)
Global $totalshipments2 = ("0 total shpmt(s)  Collection Rec: 0 00 0")

   if WinExists ("XML Auto Import", "") Then
      ControlClick ("XML Auto Import", "", "[ID:17329]")
      ControlClick ("UPS WorldShip", "", "[ID:6]")
      ControlClick ("XML Auto Import", "", "[ID:15079]")

      WinSetState("UPS WorldShip - Administrative Workstation", "", @SW_RESTORE)
      WinActivate("UPS WorldShip - Administrative Workstation", "")
      sleep(2000)
      Send("{F3}")
      sleep(10000)
      send("{F11}")
      sleep(2000)
      Do
         Sleep(1000)
         until WinExists ("End of Day Processing", "You have shipments in your Remote, Deferred, Imported or In Error list. Would you like to cancel End of Day and process the shipments first?")
      ControlClick ("End of Day Processing", "", "[CLASSNN:Button2]", "left", 1)
      Do
         Sleep(1000)
         until WinExists ("End of Day Processing", "Are you ready to close today's shipping and send the shipment information to UPS?")
      ControlClick ("End of Day Processing", "Are you ready to close today's shipping and send the shipment information to UPS?", "[CLASSNN:Button1]", "left", 1)

Else
   WinMinimizeAll ()
   WinSetState("UPS WorldShip - Administrative Workstation", "", @SW_RESTORE)
   WinActivate("UPS WorldShip - Administrative Workstation", "")
   sleep(2000)
   Send("{F3}")
   sleep(10000)
   send("{F11}")
   sleep(2000)
      Do
         Sleep(1000)
         until WinExists ("End of Day Processing", "You have shipments in your Remote, Deferred, Imported or In Error list. Would you like to cancel End of Day and process the shipments first?")
   ControlClick ("End of Day Processing", "", "[CLASSNN:Button2]", "left", 1)
   Sleep(2000)
      Do
         Sleep(1000)
         until WinExists ("End of Day Processing", "Are you ready to close today's shipping and send the shipment information to UPS?")
   ControlClick ("End of Day Processing", "Are you ready to close today's shipping and send the shipment information to UPS?", "[CLASSNN:Button1]", "left", 1)

EndIf


Sleep (120000)
Send ("{F2}")
Sleep (10000)
Send ("{F3}")
Sleep (10000)

if $totalshipments == $totalshipments2 Then
Exit
Else
   ShellExecuteWait("UPS EOD.msg", "", "Q:\mezzanine\Desktop\AutoIT tools\", "", @SW_MAXIMIZE)
   Sleep(2000)
   ControlClick ("UPS EOD - Message (HTML) ", "", 4256, "left", 1)
   Sleep(2000)
EndIf
Exit
Link to comment
Share on other sites

Show us what the contents of the variables $totalshipments and $totalshipments2 contain. The exact contents, because even an extra space will cause it to not match.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

the contents for both should be 0 total shpmt(s)  Collection Rec: 0 00 0.

this was copied from the AutoIT window info tool to avoid any mismatches.

$totalshipments should return that little bit of text however to check that it is correct i need to compare it to $totalshipments2

Link to comment
Share on other sites

We aren't asking you what it SHOULD contain, we asked you what it DOES contain, see the difference? Do a consolewrite of the variable directly after obtaining the text from the status bar, see if they match exactly.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Sleep (120000)
Send ("{F2}")
Sleep (10000)
Send ("{F3}")
Sleep (10000)


if $totalshipments == $totalshipments2 Then
MsgBox(0,"Result 1",$totalshipments, & " " & $totalshipments2);Debug line
Exit
Else
   MsgBox(0,"Result 2",$totalshipments, & " " & $totalshipments2);Debug line
   ;ShellExecuteWait("UPS EOD.msg", "", "Q:\mezzanine\Desktop\AutoIT tools\", "", @SW_MAXIMIZE)
   Sleep(2000)
   ControlClick ("UPS EOD - Message (HTML) ", "", 4256, "left", 1)
   Sleep(2000)
EndIf
Exit

You first need to know that what you are comparing is actually exactly the same. add some sleep lines or whatever to further help debug your code. Is the status bar the only constant trigger to know that it has been done?

My suggested code will tell you this info. Did the code I provided not show you the first value followed by the second value so you could compare?

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

Hi all,

Thanks for your great responses. I have actually managed to get this working. I have no idea how, I just ended up on a tangent from one of the suggestions and went from there.

Any way, here is my finished code.

Global $totalshipments = StatusbarGetText ("UPS WorldShip - Administrative Workstation", "", 4)
Global $totalshipments2 = ("0 total shpmt(s)  Collection Rec: 0 00 0")
Global $totalshipments4 = BinaryToString ( $totalshipments)

   if WinExists ("XML Auto Import", "") Then
      ControlClick ("XML Auto Import", "", "[ID:17329]")
      ControlClick ("UPS WorldShip", "", "[ID:6]")
      ControlClick ("XML Auto Import", "", "[ID:15079]")

      WinSetState("UPS WorldShip - Administrative Workstation", "", @SW_RESTORE)
      WinActivate("UPS WorldShip - Administrative Workstation", "")
      sleep(2000)
      Send("{F3}")
      sleep(10000)
      send("{F11}")
      sleep(2000)
      Do
         Sleep(1000)
         until WinExists ("End of Day Processing", "You have shipments in your Remote, Deferred, Imported or In Error list. Would you like to cancel End of Day and process the shipments first?")
      ControlClick ("End of Day Processing", "", "[CLASSNN:Button2]", "left", 1)
      Do
         Sleep(1000)
         until WinExists ("End of Day Processing", "Are you ready to close today's shipping and send the shipment information to UPS?")
      ControlClick ("End of Day Processing", "Are you ready to close today's shipping and send the shipment information to UPS?", "[CLASSNN:Button1]", "left", 1)

Else
   WinMinimizeAll ()
   WinSetState("UPS WorldShip - Administrative Workstation", "", @SW_RESTORE)
   WinActivate("UPS WorldShip - Administrative Workstation", "")
   sleep(2000)
   Send("{F3}")
   sleep(10000)
   send("{F11}")
   sleep(2000)
      Do
         Sleep(1000)
         until WinExists ("End of Day Processing", "You have shipments in your Remote, Deferred, Imported or In Error list. Would you like to cancel End of Day and process the shipments first?")
   ControlClick ("End of Day Processing", "", "[CLASSNN:Button2]", "left", 1)
   Sleep(2000)
      Do
         Sleep(1000)
         until WinExists ("End of Day Processing", "Are you ready to close today's shipping and send the shipment information to UPS?")
   ControlClick ("End of Day Processing", "Are you ready to close today's shipping and send the shipment information to UPS?", "[CLASSNN:Button1]", "left", 1)

EndIf


Sleep (120000)
Send ("{F2}")
Sleep (10000)
Send ("{F3}")
Sleep (10000)

if $totalshipments4 == $totalshipments2 Then
Exit
Else
   ShellExecuteWait("UPS EOD.msg", "", "Q:\mezzanine\Desktop\AutoIT tools\", "", @SW_MAXIMIZE)
   Sleep(2000)
   ControlClick ("UPS EOD - Message (HTML) ", "", 4256, "left", 1)
   Sleep(2000)
EndIf
Exit

Thank you all for your help :)

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