#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 ; Script Start - Add your code below here Global $iCount, $iMax $iCount=22 $iMax=IniRead("set.ini", "Details", "iRoomTotal", 10) Local $aWO[5], $aDB Local $oExcel=_Excel_Open(FALSE, FALSE, FALSE, FALSE, FALSE) While $iCount <= $iMax ;! 0=Room 1=Last Name 2= Status 3=Rate Code 4=Tracking $aWO=_at_wo($iCount) $aDB=_at_db($aWO) Sleep(60) If $aWO[2]="INHOUSE" Then _at_Init($aWO, $aDB) EndIf Sleep(1000) $iCount=$iCount+1 Sleep(1000) WEnd Func _at_Init($aWO, $aDB) ;~ Script Initilization _at_Modify($aWO, $aDB, $iCount) EndFunc Func _at_wo($iCount) Local $lfRoom $lfRoom=18+(4*$iCount) Local $oWorkbook=_Excel_BookOpen($oExcel, @ScriptDir&"\mktsegvl.xls") Local $iRoom=_Excel_RangeRead($oWorkbook, DEFAULT, "A"&$lfRoom, 3, TRUE) ;! $sName[0]=Last Name $sName[1]=First Name Local $sName=StringSplit(_Excel_RangeRead($oWorkbook, DEFAULT, "B"&$lfRoom, 3, TRUE),"/",2) Local $sStatus=_Excel_RangeRead($oWorkbook, DEFAULT, "D"&$lfRoom, 3, TRUE) Local $sRate=_Excel_RangeRead($oWorkbook, DEFAULT, "H"&$lfRoom, 3, TRUE) Local $sTracking=_Excel_RangeRead($oWorkbook, DEFAULT, "J"&$lfRoom, 3, TRUE) Local $aReturn[5] $aReturn[0]=$iRoom $aReturn[1]=$sName[0] $aReturn[2]=$sStatus $aReturn[3]=$sRate $aReturn[4]=$sTracking Return $aReturn _Excel_BookClose($oWorkbook, FALSE) WinWaitClose("[CLASS:Excel]") $aReturn=0 EndFunc Func _at_db($aWO) Local $oWorkbook=_Excel_BookOpen($oExcel, @ScriptDir&"\db.xlsx") Local $aTracking=_Excel_RangeFind($oWorkbook, $aWo[3], "A:A", Default, Default, False) Local $sTrade=$aTracking[0][2] Local $sTracking=_Excel_RangeRead($oWorkbook, DEFAULT, StringReplace($sTrade, "A", "B"), 3, TRUE) Return $sTracking _Excel_BookClose($oWorkbook, FALSE) WinWaitClose("[CLASS:Excel]") $aTracking=0 EndFunc Func _at_Record($aWO, $aDB, $iCount) If NOT ProcessExists("Notepad.exe") Then Run("notepad.exe",@ScriptDir) EndIf Sleep(60) If NOT WinActive("[CLASS:Notepad]") Then WinActivate("[CLASS:Notepad]") WinWaitActive("[CLASS:Notepad]") ;~ Else ;~ If WinActive("Untitled - Notepad") Then ;~ ;~ Do Nothing For Now ;~ EndIf EndIf Sleep(60) Send($iCount+1&"|Rm "&$aWO[0]&" "&$aWO[1]&" "&$aWO[3]&" "&$aDB) Sleep(60) Send("{ENTER}") Sleep(60) 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 EndIf ;~ _at_Record($aWO, $aDB, $iCount) 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(500) Send("{TAB}") Sleep(500) Send($aWO[1]) Sleep(500) 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 ;~ ;~ SetError(2,1) ;~ MsgBox(0, "Error "&@error&"/"&@extended, "Error generated @ _at_Modify. Script unable to verify room opened. Please return to search screen and try script again.") ;~ Exit ;~ 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") WinWaitActive($soConfirm,"",10) If NOT WinExists($soConfirm) Then SetError(2,1) MsgBox(0, "Error "&@error&"/"&@extended, "Error generated @ _at_Modify. Script unable to detect save-confirmation. Please return to search screen and try script again.") Exit EndIf EndIf If WinExists($soConfirm) Then WinActivate($soConfirm) WinWaitActive($soConfirm) Sleep(60) Send("{ENTER}") Sleep(60) EndIf EndFunc