#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.2 Author: echoAwoo Taylor Connor Script Function: To facilitate the entry of local tracking data. Because the data entered can be derived from a database, and the entry methodologies are predictable and consistent, this script is a conscise attempt at automating the process. #ce ---------------------------------------------------------------------------- #include #include ; Script Start - Add your code below here Global $iCount, $iMax $iCount=InputBox("Cycle Start Value", "Please enter which cycle you would like to begin at."&@CRLF&"Default value is 0, this starts from the beginning. If script terminated unexpectedly, reenter last completed cycle value."&@CRLF&"This number can be found in the output Notepad window just to the left of the Timestamp.", 0, "", -1, -1, DEFAULT, DEFAULT, 60) ;~ $iCount=22 ;~ $iCount Testing Override $iMax=IniRead("set.ini", "Details", "iRoomTotal", 10) Global $aWO[5], $aDB, $bCalled ;~ While $iCount <= $iMax While 1 ;! 0=Room 1=Last Name 2= Status 3=Rate Code 4=Tracking $aWO=_at_wo($iCount) $aDB=_at_db($aWO) $bCalled=0 Sleep(60) ;~ If NOT $aWO[0]="Skip" Then If $aWO[2]="INHOUSE" AND $aWO[4]=0 Then $bCalled=1 _at_Init($aWO, $aDB, $iCount) _at_Record($aWO, $aDB, $iCount, $bCalled) ElseIf $aWO[0]=0 OR "END OF REPORT" Then ExitLoop MsgBox(0, "Completed!", "Script completed.", 0) Else $bCalled=0 EndIf ;~ Else ;~ $bCalled=0 ;~ EndIf Sleep(1000) $iCount=$iCount+1 Sleep(1000) WEnd Func _at_Init($aWO, $aDB, $iCount) ;~ Script Initilization _at_Modify($aWO, $aDB, $iCount) Sleep(1000) EndFunc Func _at_wo($iCount) Local $oExcel, $oWorkbook $oExcel=_Excel_Open(FALSE, FALSE, FALSE, FALSE, FALSE) If @error Then MsgBox(0, "Error: WorkOrder", "ExcelOpen failed with error " & @error) $oWorkbook=_Excel_BookOpen($oExcel, @ScriptDir&"\mktsegvl.xls", TRUE, FALSE) If @error Then MsgBox(0, "Error: WorkOrder", "BookOpen failed with error " & @error) Local $lfRoom, $sName, $aReturn[5] $lfRoom=18+(4*$iCount) $sName=StringSplit(_Excel_RangeRead($oWorkbook, DEFAULT, "B"&$lfRoom, 3, TRUE),"/",2) ;~ If @error Then MsgBox(0, "Error: WorkOrder", "RangeRead failed at Name with error " & @error) ;~ Local $iRoom, $sStatus, $sRate, $sTracking, $aReturn[5] ;~ $iRoom=_Excel_RangeRead($oWorkbook, DEFAULT, "A"&$lfRoom, 3, TRUE) ;~ ;! $sName[0]=Last Name $sName[1]=First Name ;~ $sStatus=_Excel_RangeRead($oWorkbook, DEFAULT, "D"&$lfRoom, 3, TRUE) ;~ $sRate=_Excel_RangeRead($oWorkbook, DEFAULT, "H"&$lfRoom, 3, TRUE) ;~ $sTracking=_Excel_RangeRead($oWorkbook, DEFAULT, "J"&$lfRoom, 3, TRUE) ;~ $aReturn[0]=$iRoom ;~ $aReturn[1]=$sName[0] ;~ $aReturn[2]=$sStatus ;~ $aReturn[3]=$sRate ;~ $aReturn[4]=$sTracking $aReturn[0]=_Excel_RangeRead($oWorkbook, DEFAULT, "A"&$lfRoom, 3, TRUE) ;~ Room# If @error Then MsgBox(0, "Error: WorkOrder", "RangeRead failed at Room with error " & @error) Sleep(10) $aReturn[1]=$sName[0] ;~ Req. Translation for stringsplit array ;~ Last name Sleep(10) $aReturn[2]=_Excel_RangeRead($oWorkbook, DEFAULT, "D"&$lfRoom, 3, TRUE) ;~ Room Status If @error Then MsgBox(0, "Error: WorkOrder", "RangeRead failed at Status with error " & @error) Sleep(10) $aReturn[3]=_Excel_RangeRead($oWorkbook, DEFAULT, "H"&$lfRoom, 3, TRUE) ;~ Rate Code If @error Then MsgBox(0, "Error: WorkOrder", "RangeRead failed at Rate with error " & @error) Sleep(10) $aReturn[4]=_Excel_RangeRead($oWorkbook, DEFAULT, "J"&$lfRoom, 3, TRUE) ;~ Tracking Value If @error Then MsgBox(0, "Error: WorkOrder", "RangeRead failed at Tracking with error " & @error) Sleep(10) If $aReturn[0]="END OF REPORT" Then Exit MsgBox(0, "Script Complete", "Script has completed.") EndIf Sleep(10) If $aReturn[0]=0 Then $aReturn[0]="Skip" Sleep(10) _Excel_BookClose($oWorkbook, FALSE) If @error Then MsgBox(0, "Error: WorkOrder", "BookClose failed with error " & @error) Sleep(100) _Excel_Close($oExcel, FALSE, TRUE) If @error Then MsgBox(0, "Error: WorkOrder", "ExcelClose failed with error " & @error) Sleep(100) Return $aReturn EndFunc Func _at_db($aWO) Local $oExcel, $oWorkbook, $aTracking, $sTracking $oExcel=_Excel_Open(FALSE, FALSE, FALSE, FALSE, FALSE) If @error Then MsgBox(0, "Error: Database", "ExcelOpen failed with error " & @error) Sleep(10) $oWorkbook=_Excel_BookOpen($oExcel, @ScriptDir&"\db.xlsx", TRUE, FALSE) If @error Then MsgBox(0, "Error: Database", "BookOpen failed with error " & @error) Sleep(10) $aTracking=_Excel_RangeFind($oWorkbook, $aWo[3], "A:A", Default, Default, False) ;~ If @error Then MsgBox(0, "Error: Database", "RangeFind failed with error " & @error) Sleep(10) ;~ _ArrayDisplay($aTracking, "Display $aTracking Array", "", DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, "") ;~ $aTracking Array size CheckSUM If UBound($aTracking, 1) > 0 Then $sTracking=_Excel_RangeRead($oWorkbook, DEFAULT, StringReplace($aTracking[0][2], "A", "B"), 3, TRUE) Else $sTracking=0 EndIf _Excel_BookClose($oWorkbook, FALSE) If @error Then MsgBox(0, "Error: Database", "BookClose failed with error " & @error) Sleep(100) _Excel_Close($oExcel, FALSE, TRUE) If @error Then MsgBox(0, "Error: Database", "ExcelClose failed with error " & @error) Sleep(100) Return $sTracking EndFunc ;~ Sends output data to notepad. Func _at_Record($aWO, $aDB, $iCount, $bCalled) Local $sStatus For $i = 1 to 3 Step 1 If NOT WinExists("[CLASS:Notepad]") Then Send("#r") Sleep(1000) If NOT WinActive("Run") Then WinActivate("Run") WinWaitActive("Run") If WinActive("Run") Then Send("Notepad{ENTER}") WinWait("[CLASS:Notepad]", "", 10) If WinExists("[CLASS:Notepad]") Then WinActivate("[CLASS:Notepad]") AND ExitLoop EndIf EndIf Sleep(1000) Next Sleep(100) If NOT WinExists("[CLASS:Notepad]") Then MsgBox(0, "Error", "Notepad failed to open after 3 attempts.") Else ;~ If WinExists("[CLASS:Notepad]") If NOT WinActive("[CLASS:Notepad]") Then WinActivate("[CLASS:Notepad]") WinWaitActive("[CLASS:Notepad]") If $bCalled=1 Then $sStatus="+Modded" Else $sStatus="-Skipped" EndIf Sleep(60) ;~ Send(_NowTime(3)&"{TAB}"&$iCount+1&"|Rm# "&$aWO[0]&"{TAB}"&$sStatus&"{ENTER}{TAB}"&$aWO[1]&" "&$aWO[3]&"{ENTER}{TAB}"&$aDB&"{TAB}"&$aWO[4]&"{ENTER}") Send($iCount&" "&_NowTime(3)&"{TAB}"&StringLeft($sStatus, 1)&" Rm. "&$aWO[0]&" "&$aWO[1]&" "&$aWO[3]&"{ENTER}{TAB}"&$aWO[4]&" "&$aDB&"{ENTER}") Sleep(60) EndIf EndFunc Func _at_Modify($aWO, $aDB, $iCount) Local $sToday, $soBoot, $soLogin, $soNew, $soMain, $soSearch, $soView, $soEdit, $soConfirm $sToday $soBoot="OnQ Property Management - Front Desk" $soLogin="OnQ Security" $soNew="Guest Listing for "&$sToday $soMain="[LOCAL] Guest Listing for "&$sToday $soSearch="Front Desk - Guest Listing Screen" $soView=$aWO[1]&" " $soEdit="Update Room Information" $soConfirm="Front Desk" If WinActive($soBoot) OR WinActive($soLogin) AND WinExists($soBoot) AND WinExists($soLogin) Then SetError(1,1) MsgBox(0, "Error "&@error&"/"&@extended, "Error generated @ _at_Modify. Script detected login screens. Please login and then restart the scipt.") Exit ElseIf NOT WinExists($soMain) AND NOT WinExists($soNew) AND NOT WinExists($soSearch) AND NOT WinExists($soView) AND NOT WinExists($soEdit) AND NOT WinExists($soConfirm) Then SetError(1,2) MsgBox(0, "Error "&@error&"/"&@extended, "Error generated @ _at_Modify. Script unable to detect any necessary screens. Please restart front desk and try again.") Exit Else If WinExists($soNew) Then WinActivate($soNew) WinWaitActive($soNew) Send("{ALTDOWN}") Sleep(60) Send("n") Sleep(60) Send("{ALTUP}") Sleep(60) If WinExists($soNew) AND WinActive($soNew) Then Send("{ENTER}") Sleep(60) WinWait($soSearch) ;~ Now at $soSearch EndIf EndIf If WinExists($soMain) Then WinActivate($soMain) WinWaitActive($soMain) Send("{ALTDOWN}") Sleep(60) Send("n") Sleep(60) Send("{ALTUP}") Sleep(60) If WinExists($soMain) AND WinActive($soMain) Then Send("{ENTER}") Sleep(60) WinWait($soSearch) ;~ Now at $soSearch EndIf EndIf If WinExists($soSearch) Then WinActivate($soSearch) WinWaitActive($soSearch) If $iCount=0 Then Send("{SHIFTDOWN}") Sleep(60) For $i = 1 to 5 Step 1 Send("{TAB}") Sleep(60) Next Send("{SHIFTUP}") Sleep(60) Send("In House") Sleep(60) For $i = 5 to 1 Step -1 Send("{TAB}") Sleep(60) Next EndIf For $i = 1 to 2 Step 1 Send("{TAB}") Sleep(60) Next Send($aWO[0]) Sleep(60) Send("{ENTER}") Sleep(1000) If WinActive($soMain) Then Send($aWO[1]) Sleep(2000) Send("{ENTER}") Sleep(100) Send("{TAB}") Sleep(100) Send($aWO[1]) Sleep(10) For $i = 1 to 10 Step 1 If NOT WinActive($soView) Then Send("{UP}") Sleep(10) Else ExitLoop EndIf Next Sleep(100) EndIf WinWait($soView,"",10) EndIf If WinExists($soView) Then WinActivate($soView) WinWaitActive($soView) Send("{ALTDOWN}") Sleep(60) Send("{ALTUP}") Sleep(60) Send("r") Sleep(60) Send("v") Sleep(60) EndIf If WinExists($soEdit) Then WinActivate($soEdit) WinWaitActive($soEdit) Send("{ALTDOWN}") Sleep(60) For $i = 1 to 2 Step 1 Send("a") Sleep(60) Next Send("{ALTUP}") Sleep(60) For $i = 1 to 3 Step 1 Send("{TAB}") Sleep(60) Next Send($aDB) Sleep(60) Send("{ENTER}") WinActivate($soView) WinWaitActive($soView) Send("{ALTDOWN}") Sleep(60) Send("{ALTUP}") Sleep(60) Send("a") Sleep(60) Send("s") Sleep(60) If WinExists("Verify User") Then Sleep(1000) WinWaitClose("Verify User", "", 0) EndIf If WinActive($soConfirm) Then Send("{ENTER}") If NOT WinExists($soConfirm) Then SetError(2,1) MsgBox(0, "Error "&@error&"/"&@extended, "Modify failed at "&$soConfirm&" (var $soConfirm)") Exit EndIf EndIf ;~ If WinExists($soConfirm) Then ;~ WinActivate($soConfirm) ;~ WinWaitActive($soConfirm) ;~ Sleep(60) ;~ Send("{ENTER}") ;~ Sleep(60) ;~ EndIf EndIf EndFunc