Hollowyearz

SaniMotion_1.0

Nov 28th, 2013
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 29.00 KB | None | 0 0
  1. #region ;**** Directives created by AutoIt3Wrapper_GUI ****
  2. #AutoIt3Wrapper_icon=..\SaniMotionInstall\OxidGlas Icon 17.ico
  3. #AutoIt3Wrapper_outfile=SaniMotion.exe
  4. #AutoIt3Wrapper_Res_Description=SaniMotion
  5. #AutoIt3Wrapper_Res_Fileversion=1.0.0.4
  6. #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=p
  7. #AutoIt3Wrapper_Res_Language=1033
  8. #AutoIt3Wrapper_Run_Tidy=y
  9. #AutoIt3Wrapper_Run_cvsWrapper=y
  10. #endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
  11. #cs ----------------------------------------------------------------------------
  12.     AutoIt Version: 3.3.0.0
  13.     Author:         Bill Hall
  14.    
  15.     Script Function:
  16.     SaniMotion - Gives macro Function to the F1 - F11 keyz
  17.     Sanitation Program Automation Project
  18.    
  19.     28 February 2010 Started work on SaniMotion_beta
  20.     28 April 2010 Removed beta, version 1.0.0.3
  21.    
  22. #ce ----------------------------------------------------------------------------
  23. #include<Date.au3>
  24. #include<Excel.au3>
  25. #include<IE.au3>
  26. #include<WindowsConstants.au3>
  27. #include<GuiConstants.au3>
  28. #include<File.au3>
  29. #include<ButtonConstants.au3>
  30. #include<EditConstants.au3>
  31. #include<StaticConstants.au3>
  32. #include<Array.au3>
  33. #include<Misc.au3>
  34.  
  35.  
  36. HotKeySet("{F1}", "_help")
  37. HotKeySet("{F2}", "_datacruncher");Datacruncher
  38. HotKeySet("{F3}", "_tll") ;Truck Load List
  39. HotKeySet("{F4}", "_sanirecord") ;Sanitation Record
  40. HotKeySet("{F5}", "_flash"); Splash Screen eyecandy
  41. HotKeySet("{F6}", "_saniprotocol");Sanitation Process Protocol
  42. HotKeySet("{F7}", "_f7");Label Printer
  43. HotKeySet("{F8}", "_f8") ;TLL Counter  -1
  44. HotKeySet("{F9}", "_f9") ;TLL Counter  +1
  45. HotKeySet("{F10}", "_f10") ;TLL Counter Show Count
  46. HotKeySet("{F11}", "_f11") ;
  47.  
  48. Global $iBatch = String(@MDAY & @MON & @YEAR & @HOUR & @MIN)
  49.  
  50. If _Singleton("SaniMotion_1.0", 1) = 0 Then
  51.     ; We know the script is already running. Let the user know.
  52.     MsgBox(0, "SaniMotion_1.0", "This script is already running. Using multiple copies of this script at the same time is unsupported!")
  53.     Exit
  54. EndIf
  55.  
  56. If ProcessExists("DMS Helper1.4.exe") Then
  57.     MsgBox(0, "SaniMotion Error", "A Macro Script is already running please close it first and try again.")
  58.     Exit
  59. EndIf
  60. Local $tllpdf = (@ScriptDir & "\TLL.pdf")
  61. ShellExecute('AcroRd32.exe', $tllpdf, "", "", @SW_MINIMIZE)
  62. WinWait("TLL.pdf")
  63. Local $sanirecord = (@ScriptDir & "\sanirecord.pdf")
  64. ShellExecute('AcroRd32.exe', $sanirecord, "", "", @SW_MINIMIZE)
  65. WinWait("sanirecord.pdf")
  66. Local $saniproto = (@ScriptDir & "\sani_protocol.pdf")
  67. ShellExecute('AcroRd32.exe', $saniproto, "", "", @SW_MINIMIZE)
  68. WinWait("sani_protocol.pdf")
  69.  
  70.  
  71. ;Splash===================================================================================================>>>
  72. $splash = @ScriptDir & "\SaniMotion.jpg"
  73. $hwnd = GUICreate("", 600, 400, -1, -1, $WS_POPUP)
  74. GUICtrlCreatePic($splash, 0, 0, 600, 400)
  75. DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00080000);fade-in
  76. GUISetState()
  77. Sleep(850);View picture
  78. DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00090000);fade-out
  79. ;Splash===================================================================================================>>>
  80. While 1
  81.     Sleep(28800)
  82. WEnd
  83.  
  84. ;F1
  85. Func _help() ;Help
  86.  
  87.     $HelpPath = _PathFull(@ScriptDir & "\help.chm")
  88.  
  89.     ShellExecute($HelpPath)
  90.  
  91.  
  92. EndFunc   ;==>_help
  93.  
  94. ;F2
  95. Func _datacruncher() ;Datacruncher
  96.     $iBatch = String(@MDAY & @MON & @YEAR & @HOUR & @MIN)
  97.     ;Splash================================================================>>>
  98.     $splash = @ScriptDir & "\datacruncher.jpg"
  99.     $hwnd = GUICreate("", 600, 200, -1, -1, $WS_POPUP)
  100.     GUICtrlCreatePic($splash, 0, 0, 600, 200)
  101.     DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00080000);fade-in
  102.     GUISetState()
  103.     Sleep(800);View picture
  104.     DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00090000);fade-out
  105.     ;Splash================================================================>>>
  106.  
  107.     Dim $aRecords
  108.     Local $var3
  109.     Local $aRecords
  110.  
  111.     ;Step 1. Read data from text file produced by scanner
  112.     $message = "Choose txt file with Serial Numbers"
  113.  
  114.     $var3 = FileOpenDialog($message, @DesktopDir & "\", "Text (*.txt;*.csv)", 1)
  115.  
  116.     If @error Then
  117.         ;MsgBox(4096,"","No File(s) chosen")
  118.     Else
  119.         $var3 = StringReplace($var3, "|", @CRLF)
  120.         ;MsgBox(4096, "", "You chose " & $var3)
  121.     EndIf
  122.  
  123.     ;Step 2. Send to Array - $aRecords
  124.     $cols = UBound($aRecords, 1)
  125.     If Not _FileReadToArray($var3, $aRecords) Then
  126.         MsgBox(4096, "Error", " Error reading log to Array     error:" & @error)
  127.         Return 0
  128.     EndIf
  129.  
  130.     ;Step 3. Open "Column Splitter" - Send $aRecords - Split Columns to C & D
  131.     BlockInput(1)
  132.     $sFilePath1 = @ScriptDir & "\column_splitter.xlsm" ;This file should already exist
  133.     $oExcel = _ExcelBookOpen($sFilePath1)
  134.     _ExcelWriteArray($oExcel, 1, 1, $aRecords, 1)
  135.     Send("^h")
  136.  
  137.     ;Step 4. Read new Split columns into an Array "$aArray"
  138.     $aArray = _ExcelReadSheetToArray($oExcel, 2, 3, 0, 2) ;Starting on the 2nd Row and 3rd Column All Rows(0) and 2 columns
  139.     $cols = UBound($aRecords, 1)
  140.     ConsoleWrite("$cols = " & $cols & @CRLF)
  141.     ;_ArrayDisplay($aArray)
  142.     _ExcelBookClose($oExcel, 0, 0)
  143.  
  144.     ;Step 5. Write new 2 column array to excel workbook "formatcell.xlsm"
  145.     $sFilePath1 = @ScriptDir & "\formatcell.xlsm" ;This file should already exist
  146.     $oExcel = _ExcelBookOpen($sFilePath1)
  147.     _ExcelWriteSheetFromArray($oExcel, $aArray, 1, 1, 1, 1)
  148.  
  149.     ;Step 6. Add a row of position numbers to C:1 -  that equals the number of positions.
  150.     $j = $cols / 2
  151.  
  152.     For $i = 1 To $j ;Loop
  153.         _ExcelWriteCell($oExcel, $i, $i, 3) ;Write to the Cell
  154.     Next
  155.  
  156.     _ExcelBookSaveAs($oExcel, @DesktopDir & "\" & $iBatch, "xls")
  157.     If Not @error Then MsgBox(0, "Success", "File was Saved!", 3)
  158.     _ExcelBookClose($oExcel, 1, 0) ;This method will save then Close the file, without any of the normal prompts, regardless of changes
  159.  
  160.     BlockInput(0)
  161.  
  162. EndFunc   ;==>_datacruncher
  163.  
  164. ;F3
  165. Func _tll() ;Truck Load List
  166.     Local $tllpdf = (@ScriptDir & "\TLL.pdf")
  167.     Local $sCellValue, $sCellValue1, $sCellValue2, $Menustate
  168.     BlockInput(1)
  169.     ;Splash================================================================>>>
  170.     $splash = @ScriptDir & "\tll.jpg"
  171.     $hwnd = GUICreate("", 600, 200, -1, -1, $WS_POPUP)
  172.     GUICtrlCreatePic($splash, 0, 0, 600, 200)
  173.     DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00080000);fade-in
  174.     GUISetState()
  175.     ;Sleep(800);View picture
  176.     DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00090000);fade-out
  177.     ;Splash================================================================>>>
  178.     BlockInput(0)
  179.  
  180.     #region start code that opens the excel file with serial numbers//saved from barcode scanner====================>>>
  181.     If WinExists("Microsoft Excel") Then
  182.         MsgBox(16, "Open Workbook Identified", "Please close any open Excel Workbooks" & @CRLF & "Function will continue after closing", 2)
  183.     EndIf
  184.     While WinExists("Microsoft Excel")
  185.         Sleep(100)
  186.     WEnd
  187.     $message = "Select Workbook"
  188.     $var = FileOpenDialog($message, @DesktopDir & "\", "Excel (*.xls;*.xlsx)", 1)
  189.     If @error Then
  190.         MsgBox(4096, "", "No File Selected - Exiting")
  191.         Return 0
  192.  
  193.     Else
  194.         $var = StringReplace($var, "|", @CRLF)
  195.     EndIf
  196.     $oExcel = _ExcelBookOpen($var)
  197.     Sleep(100)
  198.     WinSetState("Microsoft Excel", "", @SW_MINIMIZE)
  199.     Sleep(100)
  200.     #endregion start code that opens the excel file with serial numbers//saved from barcode scanner====================>>>
  201.  
  202.     $aArray = _ExcelReadSheetToArray($oExcel) ;Using Default Parameters
  203.     ;_ArrayDisplay($aArray, "Array using Default Parameters")
  204.     $rows = UBound($aArray)
  205.     ConsoleWrite("$rows=" & $rows & @CRLF)
  206.     $stop = $rows - 1
  207.  
  208.     #region Facility Selector ======================================================================>>>
  209.  
  210.     $msg = ""
  211.     $gui = GUICreate("Ship to:", 220, 120) ; creates a centered dialog box
  212.     $button_ok = GUICtrlCreateButton("Send", 10, 80, 100)
  213.     $button_cancel = GUICtrlCreateButton("Cancel", 110, 80, 100)
  214.     $Combo_1 = GUICtrlCreateCombo("Select", 10, 40, 200, 21)
  215.     GUICtrlSetData($Combo_1, "|Grunstadt|Stuttgart|Mainz|Bitburg|Schinnen|U.K.|Chievres|Schweinfurt|Vilseck|Illesheim|Italy-Vicenza|Italy-Aviano|")
  216.     GUICtrlSetData(-1, "Grunstadt")
  217.     GUICtrlCreateLabel("Select Receiving Facility", 10, 10)
  218.     GUISetState(@SW_SHOW)
  219.  
  220.     While 1
  221.         $msg = GUIGetMsg()
  222.         Select
  223.             Case $msg = $button_cancel Or $msg = $GUI_EVENT_CLOSE
  224.                 GUIDelete()
  225.                 Return 0
  226.  
  227.             Case $msg = $button_ok
  228.                 $Menustate = GUICtrlRead($Combo_1)
  229.                 If $Menustate = "Grunstadt" Then
  230.                     $var1 = "1342560"
  231.                     $var2 = "7014290600"
  232.                     ExitLoop
  233.                 EndIf
  234.                 If $Menustate = "Stuttgart" Then
  235.                     $var1 = "1342570"
  236.                     $var2 = "7014291800"
  237.                     ExitLoop
  238.                 EndIf
  239.                 If $Menustate = "Mainz" Then
  240.                     $var1 = "1342561"
  241.                     $var2 = "7014290900"
  242.                     ExitLoop
  243.                 EndIf
  244.                 If $Menustate = "Bitburg" Then
  245.                     $var1 = "1342562"
  246.                     $var2 = "7014291000"
  247.                     ExitLoop
  248.                 EndIf
  249.                 If $Menustate = "Schinnen" Then
  250.                     $var1 = "1342565"
  251.                     $var2 = "7014291300"
  252.                     ExitLoop
  253.                 EndIf
  254.                 If $Menustate = "U.K." Then
  255.                     $var1 = "1342563"
  256.                     $var2 = "7014291100"
  257.                     ExitLoop
  258.                 EndIf
  259.                 If $Menustate = "Chievres" Then
  260.                     $var1 = "1342566"
  261.                     $var2 = "7014291400"
  262.                     ExitLoop
  263.                 EndIf
  264.                 If $Menustate = "Schweinfurt" Then
  265.                     $var1 = "1342568"
  266.                     $var2 = "7014291600"
  267.                     ExitLoop
  268.                 EndIf
  269.                 If $Menustate = "Vilseck" Then
  270.                     $var1 = "1342567"
  271.                     $var2 = "7014291500"
  272.                     ExitLoop
  273.                 EndIf
  274.                 If $Menustate = "Illesheim" Then
  275.                     $var1 = "1342569"
  276.                     $var2 = "7014291700"
  277.                     ExitLoop
  278.                 EndIf
  279.                 If $Menustate = "Italy-Vicenza" Then
  280.                     $var1 = "1342571"
  281.                     $var2 = "7014291900"
  282.                     ExitLoop
  283.                 EndIf
  284.                 If $Menustate = "Italy-Aviano" Then
  285.                     $var1 = "1342572"
  286.                     $var2 = "7014292000"
  287.                     ExitLoop
  288.                 EndIf
  289.  
  290.         EndSelect
  291.     WEnd
  292.     GUIDelete()
  293.     #endregion Facility Selector ======================================================================>>>
  294.  
  295.     ;start-read number from tllcount.txt ===============================================>>>
  296.     $tllPath = _PathFull(@ScriptDir & "\tllcount.txt")
  297.     ConsoleWrite("$tllPath=" & $tllPath & @CRLF)
  298.     $chars = FileReadLine($tllPath, 1)
  299.     ;end read number from tllcount.txt =================================================>>>
  300.  
  301.     ;End of user interface, begin typing TLL ===========================================>>>
  302.  
  303.     ;Open sanirecord.pdf / maximize / zoom to fit page ===================>>>
  304.     ShellExecute('AcroRd32.exe', $tllpdf)
  305.     WinWaitActive("TLL.pdf")
  306.     WinSetState("TLL.pdf", "", @SW_MAXIMIZE)
  307.     Sleep(300)
  308.     Send("^0")
  309.     ;Open sanirecord.pdf / maximize / zoom to fit page ===================>>>
  310.  
  311.     ;Fill in Header Information=========================================>>>
  312.     Sleep(3500)
  313.     Send($chars);enters countup # from tllcount.txt
  314.     Sleep(700)
  315.     Send("+{TAB}");backs up one to title position
  316.     Sleep(700)
  317.     Send($Menustate);types receiving fac
  318.     Sleep(700)
  319.     Send("{TAB 2}")
  320.     Sleep(700)
  321.     Send($var1);aim # from selected facility
  322.     Sleep(700)
  323.     Send("{TAB}")
  324.     Sleep(700)
  325.     Send($var2);facility # from selected fac.
  326.     Sleep(700)
  327.     Send("{TAB}")
  328.     Sleep(700)
  329.     Send("1349995");aim # Sani
  330.     Sleep(700)
  331.     Send("{TAB}")
  332.     Sleep(800)
  333.     Send("7014292200");fac. # Sani
  334.     Sleep(600)
  335.     Send("{TAB 3}")
  336.     Sleep(700)
  337.     Send(_NowDate());date of today
  338.     Sleep(700)
  339.     Send("{TAB}")
  340.     Sleep(700)
  341.     ;Fill in Header Information=========================================>>>
  342.  
  343.     ;Cooler Serial # Transfer ==========================================>>>
  344.     For $iCount = 1 To 25 ;position counter
  345.  
  346.         ;$sCellValue1 = _ExcelReadCell($oExcel, $iCount, 3) ;Sends Position Counter integer
  347.         Send($iCount)
  348.         Sleep(700)
  349.         Send("{TAB}")
  350.         Sleep(700)
  351.         $sCellValue = _ExcelReadCell($oExcel, $iCount, 1);reads from selected Excel file 1 pos @ a time
  352.         If $sCellValue = "" Then ExitLoop
  353.         Send($sCellValue)
  354.         Sleep(700)
  355.         Send("{SPACE}")
  356.         Sleep(700)
  357.         $sCellValue2 = _ExcelReadCell($oExcel, $iCount, 2);reads from selected Excel file 1 pos @ a time
  358.         Send($sCellValue2)
  359.         Sleep(700)
  360.         Send("{TAB 4}")
  361.         Sleep(700)
  362.         Send("1")
  363.         Sleep(700)
  364.         Send("{TAB}")
  365.     Next
  366.     ;end loop for serial # transfer
  367.     Send("+{TAB}");when no more # to read from excel file, backup and del last position #
  368.     Sleep(700)
  369.     Send("{DEL}")
  370.     Sleep(2000)
  371.  
  372.     ;Cooler Serial # Transfer ==========================================>>>
  373.  
  374.     ;Print Message Box==================================================>>>
  375.     $msg = ""
  376.  
  377.     $gui = GUICreate("Print TLL", 220, 120) ; creates a centered dialog box
  378.     $button_ok = GUICtrlCreateButton("Print", 10, 80, 100)
  379.     $button_cancel = GUICtrlCreateButton("Cancel", 110, 80, 100)
  380.     $Combo_1 = GUICtrlCreateCombo("Select", 10, 40, 200, 21)
  381.     GUICtrlSetData($Combo_1, "|6 Copies|5 Copies|4 Copies|3 Copies|2 Copies|1 Copies|")
  382.     GUICtrlSetData(-1, "3 Copies")
  383.     GUICtrlCreateLabel("How many copies?", 10, 10)
  384.     GUISetState(@SW_SHOW)
  385.  
  386.  
  387.     While 1
  388.         $msg = GUIGetMsg()
  389.         Select
  390.             Case $msg = $button_cancel Or $msg = $GUI_EVENT_CLOSE
  391.                 ExitLoop
  392.                 GUIDelete()
  393.  
  394.             Case $msg = $button_ok
  395.                 $Menustate = GUICtrlRead($Combo_1)
  396.                 If $Menustate = "6 Copies" Then
  397.                     WinActivate("TLL.pdf")
  398.                     Send("^p")
  399.                     Send("!u")
  400.                     Send("!c")
  401.                     Send("6")
  402.                     Sleep(1000)
  403.                     Send("{ENTER}")
  404.                     ExitLoop
  405.                 EndIf
  406.                 If $Menustate = "5 Copies" Then
  407.                     WinActivate("TLL.pdf")
  408.                     Send("^p")
  409.                     Send("!u")
  410.                     Send("!c")
  411.                     Send("5")
  412.                     Sleep(1000)
  413.                     Send("{ENTER}")
  414.                     ExitLoop
  415.                 EndIf
  416.                 If $Menustate = "4 Copies" Then
  417.                     WinActivate("TLL.pdf")
  418.                     Send("^p")
  419.                     Send("!u")
  420.                     Send("!c")
  421.                     Send("4")
  422.                     Sleep(1000)
  423.                     Send("{ENTER}")
  424.                     ExitLoop
  425.                 EndIf
  426.                 If $Menustate = "3 Copies" Then
  427.                     WinActivate("TLL.pdf")
  428.                     Send("^p")
  429.                     Send("!u")
  430.                     Send("!c")
  431.                     Send("3")
  432.                     Sleep(1000)
  433.                     Send("{ENTER}")
  434.                     ExitLoop
  435.                 EndIf
  436.                 If $Menustate = "2 Copies" Then
  437.                     WinActivate("TLL.pdf")
  438.                     Send("^p")
  439.                     Send("!u")
  440.                     Send("!c")
  441.                     Send("2")
  442.                     Sleep(1000)
  443.                     Send("{ENTER}")
  444.                     ExitLoop
  445.                 EndIf
  446.                 If $Menustate = "1 Copies" Then
  447.                     WinActivate("TLL.pdf")
  448.                     Send("^p")
  449.                     Send("!u")
  450.                     Send("!c")
  451.                     Send("1")
  452.                     Sleep(1000)
  453.                     Send("{ENTER}")
  454.                     ExitLoop
  455.                 EndIf
  456.         EndSelect
  457.     WEnd
  458.     GUIDelete()
  459.     ;Print Message Box==================================================>>>
  460.     Sleep(1000)
  461.     WinActivate("TLL.pdf")
  462.     WinWaitActive("TLL.pdf")
  463.     Sleep(3000)
  464.     WinKill("TLL.pdf")
  465.     Sleep(1000)
  466.  
  467.     ;Add (1) to TLL Count txt file======================================>>>
  468.     $oldcount = FileReadLine(@ScriptDir & "\tllcount.txt", 1)
  469.     $result = StringCompare($oldcount, "999")
  470.     If $result = 0 Then
  471.         $newcount = 0
  472.     Else
  473.         $newcount = $oldcount + 1
  474.         ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $newcount = ' & $newcount & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
  475.     EndIf
  476.     $rc = _FileWriteToLine(@ScriptDir & "\tllcount.txt", 1, String($newcount), 1)
  477.     ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $rc = ' & $rc & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
  478.     ;Add (1) to TLL Count txt file======================================>>>
  479.     _ExcelBookClose($oExcel)
  480.  
  481. EndFunc   ;==>_tll
  482.  
  483. ;F4
  484. Func _sanirecord() ;Sanitation Record
  485.  
  486.     Local $sanirecord = (@ScriptDir & "\sanirecord.pdf")
  487.     BlockInput(1)
  488.     ;Splash================================================================>>>
  489.     $splash = @ScriptDir & "\sanirecord.jpg"
  490.     $hwnd = GUICreate("", 600, 200, -1, -1, $WS_POPUP)
  491.     GUICtrlCreatePic($splash, 0, 0, 600, 200)
  492.     DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00080000);fade-in
  493.     GUISetState()
  494.     ;Sleep(800);View picture
  495.     DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00090000);fade-out
  496.     ;Splash================================================================>>>
  497.     BlockInput(0)
  498.  
  499.     #region start code that opens the excel file with serial numbers//saved from barcode scanner====================>>>
  500.     If WinExists("Microsoft Excel") Then
  501.         MsgBox(16, "Open Workbook Identified", "Please close any open Excel Workbooks" & @CRLF & "Function will continue after closing", 2)
  502.     EndIf
  503.     While WinExists("Microsoft Excel")
  504.         Sleep(100)
  505.     WEnd
  506.     $message = "Select Workbook"
  507.     $var = FileOpenDialog($message, @DesktopDir & "\", "Excel (*.xls;*.xlsx)", 1)
  508.     If @error Then
  509.         MsgBox(4096, "", "No File Selected - Exiting")
  510.         Return 0
  511.     Else
  512.         $var = StringReplace($var, "|", @CRLF)
  513.     EndIf
  514.     $oExcel = _ExcelBookOpen($var)
  515.     Sleep(100)
  516.     WinSetState("Microsoft Excel", "", @SW_MINIMIZE)
  517.     Sleep(100)
  518.     #endregion start code that opens the excel file with serial numbers//saved from barcode scanner====================>>>
  519.  
  520.     $aArray = _ExcelReadSheetToArray($oExcel) ;Using Default Parameters
  521.     ;_ArrayDisplay($aArray, "Array using Default Parameters")
  522.     $rows = UBound($aArray)
  523.     ConsoleWrite("$rows=" & $rows & @CRLF)
  524.     $stop = $rows - 1
  525.     For $c = 1 To $stop Step 4 ;===>>For/Next - Repeater ...After form filler 4 times goes to next set
  526.         BlockInput(1)
  527.         ;Open sanirecord.pdf / maximize / zoom to fit page ===================>>>
  528.         ShellExecute('AcroRd32.exe', $sanirecord)
  529.         WinWaitActive("sanirecord.pdf")
  530.         WinSetState("sanirecord.pdf", "", @SW_MAXIMIZE)
  531.         Sleep(300)
  532.         Send("^0")
  533.         ;Open sanirecord.pdf / maximize / zoom to fit page ===================>>>
  534.         ;Begin - filling in form the 4 forms on sanirecord.pdf ==========================>>>
  535.         Sleep(4500)
  536.         Send("+{TAB}")
  537.         Sleep(700)
  538.         For $iCount = $c To $c + 4 - 1 ;=====>>> Repeates the form filler 4 times
  539.  
  540.             $sCellValue1 = _ExcelReadCell($oExcel, $iCount, 3) ;Sends Position Counter integer
  541.             Send($sCellValue1)
  542.             Sleep(700)
  543.             Send("{TAB}")
  544.             Sleep(700)
  545.             $sCellValue = _ExcelReadCell($oExcel, $iCount, 1) ;Sends Cooler #
  546.             If $sCellValue = "" Then ExitLoop
  547.             ConsoleWrite("$c=" & $c & @CRLF)
  548.             Send($sCellValue)
  549.             Sleep(700)
  550.             Send("{TAB}")
  551.             Sleep(700)
  552.             Send("Oasis")
  553.             Sleep(700)
  554.             Send("{TAB}")
  555.             Sleep(700)
  556.             $sCellValue2 = _ExcelReadCell($oExcel, $iCount, 2) ;Sends Reg or H&C
  557.             Send($sCellValue2)
  558.             Sleep(700)
  559.             Send("{TAB}")
  560.             Sleep(700)
  561.             Send("Grunstadt")
  562.             Sleep(300)
  563.             Send("{TAB}")
  564.             Sleep(700)
  565.             Send(_NowDate())
  566.             Sleep(700)
  567.             Send("{TAB}")
  568.             Sleep(700)
  569.         Next
  570.         ;End - filling in form the 4 forms on sanirecord.pdf ==========================>>>
  571.         ;Print PDF =============================================================>>>
  572.  
  573.         WinActivate("sanirecord.pdf")
  574.         WinWaitActive("sanirecord.pdf")
  575.         Sleep(300)
  576.         Send("^p")
  577.         Sleep(300)
  578.         WinWait("Print", "", 5)
  579.         WinWaitActive("Print")
  580.         Send("{ENTER}") ;cancels print for testing purposes============>>>
  581.         ;ControlClick("Print", "Rotate and Center", "[CLASS:Button; INSTANCE:17]")
  582.         Sleep(500)
  583.         WinActivate("sanirecord.pdf")
  584.         WinWaitActive("sanirecord.pdf")
  585.         Sleep(300)
  586.         WinKill("sanirecord.pdf")
  587.         Sleep(1000)
  588.  
  589.         ;Print PDF ==============================================================>>>
  590.  
  591.         If $sCellValue = "" Then
  592.             ExitLoop
  593.         EndIf
  594.     Next
  595.     _ExcelBookClose($oExcel)
  596.     BlockInput(0)
  597. EndFunc   ;==>_sanirecord
  598.  
  599. ;F5
  600. Func _flash() ;Splash
  601.     $iBatch = String(@MDAY & @MON & @YEAR & @HOUR & @MIN)
  602.     ConsoleWrite("$iBatch=" & $iBatch & @CRLF)
  603.     MsgBox(4096, "iBatch", $iBatch, 1)
  604. ;~  BlockInput(1)
  605. ;~  $splash = "SaniMotion.jpg"
  606.  
  607. ;~  $hwnd = GUICreate("", 600, 400, -1, -1, $WS_POPUP)
  608. ;~  GUICtrlCreatePic($splash, 0, 0, 600, 400)
  609. ;~  DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00080000);fade-in
  610. ;~  GUISetState()
  611. ;~  Sleep(2000);View picture
  612. ;~  DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00090000);fade-out
  613. ;~  BlockInput(0)
  614. EndFunc   ;==>_flash
  615. ;F6
  616. Func _saniprotocol() ;SaniProtocol
  617.  
  618.     Local $saniproto = (@ScriptDir & "\sani_protocol.pdf")
  619.     BlockInput(1)
  620.     ;Splash================================================================>>>
  621.     $splash = @ScriptDir & "\spp.jpg"
  622.     $hwnd = GUICreate("", 600, 200, -1, -1, $WS_POPUP)
  623.     GUICtrlCreatePic($splash, 0, 0, 600, 200)
  624.     DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00080000);fade-in
  625.     GUISetState()
  626.     ;Sleep(800);View picture
  627.     DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00090000);fade-out
  628.     ;Splash================================================================>>>
  629.     BlockInput(0)
  630.  
  631.     #region start code that opens the excel file with serial numbers//saved from barcode scanner------------------------
  632.     If WinExists("Microsoft Excel") Then
  633.         MsgBox(16, "Open Workbook Identified", "Please close any open Excel Workbooks" & @CRLF & "Function will continue after closing", 1.5)
  634.     EndIf
  635.     While WinExists("Microsoft Excel")
  636.         Sleep(100)
  637.     WEnd
  638.     $message = "Select Workbook"
  639.     $var = FileOpenDialog($message, @DesktopDir & "\", "Excel (*.xls;*.xlsx)", 1)
  640.     If @error Then
  641.         MsgBox(4096, "", "No File Selected - Exiting")
  642.         Return 0
  643.         BlockInput(1)
  644.     Else
  645.         $var = StringReplace($var, "|", @CRLF)
  646.     EndIf
  647.     $oExcel = _ExcelBookOpen($var)
  648.     Sleep(100)
  649.     WinSetState("Microsoft Excel", "", @SW_MINIMIZE)
  650.     Sleep(100)
  651.     #endregion start code that opens the excel file with serial numbers//saved from barcode scanner------------------------
  652.     $aArray = _ExcelReadSheetToArray($oExcel) ;Using Default Parameters
  653.     ;_ArrayDisplay($aArray, "Array using Default Parameters")
  654.     $rows = UBound($aArray)
  655.     ConsoleWrite("$rows=" & $rows & @CRLF)
  656.     $stop = $rows - 1
  657.     For $c = 1 To $stop Step 5 ;===>>For/Next - Repeater ...After form filler 4 times goes to next set
  658.         BlockInput(1)
  659.         ;Open saniprotocol.pdf / maximize / zoom to fit page ===>
  660.         ShellExecute('AcroRd32.exe', $saniproto)
  661.         WinWaitActive("sani_protocol.pdf")
  662.         WinSetState("sani_protocol.pdf", "", @SW_MAXIMIZE)
  663.         Sleep(300)
  664.         Send("^0")
  665.         ;Open saniprotocol.pdf / maximize / zoom to fit page ===>
  666.  
  667.         ;Begin - filling in form the 5 forms on saniprotocol.pdf ==========================>>>
  668.         Sleep(4000)
  669.         Send("{TAB}")
  670.         Sleep(300)
  671.         Send($iBatch)
  672.         Sleep(300)
  673.         Send("{TAB}")
  674.         Sleep(300)
  675.         For $iCount = $c To $c + 5 - 1 ;=====>>> Repeates the form filler 5 times
  676.             $sCellValue1 = _ExcelReadCell($oExcel, $iCount, 3)
  677.             Sleep(300)
  678.             Send($sCellValue1) ; send position counter
  679.             Sleep(300)
  680.             Send("{TAB}")
  681.             Sleep(300)
  682.             $sCellValue2 = _ExcelReadCell($oExcel, $iCount, 1);reads from selected Excel file 1 pos @ a time
  683.             If $sCellValue2 = "" Then ExitLoop
  684.             Send($sCellValue2) ;sends cooler #
  685.             Sleep(300)
  686.             Send("{TAB}")
  687.             Sleep(300)
  688.             $sCellValue3 = _ExcelReadCell($oExcel, $iCount, 2)
  689.             Send($sCellValue3) ;sends H&C or REG
  690.             Sleep(300)
  691.             Send("{TAB}")
  692.             Sleep(300)
  693.             Send(_NowDate())
  694.             Sleep(300)
  695.             Send("{TAB}")
  696.             Sleep(300)
  697.             Send(_NowDate())
  698.             Sleep(300)
  699.             Send("{TAB}")
  700.             Sleep(300)
  701.         Next
  702.         ;End - filling in form the 5 forms on saniprotocol.pdf ==========================>>>
  703.         ;Print PDF ======================================================================>>>
  704.         WinActivate("sani_protocol.pdf")
  705.         WinWaitActive("sani_protocol.pdf")
  706.         Sleep(300)
  707.         Send("^p")
  708.         Sleep(300)
  709.         WinWait("Print", "", 5)
  710.         WinWaitActive("Print")
  711.         Send("{ENTER}") ;cancels print for testing purposes============>>>
  712.         ;ControlClick("Print", "Rotate and Center", "[CLASS:Button; INSTANCE:17]")
  713.         Sleep(500)
  714.         WinActivate("sani_protocol.pdf")
  715.         WinWaitActive("sani_protocol.pdf")
  716.         Sleep(300)
  717.         WinKill("sani_protocol.pdf")
  718.         Sleep(1000)
  719.         ;Print PDF ======================================================================>>>
  720.  
  721.         If $sCellValue2 = "" Then
  722.             ExitLoop
  723.         EndIf
  724.     Next
  725.     _ExcelBookClose($oExcel)
  726.     BlockInput(0)
  727.  
  728. EndFunc   ;==>_saniprotocol
  729.  
  730. ;F7
  731. Func _f7()
  732.     BlockInput(1)
  733.     $splash = @ScriptDir & "\labelprinter.jpg"
  734.  
  735.     $hwnd = GUICreate("", 600, 200, -1, -1, $WS_POPUP)
  736.     GUICtrlCreatePic($splash, 0, 0, 600, 200)
  737.     DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00080000);fade-in
  738.     GUISetState()
  739.     Sleep(1500);View picture
  740.     DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00090000);fade-out
  741.  
  742.     Local $Input1, $Input2, $Button1, $Button2, $nMsg
  743.     $nMsg = 0
  744.     BlockInput(0)
  745.     #region ### START Koda GUI section ### Form=
  746.     $Form1 = GUICreate("Print Label", 381, 221, 192, 124)
  747.     $Input1 = GUICtrlCreateInput("Cooler#", 120, 96, 121, 21)
  748.     $Input2 = GUICtrlCreateInput("Model", 120, 128, 121, 21)
  749.     $Button1 = GUICtrlCreateButton("Print", 88, 176, 75, 25, $WS_GROUP)
  750.     $Button2 = GUICtrlCreateButton("Cancel", 200, 176, 75, 25, $WS_GROUP)
  751.     $Label1 = GUICtrlCreateLabel("Prints Waterproof Labels for Coolers on the fly.", 24, 16, 332, 57)
  752.     GUISetState(@SW_SHOW)
  753.     #endregion ### END Koda GUI section ###
  754.  
  755.     While 1
  756.         $nMsg = GUIGetMsg()
  757.         Select
  758.             Case $nMsg = $Button2 Or $nMsg = $GUI_EVENT_CLOSE
  759.                 GUIDelete()
  760.                 Return 0
  761.  
  762.             Case $nMsg = $Button1
  763.                 $coolernr = GUICtrlRead($Input1)
  764.                 $model = GUICtrlRead($Input2)
  765.  
  766.                 ExitLoop
  767.         EndSelect
  768.     WEnd
  769.     GUIDelete()
  770.  
  771.     MsgBox(4096, "Printing Label", $coolernr & @CRLF & $model, 1)
  772.  
  773.     Local $pte
  774.     ShellExecute(@ProgramFilesDir & "\Brother\Ptedit50\Ptedit50.exe")
  775.     $pte = WinGetHandle("Ptedit50.exe", "")
  776.     WinWaitActive($pte)
  777.     ;Send("{ENTER}") ;closes the missing driver warning
  778.     Sleep(3000)
  779.     ;WinSetState($pte, "", @SW_HIDE)
  780.     Send("^o")
  781.     Sleep(300)
  782.     Send("replacementlabel-film.lbx")
  783.     Sleep(300)
  784.     Send("{ENTER}")
  785.     Sleep(500)
  786.     Send("{TAB}")
  787.     Sleep(300)
  788.     Send($model)
  789.     Sleep(300)
  790.     Send("{TAB}")
  791.     Sleep(300)
  792.     Send($coolernr)
  793.     Sleep(300)
  794.     ControlClick("P-touch Editor", "", "[CLASS:Button; INSTANCE:19]")
  795.     Sleep(700)
  796.     WinClose($pte)
  797.  
  798.  
  799.  
  800. EndFunc   ;==>_f7
  801.  
  802. ;F8
  803. Func _f8() ;TLL Counter  -1
  804.  
  805.     $oldcount = FileReadLine(@ScriptDir & "\tllcount.txt", 1)
  806.     $result = StringCompare($oldcount, "999")
  807.     If $result = 0 Then
  808.         ;$newcount = 0
  809.     Else
  810.         $newcount = $oldcount - 1
  811.         ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $newcount = ' & $newcount & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
  812.     EndIf
  813.     $rc = _FileWriteToLine(@ScriptDir & "\tllcount.txt", 1, String($newcount), 1)
  814.     ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $rc = ' & $rc & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
  815.     MsgBox(0, "TLL", "-" & $rc, 1)
  816.  
  817. EndFunc   ;==>_f8
  818. ;F9
  819. Func _f9() ;TLL Counter  +1
  820.  
  821.     ;start code to add (1) to counter for next TLL----------------------------------------------------
  822.  
  823.     $oldcount = FileReadLine(@ScriptDir & "\tllcount.txt", 1)
  824.     $result = StringCompare($oldcount, "999")
  825.     If $result = 0 Then
  826.         $newcount = 0
  827.     Else
  828.         $newcount = $oldcount + 1
  829.         ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $newcount = ' & $newcount & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
  830.     EndIf
  831.     $rc = _FileWriteToLine(@ScriptDir & "\tllcount.txt", 1, String($newcount), 1)
  832.     ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $rc = ' & $rc & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
  833.     MsgBox(0, "TLL", "+" & $rc, 1)
  834.  
  835.     ;end code to add (1) to counter for next TLL------------------------------------------------------
  836.  
  837.  
  838. EndFunc   ;==>_f9
  839.  
  840. ;F10
  841. Func _f10() ;TLL Counter Show Count
  842.  
  843.     ;start-read number from tllcount.txt----------------------------------------------------------------------------------
  844.     $tllPath = _PathFull(@ScriptDir & "\tllcount.txt")
  845.     $chars = FileReadLine($tllPath, 1)
  846.     ;end read number from tllcount.txt------------------------------------------------------------------------------------
  847.  
  848.     MsgBox(64, "TLL Counter", "Tll Count is now:" & @CRLF & _
  849.             @TAB & $chars, 2)
  850.  
  851. EndFunc   ;==>_f10
  852.  
  853. ;F11
  854. Func _f11() ;====>>> Scanner Upload
  855.     $iBatch = String(@MDAY & @MON & @YEAR & @HOUR & @MIN)
  856.     BlockInput(1)
  857.     ;Splash================================================================>>>
  858.     $splash = @ScriptDir & "\upload.jpg"
  859.     $hwnd = GUICreate("", 600, 200, -1, -1, $WS_POPUP)
  860.     GUICtrlCreatePic($splash, 0, 0, 600, 200)
  861.     DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00080000);fade-in
  862.     GUISetState()
  863.     Sleep(800);View picture
  864.     DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00090000);fade-out
  865.     ;Splash================================================================>>>
  866.     BlockInput(0)
  867.     ShellExecute("C:\Program Files\BCP7000Read\BCP7000Read.exe")
  868.     BlockInput(1)
  869.     WinWaitActive("Read Data via Serial Port")
  870.  
  871.     ControlClick("Read Data via Serial Port", "Save received data to file", "[CLASS:WindowsForms10.EDIT.app.0.378734a; INSTANCE:2]", "Right")
  872.  
  873.     ControlSend("Read Data via Serial Port", "Save received data to file", "[CLASS:WindowsForms10.EDIT.app.0.378734a; INSTANCE:2]", "a")
  874.  
  875.     ControlSend("Read Data via Serial Port", "Save received data to file", "[CLASS:WindowsForms10.EDIT.app.0.378734a; INSTANCE:2]", @DesktopDir)
  876.  
  877.     Send("{TAB}")
  878.  
  879.     ControlSend("Read Data via Serial Port", "Save received data to file", "[CLASS:WindowsForms10.EDIT.app.0.378734a; INSTANCE:1]", $iBatch & "." & "txt")
  880.  
  881.     ControlClick("Read Data via Serial Port", "Save received data to file", "[CLASS:WindowsForms10.BUTTON.app.0.378734a; INSTANCE:4]")
  882.  
  883.     WinWait("BCP7000Read", "OK", 1)
  884.  
  885.     ControlClick("BCP7000Read", "OK", "[CLASS:Button; INSTANCE:1]")
  886.  
  887.     Sleep(2000)
  888.  
  889.     ControlClick("Read Data via Serial Port", "Save received data to file", "[CLASS:WindowsForms10.BUTTON.app.0.378734a; INSTANCE:3]")
  890.  
  891.     BlockInput(0)
  892.  
  893. EndFunc   ;==>_f11
Advertisement
Add Comment
Please, Sign In to add comment