I'm trying to create some automation code for Milestone XProtect, a camera surveillance software, and I need a bit of help. I was originally using Batch scripting and VBScript to attempt my goal, but it doesn't seem to work for me
#include <MsgBoxConstants.au3> ;Import Message Box
Local Const $milestone = "C:\Program Files\Milestone\XProtect Smart Client\Client.exe" ;Local Variable $milestone set to file path
Local $iFileExists = FileExists($milestone) ;Variable that sees if file exists($milestone)
If $iFileExists Then
Run($milestone)
> ;[Unknown Variables] ;***Figure out the "Window Title", Class, and Instance***
Send("{TAB}")
Send("{TAB}")
Send("[Insert Camera IP Address Here]") ;Between [] different for each .exe I'll create
Send("{ENTER}")
> ;[Unknown Variables] ;***Figure out items in camera window to see when its fully loaded***
Else
MsgBox($MB_SYSTEMMODAL, "", "Milestone XProtect wasn't found on this computer" & @CRLF) ;Error Message "File not Found"
EndIf
As of right now, my code sets a variable of the path to Milestone on the computer, and the if statement checks if the file exists. If it exists, then it'll run the program. The next line of code is supposed to wait until the program is fully loaded before sending two tab keys, the ip address to the cameras server, then and enter key. The last line of code in the if statement is supposed to check and see if the cameras have loaded up fully before ending the program.
What I need help on are the two sections labeled [Unknown Variables] in my code:
- I need to know when the program is loaded up to the server selection screen
- I need to know when the cameras server has loaded completely before I end the program
Can anyone help?
Solution
I have put together some of the missing elements you needed in order to accomplish this task while maintaining simplicity, as well as added annotations to help describe each line.
There are several ways to continue the automation process, such as offering a drop down list of different IP Address's or an Input box instead of hardcoding the address. You will just have to evolve the script over time adding one element at a time.
AutoIt Script
Window Handle
Retrieving the window handle is important as it ensures the keystrokes are being sent to the last ran instance of the Milestone software, if several are running.
Thoughts On Retrying
As for the second question, there are many ways you could achieve checking for a connection with a timeout to retry. However, it mostly depends on the interaction available via AutoIt. A good place to start is the AutoIt Window Info Tool. You can drag and drop the crosshair to elements of a window to identify controls. Image below shows the tool when focusing the Windows Calculator.
Example
If there is a popup window that displays when a server cannot connect you could intercept that to signal a retry. There are options to search for an image or pixels on the screen if all you have to go off of is a blank video monitor. Or perhaps a good server connection will offer some type of alert that AuoIt can capture and successfully close when satisfied, or retry in X seconds if not.
UPDATE
Here is the program with the GUI and Combo Box option, this utilizes 2D arrays.
UPDATE #2