Commits

Daniel Felzke committed ba1601d

Added Confirmation Box and Ensured that only one instance of Store Operations Manager is running.

Comments (0)

Files changed (1)

AutoSettleEDCBatch.ahk

 CashierNumber = Number
 CashierPassword = Password
 
+; Functions
+CloseStoreOperationsManager()
+{
+	; Check if program is running.
+	IfWinExist, Store Operations Manager
+	{
+		WinKill, Store Operations Manager
+		Sleep 5000
+	}
+
+	; Check if process is running.
+	Process, Exist, SOMANAGER.exe
+	SO_PID = %ErrorLevel%
+	if %SO_PID% != 0
+	{
+		Process, Close, %SO_PID%
+		Sleep 10000
+	}
+}
+
+; Confirmation
+MsgBox,4,Close Store Operations Manager Confirmation,Auto Settle EDC Batches Now?,30
+IfMsgBox No
+	Exit
+
+; Close Store Operations Manager
+CloseStoreOperationsManager()
+	
 ; Run Store Operations Manager
 Run "C:\Program Files\Microsoft Retail Management System\Store Operations\SOMANAGER.exe"
 
 WinWaitActive,Store Operations Manager,,20
 if ErrorLevel
 {
-    Exit
+    CloseStoreOperationsManager()
+	Exit
 }
 Send !ue
+WinWaitActive,Settle EDC Batch,,8
 
 ; Settle EDC Batch
-WinWaitActive,Settle EDC Batch,,20
+Send !s
+
+WinWaitActive,Settle Transactions,,5
 if ErrorLevel
 {
-    Exit
+	; No Transaction to settle
+	CloseStoreOperationsManager()
+	Exit
 }
-Send !s
-
-WinWaitActive,Settle Transactions,,20
 Send {Enter}
 
 WinWaitActive,Success,,120
 Send {Enter}
 
 ; Exit Application
-Sleep 3000
-Send !{F4}
-
+CloseStoreOperationsManager()
 Exit