Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #region ;**** Directives created by AutoIt3Wrapper_GUI ****
- #AutoIt3Wrapper_icon=..\SaniMotionInstall\OxidGlas Icon 17.ico
- #AutoIt3Wrapper_outfile=SaniMotion.exe
- #AutoIt3Wrapper_Res_Description=SaniMotion
- #AutoIt3Wrapper_Res_Fileversion=1.0.0.4
- #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=p
- #AutoIt3Wrapper_Res_Language=1033
- #AutoIt3Wrapper_Run_Tidy=y
- #AutoIt3Wrapper_Run_cvsWrapper=y
- #endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
- #cs ----------------------------------------------------------------------------
- AutoIt Version: 3.3.0.0
- Author: Bill Hall
- Script Function:
- SaniMotion - Gives macro Function to the F1 - F11 keyz
- Sanitation Program Automation Project
- 28 February 2010 Started work on SaniMotion_beta
- 28 April 2010 Removed beta, version 1.0.0.3
- #ce ----------------------------------------------------------------------------
- #include<Date.au3>
- #include<Excel.au3>
- #include<IE.au3>
- #include<WindowsConstants.au3>
- #include<GuiConstants.au3>
- #include<File.au3>
- #include<ButtonConstants.au3>
- #include<EditConstants.au3>
- #include<StaticConstants.au3>
- #include<Array.au3>
- #include<Misc.au3>
- HotKeySet("{F1}", "_help")
- HotKeySet("{F2}", "_datacruncher");Datacruncher
- HotKeySet("{F3}", "_tll") ;Truck Load List
- HotKeySet("{F4}", "_sanirecord") ;Sanitation Record
- HotKeySet("{F5}", "_flash"); Splash Screen eyecandy
- HotKeySet("{F6}", "_saniprotocol");Sanitation Process Protocol
- HotKeySet("{F7}", "_f7");Label Printer
- HotKeySet("{F8}", "_f8") ;TLL Counter -1
- HotKeySet("{F9}", "_f9") ;TLL Counter +1
- HotKeySet("{F10}", "_f10") ;TLL Counter Show Count
- HotKeySet("{F11}", "_f11") ;
- Global $iBatch = String(@MDAY & @MON & @YEAR & @HOUR & @MIN)
- If _Singleton("SaniMotion_1.0", 1) = 0 Then
- ; We know the script is already running. Let the user know.
- MsgBox(0, "SaniMotion_1.0", "This script is already running. Using multiple copies of this script at the same time is unsupported!")
- Exit
- EndIf
- If ProcessExists("DMS Helper1.4.exe") Then
- MsgBox(0, "SaniMotion Error", "A Macro Script is already running please close it first and try again.")
- Exit
- EndIf
- Local $tllpdf = (@ScriptDir & "\TLL.pdf")
- ShellExecute('AcroRd32.exe', $tllpdf, "", "", @SW_MINIMIZE)
- WinWait("TLL.pdf")
- Local $sanirecord = (@ScriptDir & "\sanirecord.pdf")
- ShellExecute('AcroRd32.exe', $sanirecord, "", "", @SW_MINIMIZE)
- WinWait("sanirecord.pdf")
- Local $saniproto = (@ScriptDir & "\sani_protocol.pdf")
- ShellExecute('AcroRd32.exe', $saniproto, "", "", @SW_MINIMIZE)
- WinWait("sani_protocol.pdf")
- ;Splash===================================================================================================>>>
- $splash = @ScriptDir & "\SaniMotion.jpg"
- $hwnd = GUICreate("", 600, 400, -1, -1, $WS_POPUP)
- GUICtrlCreatePic($splash, 0, 0, 600, 400)
- DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00080000);fade-in
- GUISetState()
- Sleep(850);View picture
- DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00090000);fade-out
- ;Splash===================================================================================================>>>
- While 1
- Sleep(28800)
- WEnd
- ;F1
- Func _help() ;Help
- $HelpPath = _PathFull(@ScriptDir & "\help.chm")
- ShellExecute($HelpPath)
- EndFunc ;==>_help
- ;F2
- Func _datacruncher() ;Datacruncher
- $iBatch = String(@MDAY & @MON & @YEAR & @HOUR & @MIN)
- ;Splash================================================================>>>
- $splash = @ScriptDir & "\datacruncher.jpg"
- $hwnd = GUICreate("", 600, 200, -1, -1, $WS_POPUP)
- GUICtrlCreatePic($splash, 0, 0, 600, 200)
- DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00080000);fade-in
- GUISetState()
- Sleep(800);View picture
- DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00090000);fade-out
- ;Splash================================================================>>>
- Dim $aRecords
- Local $var3
- Local $aRecords
- ;Step 1. Read data from text file produced by scanner
- $message = "Choose txt file with Serial Numbers"
- $var3 = FileOpenDialog($message, @DesktopDir & "\", "Text (*.txt;*.csv)", 1)
- If @error Then
- ;MsgBox(4096,"","No File(s) chosen")
- Else
- $var3 = StringReplace($var3, "|", @CRLF)
- ;MsgBox(4096, "", "You chose " & $var3)
- EndIf
- ;Step 2. Send to Array - $aRecords
- $cols = UBound($aRecords, 1)
- If Not _FileReadToArray($var3, $aRecords) Then
- MsgBox(4096, "Error", " Error reading log to Array error:" & @error)
- Return 0
- EndIf
- ;Step 3. Open "Column Splitter" - Send $aRecords - Split Columns to C & D
- BlockInput(1)
- $sFilePath1 = @ScriptDir & "\column_splitter.xlsm" ;This file should already exist
- $oExcel = _ExcelBookOpen($sFilePath1)
- _ExcelWriteArray($oExcel, 1, 1, $aRecords, 1)
- Send("^h")
- ;Step 4. Read new Split columns into an Array "$aArray"
- $aArray = _ExcelReadSheetToArray($oExcel, 2, 3, 0, 2) ;Starting on the 2nd Row and 3rd Column All Rows(0) and 2 columns
- $cols = UBound($aRecords, 1)
- ConsoleWrite("$cols = " & $cols & @CRLF)
- ;_ArrayDisplay($aArray)
- _ExcelBookClose($oExcel, 0, 0)
- ;Step 5. Write new 2 column array to excel workbook "formatcell.xlsm"
- $sFilePath1 = @ScriptDir & "\formatcell.xlsm" ;This file should already exist
- $oExcel = _ExcelBookOpen($sFilePath1)
- _ExcelWriteSheetFromArray($oExcel, $aArray, 1, 1, 1, 1)
- ;Step 6. Add a row of position numbers to C:1 - that equals the number of positions.
- $j = $cols / 2
- For $i = 1 To $j ;Loop
- _ExcelWriteCell($oExcel, $i, $i, 3) ;Write to the Cell
- Next
- _ExcelBookSaveAs($oExcel, @DesktopDir & "\" & $iBatch, "xls")
- If Not @error Then MsgBox(0, "Success", "File was Saved!", 3)
- _ExcelBookClose($oExcel, 1, 0) ;This method will save then Close the file, without any of the normal prompts, regardless of changes
- BlockInput(0)
- EndFunc ;==>_datacruncher
- ;F3
- Func _tll() ;Truck Load List
- Local $tllpdf = (@ScriptDir & "\TLL.pdf")
- Local $sCellValue, $sCellValue1, $sCellValue2, $Menustate
- BlockInput(1)
- ;Splash================================================================>>>
- $splash = @ScriptDir & "\tll.jpg"
- $hwnd = GUICreate("", 600, 200, -1, -1, $WS_POPUP)
- GUICtrlCreatePic($splash, 0, 0, 600, 200)
- DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00080000);fade-in
- GUISetState()
- ;Sleep(800);View picture
- DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00090000);fade-out
- ;Splash================================================================>>>
- BlockInput(0)
- #region start code that opens the excel file with serial numbers//saved from barcode scanner====================>>>
- If WinExists("Microsoft Excel") Then
- MsgBox(16, "Open Workbook Identified", "Please close any open Excel Workbooks" & @CRLF & "Function will continue after closing", 2)
- EndIf
- While WinExists("Microsoft Excel")
- Sleep(100)
- WEnd
- $message = "Select Workbook"
- $var = FileOpenDialog($message, @DesktopDir & "\", "Excel (*.xls;*.xlsx)", 1)
- If @error Then
- MsgBox(4096, "", "No File Selected - Exiting")
- Return 0
- Else
- $var = StringReplace($var, "|", @CRLF)
- EndIf
- $oExcel = _ExcelBookOpen($var)
- Sleep(100)
- WinSetState("Microsoft Excel", "", @SW_MINIMIZE)
- Sleep(100)
- #endregion start code that opens the excel file with serial numbers//saved from barcode scanner====================>>>
- $aArray = _ExcelReadSheetToArray($oExcel) ;Using Default Parameters
- ;_ArrayDisplay($aArray, "Array using Default Parameters")
- $rows = UBound($aArray)
- ConsoleWrite("$rows=" & $rows & @CRLF)
- $stop = $rows - 1
- #region Facility Selector ======================================================================>>>
- $msg = ""
- $gui = GUICreate("Ship to:", 220, 120) ; creates a centered dialog box
- $button_ok = GUICtrlCreateButton("Send", 10, 80, 100)
- $button_cancel = GUICtrlCreateButton("Cancel", 110, 80, 100)
- $Combo_1 = GUICtrlCreateCombo("Select", 10, 40, 200, 21)
- GUICtrlSetData($Combo_1, "|Grunstadt|Stuttgart|Mainz|Bitburg|Schinnen|U.K.|Chievres|Schweinfurt|Vilseck|Illesheim|Italy-Vicenza|Italy-Aviano|")
- GUICtrlSetData(-1, "Grunstadt")
- GUICtrlCreateLabel("Select Receiving Facility", 10, 10)
- GUISetState(@SW_SHOW)
- While 1
- $msg = GUIGetMsg()
- Select
- Case $msg = $button_cancel Or $msg = $GUI_EVENT_CLOSE
- GUIDelete()
- Return 0
- Case $msg = $button_ok
- $Menustate = GUICtrlRead($Combo_1)
- If $Menustate = "Grunstadt" Then
- $var1 = "1342560"
- $var2 = "7014290600"
- ExitLoop
- EndIf
- If $Menustate = "Stuttgart" Then
- $var1 = "1342570"
- $var2 = "7014291800"
- ExitLoop
- EndIf
- If $Menustate = "Mainz" Then
- $var1 = "1342561"
- $var2 = "7014290900"
- ExitLoop
- EndIf
- If $Menustate = "Bitburg" Then
- $var1 = "1342562"
- $var2 = "7014291000"
- ExitLoop
- EndIf
- If $Menustate = "Schinnen" Then
- $var1 = "1342565"
- $var2 = "7014291300"
- ExitLoop
- EndIf
- If $Menustate = "U.K." Then
- $var1 = "1342563"
- $var2 = "7014291100"
- ExitLoop
- EndIf
- If $Menustate = "Chievres" Then
- $var1 = "1342566"
- $var2 = "7014291400"
- ExitLoop
- EndIf
- If $Menustate = "Schweinfurt" Then
- $var1 = "1342568"
- $var2 = "7014291600"
- ExitLoop
- EndIf
- If $Menustate = "Vilseck" Then
- $var1 = "1342567"
- $var2 = "7014291500"
- ExitLoop
- EndIf
- If $Menustate = "Illesheim" Then
- $var1 = "1342569"
- $var2 = "7014291700"
- ExitLoop
- EndIf
- If $Menustate = "Italy-Vicenza" Then
- $var1 = "1342571"
- $var2 = "7014291900"
- ExitLoop
- EndIf
- If $Menustate = "Italy-Aviano" Then
- $var1 = "1342572"
- $var2 = "7014292000"
- ExitLoop
- EndIf
- EndSelect
- WEnd
- GUIDelete()
- #endregion Facility Selector ======================================================================>>>
- ;start-read number from tllcount.txt ===============================================>>>
- $tllPath = _PathFull(@ScriptDir & "\tllcount.txt")
- ConsoleWrite("$tllPath=" & $tllPath & @CRLF)
- $chars = FileReadLine($tllPath, 1)
- ;end read number from tllcount.txt =================================================>>>
- ;End of user interface, begin typing TLL ===========================================>>>
- ;Open sanirecord.pdf / maximize / zoom to fit page ===================>>>
- ShellExecute('AcroRd32.exe', $tllpdf)
- WinWaitActive("TLL.pdf")
- WinSetState("TLL.pdf", "", @SW_MAXIMIZE)
- Sleep(300)
- Send("^0")
- ;Open sanirecord.pdf / maximize / zoom to fit page ===================>>>
- ;Fill in Header Information=========================================>>>
- Sleep(3500)
- Send($chars);enters countup # from tllcount.txt
- Sleep(700)
- Send("+{TAB}");backs up one to title position
- Sleep(700)
- Send($Menustate);types receiving fac
- Sleep(700)
- Send("{TAB 2}")
- Sleep(700)
- Send($var1);aim # from selected facility
- Sleep(700)
- Send("{TAB}")
- Sleep(700)
- Send($var2);facility # from selected fac.
- Sleep(700)
- Send("{TAB}")
- Sleep(700)
- Send("1349995");aim # Sani
- Sleep(700)
- Send("{TAB}")
- Sleep(800)
- Send("7014292200");fac. # Sani
- Sleep(600)
- Send("{TAB 3}")
- Sleep(700)
- Send(_NowDate());date of today
- Sleep(700)
- Send("{TAB}")
- Sleep(700)
- ;Fill in Header Information=========================================>>>
- ;Cooler Serial # Transfer ==========================================>>>
- For $iCount = 1 To 25 ;position counter
- ;$sCellValue1 = _ExcelReadCell($oExcel, $iCount, 3) ;Sends Position Counter integer
- Send($iCount)
- Sleep(700)
- Send("{TAB}")
- Sleep(700)
- $sCellValue = _ExcelReadCell($oExcel, $iCount, 1);reads from selected Excel file 1 pos @ a time
- If $sCellValue = "" Then ExitLoop
- Send($sCellValue)
- Sleep(700)
- Send("{SPACE}")
- Sleep(700)
- $sCellValue2 = _ExcelReadCell($oExcel, $iCount, 2);reads from selected Excel file 1 pos @ a time
- Send($sCellValue2)
- Sleep(700)
- Send("{TAB 4}")
- Sleep(700)
- Send("1")
- Sleep(700)
- Send("{TAB}")
- Next
- ;end loop for serial # transfer
- Send("+{TAB}");when no more # to read from excel file, backup and del last position #
- Sleep(700)
- Send("{DEL}")
- Sleep(2000)
- ;Cooler Serial # Transfer ==========================================>>>
- ;Print Message Box==================================================>>>
- $msg = ""
- $gui = GUICreate("Print TLL", 220, 120) ; creates a centered dialog box
- $button_ok = GUICtrlCreateButton("Print", 10, 80, 100)
- $button_cancel = GUICtrlCreateButton("Cancel", 110, 80, 100)
- $Combo_1 = GUICtrlCreateCombo("Select", 10, 40, 200, 21)
- GUICtrlSetData($Combo_1, "|6 Copies|5 Copies|4 Copies|3 Copies|2 Copies|1 Copies|")
- GUICtrlSetData(-1, "3 Copies")
- GUICtrlCreateLabel("How many copies?", 10, 10)
- GUISetState(@SW_SHOW)
- While 1
- $msg = GUIGetMsg()
- Select
- Case $msg = $button_cancel Or $msg = $GUI_EVENT_CLOSE
- ExitLoop
- GUIDelete()
- Case $msg = $button_ok
- $Menustate = GUICtrlRead($Combo_1)
- If $Menustate = "6 Copies" Then
- WinActivate("TLL.pdf")
- Send("^p")
- Send("!u")
- Send("!c")
- Send("6")
- Sleep(1000)
- Send("{ENTER}")
- ExitLoop
- EndIf
- If $Menustate = "5 Copies" Then
- WinActivate("TLL.pdf")
- Send("^p")
- Send("!u")
- Send("!c")
- Send("5")
- Sleep(1000)
- Send("{ENTER}")
- ExitLoop
- EndIf
- If $Menustate = "4 Copies" Then
- WinActivate("TLL.pdf")
- Send("^p")
- Send("!u")
- Send("!c")
- Send("4")
- Sleep(1000)
- Send("{ENTER}")
- ExitLoop
- EndIf
- If $Menustate = "3 Copies" Then
- WinActivate("TLL.pdf")
- Send("^p")
- Send("!u")
- Send("!c")
- Send("3")
- Sleep(1000)
- Send("{ENTER}")
- ExitLoop
- EndIf
- If $Menustate = "2 Copies" Then
- WinActivate("TLL.pdf")
- Send("^p")
- Send("!u")
- Send("!c")
- Send("2")
- Sleep(1000)
- Send("{ENTER}")
- ExitLoop
- EndIf
- If $Menustate = "1 Copies" Then
- WinActivate("TLL.pdf")
- Send("^p")
- Send("!u")
- Send("!c")
- Send("1")
- Sleep(1000)
- Send("{ENTER}")
- ExitLoop
- EndIf
- EndSelect
- WEnd
- GUIDelete()
- ;Print Message Box==================================================>>>
- Sleep(1000)
- WinActivate("TLL.pdf")
- WinWaitActive("TLL.pdf")
- Sleep(3000)
- WinKill("TLL.pdf")
- Sleep(1000)
- ;Add (1) to TLL Count txt file======================================>>>
- $oldcount = FileReadLine(@ScriptDir & "\tllcount.txt", 1)
- $result = StringCompare($oldcount, "999")
- If $result = 0 Then
- $newcount = 0
- Else
- $newcount = $oldcount + 1
- ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $newcount = ' & $newcount & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
- EndIf
- $rc = _FileWriteToLine(@ScriptDir & "\tllcount.txt", 1, String($newcount), 1)
- ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $rc = ' & $rc & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
- ;Add (1) to TLL Count txt file======================================>>>
- _ExcelBookClose($oExcel)
- EndFunc ;==>_tll
- ;F4
- Func _sanirecord() ;Sanitation Record
- Local $sanirecord = (@ScriptDir & "\sanirecord.pdf")
- BlockInput(1)
- ;Splash================================================================>>>
- $splash = @ScriptDir & "\sanirecord.jpg"
- $hwnd = GUICreate("", 600, 200, -1, -1, $WS_POPUP)
- GUICtrlCreatePic($splash, 0, 0, 600, 200)
- DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00080000);fade-in
- GUISetState()
- ;Sleep(800);View picture
- DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00090000);fade-out
- ;Splash================================================================>>>
- BlockInput(0)
- #region start code that opens the excel file with serial numbers//saved from barcode scanner====================>>>
- If WinExists("Microsoft Excel") Then
- MsgBox(16, "Open Workbook Identified", "Please close any open Excel Workbooks" & @CRLF & "Function will continue after closing", 2)
- EndIf
- While WinExists("Microsoft Excel")
- Sleep(100)
- WEnd
- $message = "Select Workbook"
- $var = FileOpenDialog($message, @DesktopDir & "\", "Excel (*.xls;*.xlsx)", 1)
- If @error Then
- MsgBox(4096, "", "No File Selected - Exiting")
- Return 0
- Else
- $var = StringReplace($var, "|", @CRLF)
- EndIf
- $oExcel = _ExcelBookOpen($var)
- Sleep(100)
- WinSetState("Microsoft Excel", "", @SW_MINIMIZE)
- Sleep(100)
- #endregion start code that opens the excel file with serial numbers//saved from barcode scanner====================>>>
- $aArray = _ExcelReadSheetToArray($oExcel) ;Using Default Parameters
- ;_ArrayDisplay($aArray, "Array using Default Parameters")
- $rows = UBound($aArray)
- ConsoleWrite("$rows=" & $rows & @CRLF)
- $stop = $rows - 1
- For $c = 1 To $stop Step 4 ;===>>For/Next - Repeater ...After form filler 4 times goes to next set
- BlockInput(1)
- ;Open sanirecord.pdf / maximize / zoom to fit page ===================>>>
- ShellExecute('AcroRd32.exe', $sanirecord)
- WinWaitActive("sanirecord.pdf")
- WinSetState("sanirecord.pdf", "", @SW_MAXIMIZE)
- Sleep(300)
- Send("^0")
- ;Open sanirecord.pdf / maximize / zoom to fit page ===================>>>
- ;Begin - filling in form the 4 forms on sanirecord.pdf ==========================>>>
- Sleep(4500)
- Send("+{TAB}")
- Sleep(700)
- For $iCount = $c To $c + 4 - 1 ;=====>>> Repeates the form filler 4 times
- $sCellValue1 = _ExcelReadCell($oExcel, $iCount, 3) ;Sends Position Counter integer
- Send($sCellValue1)
- Sleep(700)
- Send("{TAB}")
- Sleep(700)
- $sCellValue = _ExcelReadCell($oExcel, $iCount, 1) ;Sends Cooler #
- If $sCellValue = "" Then ExitLoop
- ConsoleWrite("$c=" & $c & @CRLF)
- Send($sCellValue)
- Sleep(700)
- Send("{TAB}")
- Sleep(700)
- Send("Oasis")
- Sleep(700)
- Send("{TAB}")
- Sleep(700)
- $sCellValue2 = _ExcelReadCell($oExcel, $iCount, 2) ;Sends Reg or H&C
- Send($sCellValue2)
- Sleep(700)
- Send("{TAB}")
- Sleep(700)
- Send("Grunstadt")
- Sleep(300)
- Send("{TAB}")
- Sleep(700)
- Send(_NowDate())
- Sleep(700)
- Send("{TAB}")
- Sleep(700)
- Next
- ;End - filling in form the 4 forms on sanirecord.pdf ==========================>>>
- ;Print PDF =============================================================>>>
- WinActivate("sanirecord.pdf")
- WinWaitActive("sanirecord.pdf")
- Sleep(300)
- Send("^p")
- Sleep(300)
- WinWait("Print", "", 5)
- WinWaitActive("Print")
- Send("{ENTER}") ;cancels print for testing purposes============>>>
- ;ControlClick("Print", "Rotate and Center", "[CLASS:Button; INSTANCE:17]")
- Sleep(500)
- WinActivate("sanirecord.pdf")
- WinWaitActive("sanirecord.pdf")
- Sleep(300)
- WinKill("sanirecord.pdf")
- Sleep(1000)
- ;Print PDF ==============================================================>>>
- If $sCellValue = "" Then
- ExitLoop
- EndIf
- Next
- _ExcelBookClose($oExcel)
- BlockInput(0)
- EndFunc ;==>_sanirecord
- ;F5
- Func _flash() ;Splash
- $iBatch = String(@MDAY & @MON & @YEAR & @HOUR & @MIN)
- ConsoleWrite("$iBatch=" & $iBatch & @CRLF)
- MsgBox(4096, "iBatch", $iBatch, 1)
- ;~ BlockInput(1)
- ;~ $splash = "SaniMotion.jpg"
- ;~ $hwnd = GUICreate("", 600, 400, -1, -1, $WS_POPUP)
- ;~ GUICtrlCreatePic($splash, 0, 0, 600, 400)
- ;~ DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00080000);fade-in
- ;~ GUISetState()
- ;~ Sleep(2000);View picture
- ;~ DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00090000);fade-out
- ;~ BlockInput(0)
- EndFunc ;==>_flash
- ;F6
- Func _saniprotocol() ;SaniProtocol
- Local $saniproto = (@ScriptDir & "\sani_protocol.pdf")
- BlockInput(1)
- ;Splash================================================================>>>
- $splash = @ScriptDir & "\spp.jpg"
- $hwnd = GUICreate("", 600, 200, -1, -1, $WS_POPUP)
- GUICtrlCreatePic($splash, 0, 0, 600, 200)
- DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00080000);fade-in
- GUISetState()
- ;Sleep(800);View picture
- DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00090000);fade-out
- ;Splash================================================================>>>
- BlockInput(0)
- #region start code that opens the excel file with serial numbers//saved from barcode scanner------------------------
- If WinExists("Microsoft Excel") Then
- MsgBox(16, "Open Workbook Identified", "Please close any open Excel Workbooks" & @CRLF & "Function will continue after closing", 1.5)
- EndIf
- While WinExists("Microsoft Excel")
- Sleep(100)
- WEnd
- $message = "Select Workbook"
- $var = FileOpenDialog($message, @DesktopDir & "\", "Excel (*.xls;*.xlsx)", 1)
- If @error Then
- MsgBox(4096, "", "No File Selected - Exiting")
- Return 0
- BlockInput(1)
- Else
- $var = StringReplace($var, "|", @CRLF)
- EndIf
- $oExcel = _ExcelBookOpen($var)
- Sleep(100)
- WinSetState("Microsoft Excel", "", @SW_MINIMIZE)
- Sleep(100)
- #endregion start code that opens the excel file with serial numbers//saved from barcode scanner------------------------
- $aArray = _ExcelReadSheetToArray($oExcel) ;Using Default Parameters
- ;_ArrayDisplay($aArray, "Array using Default Parameters")
- $rows = UBound($aArray)
- ConsoleWrite("$rows=" & $rows & @CRLF)
- $stop = $rows - 1
- For $c = 1 To $stop Step 5 ;===>>For/Next - Repeater ...After form filler 4 times goes to next set
- BlockInput(1)
- ;Open saniprotocol.pdf / maximize / zoom to fit page ===>
- ShellExecute('AcroRd32.exe', $saniproto)
- WinWaitActive("sani_protocol.pdf")
- WinSetState("sani_protocol.pdf", "", @SW_MAXIMIZE)
- Sleep(300)
- Send("^0")
- ;Open saniprotocol.pdf / maximize / zoom to fit page ===>
- ;Begin - filling in form the 5 forms on saniprotocol.pdf ==========================>>>
- Sleep(4000)
- Send("{TAB}")
- Sleep(300)
- Send($iBatch)
- Sleep(300)
- Send("{TAB}")
- Sleep(300)
- For $iCount = $c To $c + 5 - 1 ;=====>>> Repeates the form filler 5 times
- $sCellValue1 = _ExcelReadCell($oExcel, $iCount, 3)
- Sleep(300)
- Send($sCellValue1) ; send position counter
- Sleep(300)
- Send("{TAB}")
- Sleep(300)
- $sCellValue2 = _ExcelReadCell($oExcel, $iCount, 1);reads from selected Excel file 1 pos @ a time
- If $sCellValue2 = "" Then ExitLoop
- Send($sCellValue2) ;sends cooler #
- Sleep(300)
- Send("{TAB}")
- Sleep(300)
- $sCellValue3 = _ExcelReadCell($oExcel, $iCount, 2)
- Send($sCellValue3) ;sends H&C or REG
- Sleep(300)
- Send("{TAB}")
- Sleep(300)
- Send(_NowDate())
- Sleep(300)
- Send("{TAB}")
- Sleep(300)
- Send(_NowDate())
- Sleep(300)
- Send("{TAB}")
- Sleep(300)
- Next
- ;End - filling in form the 5 forms on saniprotocol.pdf ==========================>>>
- ;Print PDF ======================================================================>>>
- WinActivate("sani_protocol.pdf")
- WinWaitActive("sani_protocol.pdf")
- Sleep(300)
- Send("^p")
- Sleep(300)
- WinWait("Print", "", 5)
- WinWaitActive("Print")
- Send("{ENTER}") ;cancels print for testing purposes============>>>
- ;ControlClick("Print", "Rotate and Center", "[CLASS:Button; INSTANCE:17]")
- Sleep(500)
- WinActivate("sani_protocol.pdf")
- WinWaitActive("sani_protocol.pdf")
- Sleep(300)
- WinKill("sani_protocol.pdf")
- Sleep(1000)
- ;Print PDF ======================================================================>>>
- If $sCellValue2 = "" Then
- ExitLoop
- EndIf
- Next
- _ExcelBookClose($oExcel)
- BlockInput(0)
- EndFunc ;==>_saniprotocol
- ;F7
- Func _f7()
- BlockInput(1)
- $splash = @ScriptDir & "\labelprinter.jpg"
- $hwnd = GUICreate("", 600, 200, -1, -1, $WS_POPUP)
- GUICtrlCreatePic($splash, 0, 0, 600, 200)
- DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00080000);fade-in
- GUISetState()
- Sleep(1500);View picture
- DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00090000);fade-out
- Local $Input1, $Input2, $Button1, $Button2, $nMsg
- $nMsg = 0
- BlockInput(0)
- #region ### START Koda GUI section ### Form=
- $Form1 = GUICreate("Print Label", 381, 221, 192, 124)
- $Input1 = GUICtrlCreateInput("Cooler#", 120, 96, 121, 21)
- $Input2 = GUICtrlCreateInput("Model", 120, 128, 121, 21)
- $Button1 = GUICtrlCreateButton("Print", 88, 176, 75, 25, $WS_GROUP)
- $Button2 = GUICtrlCreateButton("Cancel", 200, 176, 75, 25, $WS_GROUP)
- $Label1 = GUICtrlCreateLabel("Prints Waterproof Labels for Coolers on the fly.", 24, 16, 332, 57)
- GUISetState(@SW_SHOW)
- #endregion ### END Koda GUI section ###
- While 1
- $nMsg = GUIGetMsg()
- Select
- Case $nMsg = $Button2 Or $nMsg = $GUI_EVENT_CLOSE
- GUIDelete()
- Return 0
- Case $nMsg = $Button1
- $coolernr = GUICtrlRead($Input1)
- $model = GUICtrlRead($Input2)
- ExitLoop
- EndSelect
- WEnd
- GUIDelete()
- MsgBox(4096, "Printing Label", $coolernr & @CRLF & $model, 1)
- Local $pte
- ShellExecute(@ProgramFilesDir & "\Brother\Ptedit50\Ptedit50.exe")
- $pte = WinGetHandle("Ptedit50.exe", "")
- WinWaitActive($pte)
- ;Send("{ENTER}") ;closes the missing driver warning
- Sleep(3000)
- ;WinSetState($pte, "", @SW_HIDE)
- Send("^o")
- Sleep(300)
- Send("replacementlabel-film.lbx")
- Sleep(300)
- Send("{ENTER}")
- Sleep(500)
- Send("{TAB}")
- Sleep(300)
- Send($model)
- Sleep(300)
- Send("{TAB}")
- Sleep(300)
- Send($coolernr)
- Sleep(300)
- ControlClick("P-touch Editor", "", "[CLASS:Button; INSTANCE:19]")
- Sleep(700)
- WinClose($pte)
- EndFunc ;==>_f7
- ;F8
- Func _f8() ;TLL Counter -1
- $oldcount = FileReadLine(@ScriptDir & "\tllcount.txt", 1)
- $result = StringCompare($oldcount, "999")
- If $result = 0 Then
- ;$newcount = 0
- Else
- $newcount = $oldcount - 1
- ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $newcount = ' & $newcount & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
- EndIf
- $rc = _FileWriteToLine(@ScriptDir & "\tllcount.txt", 1, String($newcount), 1)
- ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $rc = ' & $rc & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
- MsgBox(0, "TLL", "-" & $rc, 1)
- EndFunc ;==>_f8
- ;F9
- Func _f9() ;TLL Counter +1
- ;start code to add (1) to counter for next TLL----------------------------------------------------
- $oldcount = FileReadLine(@ScriptDir & "\tllcount.txt", 1)
- $result = StringCompare($oldcount, "999")
- If $result = 0 Then
- $newcount = 0
- Else
- $newcount = $oldcount + 1
- ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $newcount = ' & $newcount & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
- EndIf
- $rc = _FileWriteToLine(@ScriptDir & "\tllcount.txt", 1, String($newcount), 1)
- ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $rc = ' & $rc & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
- MsgBox(0, "TLL", "+" & $rc, 1)
- ;end code to add (1) to counter for next TLL------------------------------------------------------
- EndFunc ;==>_f9
- ;F10
- Func _f10() ;TLL Counter Show Count
- ;start-read number from tllcount.txt----------------------------------------------------------------------------------
- $tllPath = _PathFull(@ScriptDir & "\tllcount.txt")
- $chars = FileReadLine($tllPath, 1)
- ;end read number from tllcount.txt------------------------------------------------------------------------------------
- MsgBox(64, "TLL Counter", "Tll Count is now:" & @CRLF & _
- @TAB & $chars, 2)
- EndFunc ;==>_f10
- ;F11
- Func _f11() ;====>>> Scanner Upload
- $iBatch = String(@MDAY & @MON & @YEAR & @HOUR & @MIN)
- BlockInput(1)
- ;Splash================================================================>>>
- $splash = @ScriptDir & "\upload.jpg"
- $hwnd = GUICreate("", 600, 200, -1, -1, $WS_POPUP)
- GUICtrlCreatePic($splash, 0, 0, 600, 200)
- DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00080000);fade-in
- GUISetState()
- Sleep(800);View picture
- DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00090000);fade-out
- ;Splash================================================================>>>
- BlockInput(0)
- ShellExecute("C:\Program Files\BCP7000Read\BCP7000Read.exe")
- BlockInput(1)
- WinWaitActive("Read Data via Serial Port")
- ControlClick("Read Data via Serial Port", "Save received data to file", "[CLASS:WindowsForms10.EDIT.app.0.378734a; INSTANCE:2]", "Right")
- ControlSend("Read Data via Serial Port", "Save received data to file", "[CLASS:WindowsForms10.EDIT.app.0.378734a; INSTANCE:2]", "a")
- ControlSend("Read Data via Serial Port", "Save received data to file", "[CLASS:WindowsForms10.EDIT.app.0.378734a; INSTANCE:2]", @DesktopDir)
- Send("{TAB}")
- ControlSend("Read Data via Serial Port", "Save received data to file", "[CLASS:WindowsForms10.EDIT.app.0.378734a; INSTANCE:1]", $iBatch & "." & "txt")
- ControlClick("Read Data via Serial Port", "Save received data to file", "[CLASS:WindowsForms10.BUTTON.app.0.378734a; INSTANCE:4]")
- WinWait("BCP7000Read", "OK", 1)
- ControlClick("BCP7000Read", "OK", "[CLASS:Button; INSTANCE:1]")
- Sleep(2000)
- ControlClick("Read Data via Serial Port", "Save received data to file", "[CLASS:WindowsForms10.BUTTON.app.0.378734a; INSTANCE:3]")
- BlockInput(0)
- EndFunc ;==>_f11
Advertisement
Add Comment
Please, Sign In to add comment