Steven, here is the script we use and when it works it works great. For the warning message that pops up after you select scan, we set for the script to sent Enter. Enter will select yes on that warning and continue the script.
; AutoIt v3.3.14.5
; https://www.autoitscript.com
#include <MsgBoxConstants.au3>
; Path to QuickBooks Database Server Manager
Global Const $qbDSM = "C:\Program Files (x86)\Common Files\Intuit\QuickBooks\QBServerUtilityMgr.exe"
; Title of window
Global Const $title = "QuickBooks Database Server Manager";
Main()
; Main Function
Func Main()
; check if program already running
If WinExists("[TITLE:"&$title&"]") Then
;program running close it and wait 5 seconds for it close
WinClose("[TITLE:"&$title&"]")
WinWaitClose("[TITLE:"&$title&"]",5)
EndIf
Launch()
EndFunc
; launch the QuickBooks Database Server Manager
Func Launch()
; Check if the Program File Exists
Local $exist = FileExists($qbDSM)
If $exist Then ; if it does exist
; launch the program
Local $iPID = Run($qbDSM)
; wait upto 5 seconds for the window to appear
WinWait("[TITLE:"&$title&"]","",5)
; wait 10 seconds incase it takes a while to launch
Sleep (10000)
; Select the window to execute the remianing commands
WinActivate($title)
; send keys to start Scan
Scan()
Else ; if program not found, message box saying not found
MsgBox($MB_SYSTEMMODAL,"Error","Program " & $qbDSM & " not found")
EndIf
EndFunc
Func Scan()
; send the tab key to move to [Start Scan] button
Send("{TAB}")
; send the enter key to start the scan
Send("{ENTER}")
; send the enter key to close the warning message
Send("{ENTER}")
; wait 15 seconds for the scan to finish
Sleep (15000)
; Lock the screen for security reasons
ShellExecute("rundll32.exe", "user32.dll,LockWorkStation")
EndFunc