Advertisement
Guest User

1551 11/6/61

a guest
Jun 11th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 39.90 KB | None | 0 0
  1. #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
  2. #AutoIt3Wrapper_Icon=E:\Portfolio\Project COS3110\for Adobe\clock.ico
  3. #AutoIt3Wrapper_Outfile=E:\Portfolio\Project COS3110\for Adobe\Adobe Automatic Schedule x86.exe
  4. #AutoIt3Wrapper_UseX64=n
  5. #AutoIt3Wrapper_Res_Description=ตารางเวลา Encoder
  6. #AutoIt3Wrapper_Res_Fileversion=1.0.0.0
  7. #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
  8. #AutoIt3Wrapper_Res_ProductVersion=2.0
  9. #AutoIt3Wrapper_Res_LegalCopyright=
  10. #AutoIt3Wrapper_Res_Language=1054
  11. #AutoIt3Wrapper_Res_Field=ProductName|
  12. #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
  13. #include <GUIConstantsEx.au3>
  14. #include <ComboConstants.au3>
  15. #include <StaticConstants.au3>
  16. #include <DateTimeConstants.au3>
  17. #include <MsgBoxConstants.au3>
  18. #include <ColorConstants.au3>
  19. #include <Date.au3>
  20.  
  21.  
  22. $title = "Windows Media Encoder"
  23. $title= "Untitled - Windows Media Encoder"
  24.  
  25.  
  26. #Region ### START Koda GUI section ###
  27. $MainForm = GUICreate("WME Automatic Schedule", 800, 650, -1, -1)
  28.  
  29. ; Create the controls
  30. GUICtrlCreateGroup("เลือกวัน", 70, 140, 165, 270)
  31. GUIStartGroup()
  32. $Radio2 = GUICtrlCreateRadio("จันทร์", 100, 180, 70, 20)
  33. $Radio3 = GUICtrlCreateRadio("อังคาร", 100, 210, 60, 20)
  34. $Radio4 = GUICtrlCreateRadio("พุธ", 100, 240, 60, 20)
  35. $Radio5 = GUICtrlCreateRadio("พฤหัสบดี", 100, 270, 70, 20)
  36. $Radio6 = GUICtrlCreateRadio("ศุกร์", 100, 300, 60, 20)
  37. $Radio7 = GUICtrlCreateRadio("เสาร์", 100, 330, 60, 20)
  38. $Radio1 = GUICtrlCreateRadio("อาทิตย์", 100, 360, 70, 20)
  39.  
  40. $lecture1 = GUICtrlCreateCheckbox("", 280, 140, 18, 18)
  41. $lecture2 = GUICtrlCreateCheckbox("", 280, 180, 18, 18)
  42. $lecture3 = GUICtrlCreateCheckbox("", 280, 220, 18, 18)
  43. $lecture4 = GUICtrlCreateCheckbox("", 280, 260, 18, 18)
  44. $lecture5 = GUICtrlCreateCheckbox("", 280, 300, 18, 18)
  45. $lecture6 = GUICtrlCreateCheckbox("", 280, 340, 18, 18)
  46. $lecture7 = GUICtrlCreateCheckbox("", 280, 380, 18, 18)
  47. $lecture8 = GUICtrlCreateCheckbox("", 280, 420, 18, 18)
  48. $lecture9 = GUICtrlCreateCheckbox("", 280, 460, 18, 18)
  49. $lecture10 = GUICtrlCreateCheckbox("", 280, 500, 18, 18)
  50.  
  51. $startBefore = GUICtrlCreateCombo("", 50, 535, 65, 30, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  52. $endAfter = GUICtrlCreateCombo("", 150, 535, 65, 30, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  53.  
  54. GUIStartGroup()
  55. $extensionRadio1 = GUICtrlCreateRadio(".flv", 125, 575, 50, 30)
  56. $extensionRadio2 = GUICtrlCreateRadio(".f4v", 180, 575, 50, 30)
  57.  
  58. $startH1 = GUICtrlCreateCombo("", 320, 140, 80, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  59. $startH2 = GUICtrlCreateCombo("", 320, 180, 80, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  60. $startH3 = GUICtrlCreateCombo("", 320, 220, 80, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  61. $startH4 = GUICtrlCreateCombo("", 320, 260, 80, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  62. $startH5 = GUICtrlCreateCombo("", 320, 300, 80, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  63. $startH6 = GUICtrlCreateCombo("", 320, 340, 80, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  64. $startH7 = GUICtrlCreateCombo("", 320, 380, 80, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  65. $startH8 = GUICtrlCreateCombo("", 320, 420, 80, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  66. $startH9 = GUICtrlCreateCombo("", 320, 460, 80, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  67. $startH10 = GUICtrlCreateCombo("", 320, 500, 80, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  68.  
  69. $startM1 = GUICtrlCreateCombo("", 420, 140, 70, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  70. $startM2 = GUICtrlCreateCombo("", 420, 180, 70, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  71. $startM3 = GUICtrlCreateCombo("", 420, 220, 70, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  72. $startM4 = GUICtrlCreateCombo("", 420, 260, 70, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  73. $startM5 = GUICtrlCreateCombo("", 420, 300, 70, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  74. $startM6 = GUICtrlCreateCombo("", 420, 340, 70, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  75. $startM7 = GUICtrlCreateCombo("", 420, 380, 70, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  76. $startM8 = GUICtrlCreateCombo("", 420, 420, 70, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  77. $startM9 = GUICtrlCreateCombo("", 420, 460, 70, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  78. $startM10 = GUICtrlCreateCombo("", 420, 500, 70, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  79.  
  80. $endH1 = GUICtrlCreateCombo("", 560, 140, 80, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  81. $endH2 = GUICtrlCreateCombo("", 560, 180, 80, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  82. $endH3 = GUICtrlCreateCombo("", 560, 220, 80, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  83. $endH4 = GUICtrlCreateCombo("", 560, 260, 80, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  84. $endH5 = GUICtrlCreateCombo("", 560, 300, 80, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  85. $endH6 = GUICtrlCreateCombo("", 560, 340, 80, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  86. $endH7 = GUICtrlCreateCombo("", 560, 380, 80, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  87. $endH8 = GUICtrlCreateCombo("", 560, 420, 80, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  88. $endH9 = GUICtrlCreateCombo("", 560, 460, 80, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  89. $endH10 = GUICtrlCreateCombo("", 560, 500, 80, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  90.  
  91. $endM1 = GUICtrlCreateCombo("", 660, 140, 70, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  92. $endM2 = GUICtrlCreateCombo("", 660, 180, 70, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  93. $endM3 = GUICtrlCreateCombo("", 660, 220, 70, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  94. $endM4 = GUICtrlCreateCombo("", 660, 260, 70, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  95. $endM5 = GUICtrlCreateCombo("", 660, 300, 70, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  96. $endM6 = GUICtrlCreateCombo("", 660, 340, 70, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  97. $endM7 = GUICtrlCreateCombo("", 660, 380, 70, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  98. $endM8 = GUICtrlCreateCombo("", 660, 420, 70, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  99. $endM9 = GUICtrlCreateCombo("", 660, 460, 70, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  100. $endM10 = GUICtrlCreateCombo("", 660, 500, 70, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  101.  
  102. $shutdownH = GUICtrlCreateCombo("", 615, 58, 55, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  103. $shutdownM = GUICtrlCreateCombo("", 685, 58, 55, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  104.  
  105. $copytoDay = GUICtrlCreateCombo("", 630, 100, 100, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
  106.  
  107. ; Add additional items to the combobox.
  108. GUICtrlSetData($startBefore, "0|1|2|3|4|5", "0")
  109. GUICtrlSetData($endAfter, "0|1|2|3|4|5", "0")
  110.  
  111. GUICtrlSetData($shutdownH, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|none", "none")
  112. GUICtrlSetData($shutdownM, "00|05|10|15|20|25|30|35|40|45|50|55|none", "none")
  113.  
  114. GUICtrlSetData($copytoDay, "เลือกวันนำเข้า|จันทร์|อังคาร|พุธ|พฤหัสบดี|ศุกร์|เสาร์|อาทิตย์", "เลือกวันนำเข้า")
  115.  
  116. GUICtrlSetData($startH1, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23", "none")
  117. GUICtrlSetData($startH2, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23", "none")
  118. GUICtrlSetData($startH3, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23", "none")
  119. GUICtrlSetData($startH4, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23", "none")
  120. GUICtrlSetData($startH5, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23", "none")
  121. GUICtrlSetData($startH6, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23", "none")
  122. GUICtrlSetData($startH7, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23", "none")
  123. GUICtrlSetData($startH8, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23", "none")
  124. GUICtrlSetData($startH9, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23", "none")
  125. GUICtrlSetData($startH10, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23", "none")
  126. GUICtrlSetData($startM1, "00|05|10|15|20|25|30|35|40|45|50|55", "none")
  127. GUICtrlSetData($startM2, "00|05|10|15|20|25|30|35|40|45|50|55", "none")
  128. GUICtrlSetData($startM3, "00|05|10|15|20|25|30|35|40|45|50|55", "none")
  129. GUICtrlSetData($startM4, "00|05|10|15|20|25|30|35|40|45|50|55", "none")
  130. GUICtrlSetData($startM5, "00|05|10|15|20|25|30|35|40|45|50|55", "none")
  131. GUICtrlSetData($startM6, "00|05|10|15|20|25|30|35|40|45|50|55", "none")
  132. GUICtrlSetData($startM7, "00|05|10|15|20|25|30|35|40|45|50|55", "none")
  133. GUICtrlSetData($startM8, "00|05|10|15|20|25|30|35|40|45|50|55", "none")
  134. GUICtrlSetData($startM9, "00|05|10|15|20|25|30|35|40|45|50|55", "none")
  135. GUICtrlSetData($startM10, "00|05|10|15|20|25|30|35|40|45|50|55", "none")
  136.  
  137. GUICtrlSetData($endH1, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23", "none")
  138. GUICtrlSetData($endH2, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23", "none")
  139. GUICtrlSetData($endH3, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23", "none")
  140. GUICtrlSetData($endH4, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23", "none")
  141. GUICtrlSetData($endH5, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23", "none")
  142. GUICtrlSetData($endH6, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23", "none")
  143. GUICtrlSetData($endH7, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23", "none")
  144. GUICtrlSetData($endH8, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23", "none")
  145. GUICtrlSetData($endH9, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23", "none")
  146. GUICtrlSetData($endH10, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23", "none")
  147. GUICtrlSetData($endM1, "00|05|10|15|20|25|30|35|40|45|50|55", "none")
  148. GUICtrlSetData($endM2, "00|05|10|15|20|25|30|35|40|45|50|55", "none")
  149. GUICtrlSetData($endM3, "00|05|10|15|20|25|30|35|40|45|50|55", "none")
  150. GUICtrlSetData($endM4, "00|05|10|15|20|25|30|35|40|45|50|55", "none")
  151. GUICtrlSetData($endM5, "00|05|10|15|20|25|30|35|40|45|50|55", "none")
  152. GUICtrlSetData($endM6, "00|05|10|15|20|25|30|35|40|45|50|55", "none")
  153. GUICtrlSetData($endM7, "00|05|10|15|20|25|30|35|40|45|50|55", "none")
  154. GUICtrlSetData($endM8, "00|05|10|15|20|25|30|35|40|45|50|55", "none")
  155. GUICtrlSetData($endM9, "00|05|10|15|20|25|30|35|40|45|50|55", "none")
  156. GUICtrlSetData($endM10, "00|05|10|15|20|25|30|35|40|45|50|55", "none")
  157.  
  158. $resetButton = GUICtrlCreateButton("เคลียร์ค่า", 320, 560, 80, 25)
  159. $editButton = GUICtrlCreateButton("แก้ไข", 420, 560, 80, 25)
  160. $saveButton = GUICtrlCreateButton("บันทึกตารางเวลา", 630, 560, 100, 35)
  161.  
  162. $browseButton = GUICtrlCreateButton("Browse", 680, 10, 60, 30)
  163. $viewButton = GUICtrlCreateButton("ค่าตัวแปร", 10, 10, 60, 25)
  164.  
  165. $showDate = GUICtrlCreateLabel("ตั้งเวลา shutdown:", 515, 60, 90, 30)
  166.  
  167. $enableButton = GUICtrlCreateButton("", 50, 445, 104, 44)
  168. GUICtrlSetColor(-1, 0xFFFFFF)
  169. GUICtrlSetFont(-1, 15, 500, 0, "Arial")
  170.  
  171. $disableButton = GUICtrlCreateButton("", 160, 445, 104, 44)
  172. GUICtrlSetColor(-1, 0xFFFFFF)
  173. GUICtrlSetFont(-1, 15, 500, 0, "Arial")
  174.  
  175. ;Label
  176. $showDate = GUICtrlCreateLabel("", 70, 50, 140, 80)
  177. GUICtrlSetFont(-1, 14, 500, 0, "Arial")
  178. GUICtrlSetStyle(-1, $SS_CENTER)
  179.  
  180. $showTime = GUICtrlCreateLabel("", 280, 35, 140, 40, $SS_CENTER + $SS_CENTERIMAGE)
  181. GUICtrlSetFont(-1, 16, 600, 0, "Arial")
  182. GUICtrlSetColor(-1, 0xFFFFFF)
  183. GUICtrlSetBkColor(-1, 0x000000)
  184.  
  185. $showBrowse = GUICtrlCreateLabel("ระบุที่อยู่ Folder ชื่อ Encoder File :", 515, 15, 160, 30)
  186.  
  187. $tableTime = GUICtrlCreateLabel("ตารางเวลาในการถ่ายทอดสดและบันทึกวิดีโอ", 280, 85, 300, 30)
  188. GUICtrlSetFont(-1, 14, 600, 0, "Courier New")
  189.  
  190. $startTime = GUICtrlCreateLabel("เวลาเริ่มต้น", 320, 114)
  191. $endTime = GUICtrlCreateLabel("เวลาสิ้นสุด", 560, 114)
  192.  
  193. $beforeTime = GUICtrlCreateLabel("เริ่มก่อน: นาที", 50, 510, 80, 25)
  194. $afterTime = GUICtrlCreateLabel("ต่อหลังอีก: นาที", 150, 510, 80, 25)
  195.  
  196. $fileExtensionSelection = GUICtrlCreateLabel("นามสกุลไฟล์", 50, 580, 60, 25)
  197.  
  198. $runState = GUICtrlCreateLabel("สถานะ", 135, 415, 60, 30)
  199. GUICtrlSetFont(-1, 16, 500, 0, "Arial")
  200.  
  201. $exitPress = GUICtrlCreateLabel("กดปุ่ม ESC - กรณีค้าง บังคับออกจากโปรแกรม", 50, 620, 700, 20)
  202. GUICtrlSetStyle(-1, $SS_CENTER)
  203.  
  204. $check1 = GUICtrlCreateLabel("1.", 302, 140, 18, 20)
  205. $check2 = GUICtrlCreateLabel("2.", 302, 180, 18, 20)
  206. $check3 = GUICtrlCreateLabel("3.", 302, 220, 18, 20)
  207. $check4 = GUICtrlCreateLabel("4.", 302, 260, 18, 20)
  208. $check5 = GUICtrlCreateLabel("5.", 302, 300, 18, 20)
  209. $check6 = GUICtrlCreateLabel("6.", 302, 340, 18, 20)
  210. $check7 = GUICtrlCreateLabel("7.", 302, 380, 20, 20)
  211. $check8 = GUICtrlCreateLabel("8.", 302, 420, 20, 20)
  212. $check9 = GUICtrlCreateLabel("9.", 302, 460, 20, 20)
  213. $check10 = GUICtrlCreateLabel("10.", 302, 500, 20, 20)
  214.  
  215. GUISetState(@SW_SHOW)
  216. #EndRegion ### END Koda GUI section ###
  217.  
  218. Global $changeDate = 0
  219. Global $changeTime
  220. Global $setDay = @WDAY
  221. Global $day = ""
  222.  
  223. Global $setting_state
  224.  
  225. Global $auto_state = IniRead("setting.ini", "Auto", "auto_state", "0")
  226. Global $record_state = "start"
  227. Global $newEnd = 0
  228. Global $section = 0
  229.  
  230. Global $filePart = IniRead("setting.ini", "Auto", "latest_part", "0")
  231.  
  232. Global $shutdowntime
  233.  
  234. Global $before = IniRead("setting.ini", "Auto", "startBefore", "0")
  235. Global $after = IniRead("setting.ini", "Auto", "endAfter", "0")
  236. Global $fileExtension = IniRead("setting.ini", "Auto", "Extension", ".flv")
  237. Global $target = IniRead("setting.ini", "Auto", "FileSelectFolder", "0")
  238.  
  239. Global $save_file = ""
  240. Global $nametime
  241.  
  242. HotKeySet("{ESC}", "Terminate")
  243.  
  244. loadSetting($setDay)
  245. preload()
  246.  
  247. While 1
  248.     DateandTime()
  249.  
  250.     Switch GUIGetMsg()
  251.         Case $GUI_EVENT_CLOSE
  252.             ExitLoop
  253.  
  254.         Case $editButton
  255.             edit()
  256.         Case $resetButton
  257.             reset()
  258.         Case $saveButton
  259.             save($setDay)
  260.  
  261.         Case $browseButton
  262.             browse()
  263.  
  264.         Case $startBefore
  265.             setTime()
  266.         Case $endAfter
  267.             setTime()
  268.  
  269.         Case $shutdownH
  270.             setShutdown()
  271.         Case $shutdownM
  272.             setShutdown()
  273.  
  274.         Case $enableButton
  275.             enable()
  276.         Case $disableButton
  277.             disable()
  278.  
  279.         Case $copytoDay
  280.             copyDay()
  281.  
  282.         Case $viewButton
  283.             view()
  284.  
  285.         Case $Radio1
  286.             choiceDay(1)
  287.         Case $Radio2
  288.             choiceDay(2)
  289.         Case $Radio3
  290.             choiceDay(3)
  291.         Case $Radio4
  292.             choiceDay(4)
  293.         Case $Radio5
  294.             choiceDay(5)
  295.         Case $Radio6
  296.             choiceDay(6)
  297.         Case $Radio7
  298.             choiceDay(7)
  299.  
  300.         Case $extensionRadio1
  301.             choiceExtension(0)
  302.         Case $extensionRadio2
  303.             choiceExtension(1)
  304.  
  305.         Case $lecture1
  306.             choiceLecture(1)
  307.         Case $lecture2
  308.             choiceLecture(2)
  309.         Case $lecture3
  310.             choiceLecture(3)
  311.         Case $lecture4
  312.             choiceLecture(4)
  313.         Case $lecture5
  314.             choiceLecture(5)
  315.         Case $lecture6
  316.             choiceLecture(6)
  317.         Case $lecture7
  318.             choiceLecture(7)
  319.         Case $lecture8
  320.             choiceLecture(8)
  321.         Case $lecture9
  322.             choiceLecture(9)
  323.         Case $lecture10
  324.             choiceLecture(10)
  325.         Case $MainForm
  326.     EndSwitch
  327.    Debug()
  328.     Schedule()
  329. WEnd
  330. ; Delete the previous GUI and all controls.
  331. GUIDelete()
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338. Func Terminate()
  339.     $auto_state = 0
  340.     IniWrite("setting.ini", "Auto", "auto_state", $auto_state)
  341.     Exit
  342. EndFunc   ;==>Terminate
  343.  
  344. Func loadSetting($iValue)
  345.     GUICtrlSetState(Eval("Radio" & $iValue), $GUI_Checked)
  346.     GUICtrlSetState($resetButton, $GUI_DISABLE)
  347.     GUICtrlSetState($saveButton, $GUI_DISABLE)
  348.  
  349.     For $i = 1 To 10 Step 1
  350.         $loadLecture = IniRead("setting.ini", "Day-" & $iValue, "lecture" & $i, "0")
  351.  
  352.         If $loadLecture = 1 Then
  353.             If $i = 1 Then
  354.                 $setting_state = 1
  355.             EndIf
  356.  
  357.             GUICtrlSetState(Eval("lecture" & $i), $GUI_Checked)
  358.  
  359.             $loadstartH = IniRead("setting.ini", "Period-" & $iValue, $i & "-startH", "none")
  360.             GUICtrlSetData(Eval("startH" & $i), $loadstartH, "none")
  361.  
  362.             $loadstartM = IniRead("setting.ini", "Period-" & $iValue, $i & "-startM", "none")
  363.             GUICtrlSetData(Eval("startM" & $i), $loadstartM, "none")
  364.  
  365.             $loadendH = IniRead("setting.ini", "Period-" & $iValue, $i & "-endH", "none")
  366.             GUICtrlSetData(Eval("endH" & $i), $loadendH, "none")
  367.  
  368.             $loadendM = IniRead("setting.ini", "Period-" & $iValue, $i & "-endM", "none")
  369.             GUICtrlSetData(Eval("endM" & $i), $loadendM, "none")
  370.         Else
  371.             If $i = 1 Then
  372.                 $setting_state = 0
  373.             EndIf
  374.             GUICtrlSetState(Eval("lecture" & $i), $GUI_Unchecked)
  375.  
  376.             GUICtrlSetData(Eval("startH" & $i), "none", "none")
  377.             GUICtrlSetData(Eval("startM" & $i), "none", "none")
  378.             GUICtrlSetData(Eval("endH" & $i), "none", "none")
  379.             GUICtrlSetData(Eval("endM" & $i), "none", "none")
  380.             GUICtrlSetState(Eval("check" & $i), $GUI_HIDE)
  381.         EndIf
  382.     Next
  383.  
  384.     disableSetting()
  385.  
  386.     If $auto_state = 1 Then
  387.         For $i = 1 To 7 Step 1
  388.             If GUICtrlRead(Eval("Radio" & $i)) = $GUI_Unchecked Then
  389.                 GUICtrlSetState(Eval("Radio" & $i), $GUI_DISABLE)
  390.             EndIf
  391.         Next
  392.     Else
  393.         GUICtrlSetState($editButton, $GUI_ENABLE)
  394.     EndIf
  395. EndFunc   ;==>loadSetting
  396.  
  397. Func preload()
  398.     If $auto_state = 1 Then
  399.         GUICtrlSetState($disableButton, $GUI_ENABLE)
  400.         GUICtrlSetData($disableButton, "Disable")
  401.         GUICtrlSetBkColor($disableButton, 0xF44336)
  402.  
  403.         GUICtrlSetState($enableButton, $GUI_DISABLE)
  404.         GUICtrlSetData($enableButton, "กำลังทำงาน")
  405.  
  406.         GUICtrlSetState($editButton, $GUI_DISABLE)
  407.         GUICtrlSetState($browseButton, $GUI_DISABLE)
  408.  
  409.         If $fileExtension = ".flv" Then
  410.             GUICtrlSetState($extensionRadio1, $GUI_CHECKED)
  411.             GUICtrlSetState($extensionRadio2, $GUI_DISABLE)
  412.         Else
  413.             GUICtrlSetState($extensionRadio2, $GUI_CHECKED)
  414.             GUICtrlSetState($extensionRadio1, $GUI_DISABLE)
  415.         EndIf
  416.  
  417.     Else
  418.         GUICtrlSetState($enableButton, $GUI_ENABLE)
  419.         GUICtrlSetData($enableButton, "Enable")
  420.         GUICtrlSetBkColor($enableButton, 0x4CAF50)
  421.  
  422.         GUICtrlSetState($disableButton, $GUI_DISABLE)
  423.         GUICtrlSetData($disableButton, "หยุดทำงาน")
  424.  
  425.         GUICtrlSetState($editButton, $GUI_ENABLE)
  426.         GUICtrlSetState($browseButton, $GUI_ENABLE)
  427.  
  428.         If $fileExtension = ".flv" Then
  429.             GUICtrlSetState($extensionRadio1, $GUI_CHECKED)
  430.         Else
  431.             GUICtrlSetState($extensionRadio2, $GUI_CHECKED)
  432.         EndIf
  433.  
  434.         GUICtrlSetState($extensionRadio1, $GUI_ENABLE)
  435.         GUICtrlSetState($extensionRadio2, $GUI_ENABLE)
  436.     EndIf
  437.  
  438.     GUICtrlSetData(Eval("startBefore"), $before)
  439.     GUICtrlSetData(Eval("endAfter"), $after)
  440.  
  441.     $shutdownH1 = IniRead("setting.ini", "Auto", "shutdownH", "none")
  442.     $shutdownM1 = IniRead("setting.ini", "Auto", "shutdownM", "none")
  443.     GUICtrlSetData(Eval("shutdownH"), $shutdownH1)
  444.     GUICtrlSetData(Eval("shutdownM"), $shutdownM1)
  445.  
  446.     If $shutdownH1 == "none" Or $shutdownM1 == "none" Then
  447.         $shutdowntime = "none"
  448.     Else
  449.         $shutdowntime = Int($shutdownH1 & $shutdownM1)
  450.     EndIf
  451. EndFunc   ;==>preload
  452.  
  453. Func DateandTime()
  454.     If @MDAY <> $changeDate Then
  455.         Switch @WDAY
  456.             Case 1
  457.                 $day = "Sunday"
  458.             Case 2
  459.                 $day = "Monday"
  460.             Case 3
  461.                 $day = "Tuesday"
  462.             Case 4
  463.                 $day = "Wednesday"
  464.             Case 5
  465.                 $day = "Thursday"
  466.             Case 6
  467.                 $day = "Friday"
  468.             Case 7
  469.                 $day = "Saturday"
  470.             Case Else
  471.                 $sday = "day"
  472.         EndSwitch
  473.  
  474.         GUICtrlSetData($showDate, @MDAY & "/" & @MON & "/" & @YEAR & @LF & @LF & $day)
  475.         ; กำหนด Folder จัดเก็บของแต่ละวัน
  476.         $save_file = $target & "\" & $day & "\"
  477.  
  478.         If $changeDate > 0 Then
  479.             $setDay = @WDAY
  480.             loadSetting($setDay)
  481.         EndIf
  482.         $changeDate = @MDAY
  483.     EndIf
  484.  
  485.     If @SEC <> $changeTime Then
  486.         GUICtrlSetData($showTime, @HOUR & ":" & @MIN & ":" & @SEC)
  487.         $changeTime = @SEC
  488.     EndIf
  489. EndFunc   ;==>DateandTime
  490.  
  491. Func enable()
  492.     If $target <> "0" Then
  493.         If $setting_state = 2 Then
  494.             MsgBox(0, "แจ้งเตือน", "โปรดทำการบันทึกตารางเวลา ก่อนจะเปิดการทำงาน")
  495.         Else
  496.             GUICtrlSetState($enableButton, $GUI_DISABLE)
  497.             GUICtrlSetData($enableButton, "กำลังทำงาน")
  498.             GUICtrlSetBkColor($enableButton, 0xFFFFFF)
  499.  
  500.             GUICtrlSetState($disableButton, $GUI_ENABLE)
  501.             GUICtrlSetData($disableButton, "Disable")
  502.             GUICtrlSetBkColor($disableButton, 0xF44336)
  503.  
  504.             GUICtrlSetState($browseButton, $GUI_DISABLE)
  505.             GUICtrlSetState($editButton, $GUI_DISABLE)
  506.  
  507.             If $fileExtension = ".flv" Then
  508.                 GUICtrlSetState($extensionRadio2, $GUI_DISABLE)
  509.             Else
  510.                 GUICtrlSetState($extensionRadio1, $GUI_DISABLE)
  511.             EndIf
  512.  
  513.             For $i = 1 To 7 Step 1
  514.                 If GUICtrlRead(Eval("Radio" & $i)) = $GUI_Unchecked Then
  515.                     GUICtrlSetState(Eval("Radio" & $i), $GUI_DISABLE)
  516.                 EndIf
  517.             Next
  518.             $auto_state = 1
  519.             IniWrite("setting.ini", "Auto", "auto_state", $auto_state)
  520.         EndIf
  521.     Else
  522.         MsgBox(0, "แจ้งเตือน", "โปรดระบุที่อยู่ Folder ชื่อ Encoder File สำหรับการจัดเก็บ ก่อนจะเปิดการทำงาน")
  523.     EndIf
  524. EndFunc   ;==>enable
  525.  
  526. Func disable()
  527.     GUICtrlSetState($disableButton, $GUI_DISABLE)
  528.     GUICtrlSetData($disableButton, "หยุดทำงาน")
  529.     GUICtrlSetBkColor($disableButton, 0xFFFFFF)
  530.  
  531.     GUICtrlSetState($enableButton, $GUI_ENABLE)
  532.     GUICtrlSetData($enableButton, "Enable")
  533.     GUICtrlSetBkColor($enableButton, 0x4CAF50)
  534.  
  535.     GUICtrlSetState($editButton, $GUI_ENABLE)
  536.     GUICtrlSetState($browseButton, $GUI_ENABLE)
  537.     GUICtrlSetState($extensionRadio1, $GUI_ENABLE)
  538.     GUICtrlSetState($extensionRadio2, $GUI_ENABLE)
  539.  
  540.     For $i = 1 To 7 Step 1
  541.         GUICtrlSetState(Eval("Radio" & $i), $GUI_ENABLE)
  542.     Next
  543.     $auto_state = 0
  544.     IniWrite("setting.ini", "Auto", "auto_state", $auto_state)
  545. EndFunc   ;==>disable
  546.  
  547. Func view()
  548.     MsgBox(0, "ค่าสถานะ และรายละเอียด", "setting_state = " & $setting_state & @LF & "auto_state = " & $auto_state & @LF & "record_state = " & $record_state & @LF & @LF & "กำลังบันทึก section: " & $section & "  โดยจะจบบันทึกเวลา: " & $newEnd& @LF & "Part ไฟล์: "& $filePart & @LF & "บันทึกก่อนเวลา: " & $before & " นาที" & @LF & "บันทึกหลังเวลาอีก: " & $after & " นาที" & @LF & "โฟลเดอร์จัดเก็บของวันนี้: " & $save_file & @LF & "นามสกุลไฟล์: " & $fileExtension & @LF &"เวลา Shutdown: "& $shutdowntime)
  549. EndFunc   ;==>view
  550.  
  551. Func Schedule()
  552.     If $setting_state <> 2 And $auto_state = 1 Then
  553.         Timer()
  554.     EndIf
  555. EndFunc   ;==>Schedule
  556.  
  557. Func choiceDay($iValue)
  558.     reset()
  559.     $setDay = $iValue
  560.     loadSetting($setDay)
  561. EndFunc   ;==>choiceDay
  562.  
  563. Func choiceLecture($i)
  564.     If GUICtrlRead(Eval("lecture" & $i)) = $GUI_Checked Then
  565.         GUICtrlSetState(Eval("check" & $i), $GUI_SHOW)
  566.         GUICtrlSetState(Eval("check" & $i), $GUI_ENABLE)
  567.         GUICtrlSetState(Eval("startH" & $i), $GUI_ENABLE)
  568.         GUICtrlSetState(Eval("startM" & $i), $GUI_ENABLE)
  569.         GUICtrlSetState(Eval("endH" & $i), $GUI_ENABLE)
  570.         GUICtrlSetState(Eval("endM" & $i), $GUI_ENABLE)
  571.  
  572.     ElseIf GUICtrlRead(Eval("lecture" & $i)) = $GUI_Unchecked Then
  573.  
  574.         GUICtrlSetData(Eval("startH" & $i), "none", "none")
  575.         GUICtrlSetData(Eval("startM" & $i), "none", "none")
  576.         GUICtrlSetData(Eval("endH" & $i), "none", "none")
  577.         GUICtrlSetData(Eval("endM" & $i), "none", "none")
  578.  
  579.         GUICtrlSetState(Eval("check" & $i), $GUI_HIDE)
  580.  
  581.         GUICtrlSetState(Eval("startH" & $i), $GUI_DISABLE)
  582.         GUICtrlSetState(Eval("startM" & $i), $GUI_DISABLE)
  583.         GUICtrlSetState(Eval("endH" & $i), $GUI_DISABLE)
  584.         GUICtrlSetState(Eval("endM" & $i), $GUI_DISABLE)
  585.     EndIf
  586. EndFunc   ;==>choiceLecture
  587.  
  588. Func choiceExtension($iValue)
  589.     If $iValue = 0 Then
  590.         $fileExtension = ".flv"
  591.         IniWrite("setting.ini", "Auto", "Extension", ".flv")
  592.     Else
  593.         $fileExtension = ".f4v"
  594.         IniWrite("setting.ini", "Auto", "Extension", ".f4v")
  595.     EndIf
  596. EndFunc   ;==>choiceExtension
  597.  
  598. Func edit()
  599.     $setting_state = 2
  600.     GUICtrlSetState($editButton, $GUI_DISABLE)
  601.  
  602.     GUICtrlSetState($resetButton, $GUI_ENABLE)
  603.     GUICtrlSetState($saveButton, $GUI_ENABLE)
  604.     GUICtrlSetState($copytoDay, $GUI_ENABLE)
  605.  
  606.     For $i = 1 To 10 Step 1
  607.         GUICtrlSetState(Eval("lecture" & $i), $GUI_ENABLE)
  608.         If GUICtrlRead(Eval("lecture" & $i)) = $GUI_Checked Then
  609.  
  610.             GUICtrlSetState(Eval("startH" & $i), $GUI_ENABLE)
  611.             GUICtrlSetState(Eval("startM" & $i), $GUI_ENABLE)
  612.  
  613.             GUICtrlSetState(Eval("endH" & $i), $GUI_ENABLE)
  614.             GUICtrlSetState(Eval("endM" & $i), $GUI_ENABLE)
  615.  
  616.             GUICtrlSetState(Eval("check" & $i), $GUI_ENABLE)
  617.             GUICtrlSetState(Eval("check" & $i), $GUI_SHOW)
  618.         EndIf
  619.     Next
  620. EndFunc   ;==>edit
  621.  
  622. Func reset()
  623.     For $i = 1 To 10 Step 1
  624.         GUICtrlSetState(Eval("lecture" & $i), $GUI_Unchecked)
  625.  
  626.         GUICtrlSetState(Eval("startH" & $i), $GUI_DISABLE)
  627.         GUICtrlSetData(Eval("startH" & $i), "none", "none")
  628.         GUICtrlSetState(Eval("startM" & $i), $GUI_DISABLE)
  629.         GUICtrlSetData(Eval("startM" & $i), "none", "none")
  630.  
  631.         GUICtrlSetState(Eval("endH" & $i), $GUI_DISABLE)
  632.         GUICtrlSetData(Eval("endH" & $i), "none", "none")
  633.         GUICtrlSetState(Eval("endM" & $i), $GUI_DISABLE)
  634.         GUICtrlSetData(Eval("endM" & $i), "none", "none")
  635.  
  636.         GUICtrlSetState(Eval("check" & $i), $GUI_HIDE)
  637.     Next
  638. EndFunc   ;==>reset
  639.  
  640. Func save($iValue)
  641.     If checkSection() = True And checkData() = True And checkTime() = True Then
  642.         saveSetting($iValue)
  643.         MsgBox(0, "แจ้งเตือน", "ระบบได้ทำการบันทึกตารางเวลาเรียบร้อยแล้ว")
  644.         loadSetting($iValue)
  645.  
  646.         If GUICtrlRead(Eval("lecture1")) = $GUI_Checked Then
  647.             $setting_state = 1
  648.         Else
  649.             $setting_state = 0
  650.         EndIf
  651.     EndIf
  652. EndFunc   ;==>save
  653.  
  654. Func saveSetting($iValue)
  655.     If GUICtrlRead(Eval("Radio" & $iValue)) = $GUI_Checked Then
  656.         For $i = 1 To 10 Step 1
  657.             If GUICtrlRead(Eval("lecture" & $i)) = $GUI_Checked Then
  658.                 IniWrite("setting.ini", "Day-" & $iValue, "lecture" & $i, "1")
  659.                 IniWrite("setting.ini", "Period-" & $iValue, $i & "-startH", GUICtrlRead(Eval("startH" & $i)))
  660.                 IniWrite("setting.ini", "Period-" & $iValue, $i & "-startM", GUICtrlRead(Eval("startM" & $i)))
  661.                 IniWrite("setting.ini", "Period-" & $iValue, $i & "-endH", GUICtrlRead(Eval("endH" & $i)))
  662.                 IniWrite("setting.ini", "Period-" & $iValue, $i & "-endM", GUICtrlRead(Eval("endM" & $i)))
  663.             Else
  664.                 IniWrite("setting.ini", "Day-" & $iValue, "lecture" & $i, "0")
  665.                 IniWrite("setting.ini", "Period-" & $iValue, $i & "-startH", "none")
  666.                 IniWrite("setting.ini", "Period-" & $iValue, $i & "-startM", "none")
  667.                 IniWrite("setting.ini", "Period-" & $iValue, $i & "-endH", "none")
  668.                 IniWrite("setting.ini", "Period-" & $iValue, $i & "-endM", "none")
  669.             EndIf
  670.         Next
  671.     EndIf
  672. EndFunc   ;==>saveSetting
  673.  
  674. Func disableSetting()
  675.     For $i = 1 To 10 Step 1
  676.         If GUICtrlRead(Eval("lecture" & $i)) = $GUI_Checked Then
  677.             GUICtrlSetState(Eval("check" & $i), $GUI_SHOW)
  678.         EndIf
  679.  
  680.         GUICtrlSetState(Eval("lecture" & $i), $GUI_DISABLE)
  681.         GUICtrlSetState(Eval("startH" & $i), $GUI_DISABLE)
  682.         GUICtrlSetState(Eval("startM" & $i), $GUI_DISABLE)
  683.         GUICtrlSetState(Eval("endH" & $i), $GUI_DISABLE)
  684.         GUICtrlSetState(Eval("endM" & $i), $GUI_DISABLE)
  685.         GUICtrlSetState(Eval("check" & $i), $GUI_DISABLE)
  686.     Next
  687.     GUICtrlSetData($copytoDay, "เลือกวันนำเข้า")
  688.     GUICtrlSetState($copytoDay, $GUI_DISABLE)
  689. EndFunc   ;==>disableSetting
  690.  
  691. Func checkData()
  692.     $ckData = True
  693.     For $i = 1 To 10 Step 1
  694.         If GUICtrlRead(Eval("lecture" & $i)) = $GUI_Checked Then
  695.             If GUICtrlRead(Eval("startH" & $i)) == "none" Or GUICtrlRead(Eval("startM" & $i)) == "none" Or GUICtrlRead(Eval("endH" & $i)) == "none" Or GUICtrlRead(Eval("endM" & $i)) == "none" Then
  696.                 $ckData = False
  697.                 MsgBox(0, "แจ้งเตือน", "โปรดตั้งค่าตารางเวลาของ section " & $i & " ให้ครบ ก่อนทำการบันทึกตารางเวลา")
  698.                 ExitLoop
  699.             EndIf
  700.         Else
  701.             ExitLoop
  702.         EndIf
  703.     Next
  704.     Return $ckData
  705. EndFunc   ;==>checkData
  706.  
  707. Func checkSection()
  708.     $ckSection = True
  709.     For $i = 2 To 10 Step 1
  710.         If GUICtrlRead(Eval("lecture" & $i)) = $GUI_Checked Then
  711.             If GUICtrlRead(Eval("lecture" & $i - 1)) = $GUI_Unchecked Then
  712.                 $ckSection = False
  713.                 MsgBox(0, "แจ้งเตือน", "โปรดตั้งค่าตารางเวลาของ section " & $i - 1 & "  อย่างถูกต้อง เสียก่อน")
  714.                 ExitLoop
  715.             EndIf
  716.         EndIf
  717.     Next
  718.     Return $ckSection
  719. EndFunc   ;==>checkSection
  720.  
  721. Func checkTime()
  722.     $ckTime = True
  723.     $temp = 0
  724.     For $i = 1 To 10 Step 1
  725.         If GUICtrlRead(Eval("lecture" & $i)) = $GUI_Checked Then
  726.             Local $Diff
  727.             Local $cStart
  728.             $Start = Int(GUICtrlRead(Eval("startH" & $i)) & GUICtrlRead(Eval("startM" & $i)))
  729.             $End = Int(GUICtrlRead(Eval("endH" & $i)) & GUICtrlRead(Eval("endM" & $i)))
  730.  
  731.             If $i > 1 Then
  732.                 If GUICtrlRead(Eval("startH" & $i)) = 00 Then
  733.                     ; 00:00 and 00:10
  734.                     $cStart = Int(GUICtrlRead(Eval("startM" & $i)))
  735.                 Else
  736.                     ; 01:00 => 00:60
  737.                     If GUICtrlRead(Eval("startM" & $i)) = 00 Then
  738.                         $cStart = Int((GUICtrlRead(Eval("startH" & $i)) - 1) & 60)
  739.                         ; 01:10 => 01:10
  740.                     Else
  741.                         $cStart = Int(GUICtrlRead(Eval("startH" & $i)) & GUICtrlRead(Eval("startM" & $i)))
  742.                     EndIf
  743.                 EndIf
  744.  
  745.                 $Diff = $cStart - $temp
  746.  
  747.                 If $temp >= $Start Or $Start >= $End Or $Diff = 5 Then
  748.                     $ckTime = False
  749.                     MsgBox(0, "แจ้งเตือน", "โปรดตั้งค่าตารางเวลาของ section " & $i & "  อย่างถูกต้อง" & @LF & @LF & " - ต้องเรียงลำดับของเวลาเริ่มต้น - เวลาสิ้นสุด จากน้อยไปหามาก " & @LF & " - ต้องเว้นช่วงระยะห่างระหว่าง section 10 นาที")
  750.                     ExitLoop
  751.                 EndIf
  752.                 $temp = $End
  753.             EndIf
  754.  
  755.             If $i = 1 Then
  756.                 If $Start >= $End Then
  757.                     $ckTime = False
  758.                     MsgBox(0, "แจ้งเตือน", "โปรดตั้งค่าตารางเวลาของ section " & $i & "  อย่างถูกต้อง" & @LF & @LF & " - ต้องเรียงลำดับของเวลาเริ่มต้น - เวลาสิ้นสุด จากน้อยไปหามาก ")
  759.                     ExitLoop
  760.                 EndIf
  761.                 $temp = $End
  762.             EndIf
  763.             ;MsgBox(0,"Value", "$Start : "&$Start&@LF&"$End : "&$End&@LF&"$cStart : "&$cStart&@LF)
  764.         Else
  765.             ExitLoop
  766.         EndIf
  767.     Next
  768.     Return $ckTime
  769. EndFunc   ;==>checkTime
  770.  
  771. Func Timer()
  772.     Local $newStart
  773.     Local $oldStart
  774.     Local $oldEnd
  775.     Local $current_time
  776.  
  777.    Local $tempstartH
  778.    Local $tempstartM
  779.    Local $tempendH
  780.    Local $tempendM
  781.  
  782.     Switch $record_state
  783.         Case "start"
  784.             For $i = 1 To 10 Step 1
  785.                 If $GUI_Checked = GUICtrlRead(Eval("lecture" & $i)) Then
  786. ;~                  Local $tempstartH
  787. ;~                  Local $tempstartM
  788. ;~                  Local $tempendH
  789. ;~                  Local $tempendM
  790.  
  791.                     If GUICtrlRead(Eval("startH" & $i)) = 00 Then
  792.                         $tempstartH = 00
  793.                         $tempstartM = GUICtrlRead(Eval("startM" & $i))
  794.                     Else
  795.                         If GUICtrlRead(Eval("startM" & $i)) = 00 Then
  796.                             $tempstartH = GUICtrlRead(Eval("startH" & $i)) - 1
  797.                             $tempstartM = 60
  798.                         Else
  799.                             $tempstartH = GUICtrlRead(Eval("startH" & $i))
  800.                             $tempstartM = GUICtrlRead(Eval("startM" & $i))
  801.                         EndIf
  802.                     EndIf
  803.  
  804.                     $oldStart = Int($tempstartH & $tempstartM)
  805.                     $newStart = Int($oldStart - $before)
  806.  
  807.                     If $oldStart = 0 Then
  808.                         $newStart = 0
  809.                     EndIf
  810.  
  811.                     ;0005, 0055+5 => 0060
  812.                     $tempendH = GUICtrlRead(Eval("endH" & $i))
  813.                     $tempendM = GUICtrlRead(Eval("endM" & $i))
  814.  
  815.                     $oldEnd = Int($tempendH & $tempendM)
  816.  
  817.                     $current_time = Int(@HOUR & @MIN)
  818.  
  819.                     If $current_time >= $newStart And $current_time < $oldEnd Then
  820.                         $section = $i
  821.                         $nametime = GUICtrlRead(Eval("startH" & $i)) & GUICtrlRead(Eval("startM" & $i))
  822.  
  823.                         Local $checknametime = IniRead("setting.ini", "Auto", "latest_nametime", "2400")
  824.                         Local $checkDay = IniRead("setting.ini", "Auto", "latest_day", "0")
  825.  
  826.                         ; กรณี Restart => filename__1, filename__2, filename__3
  827.                         If $nametime = $checknametime And $checkDay = @MDAY Then
  828.                             $filePart += 1
  829.                             IniWrite("setting.ini", "Auto", "latest_part", $filePart)
  830.                         ; กรณี Encoder file ปกติ => filename__0
  831.                         Else
  832.                             $filePart = 0
  833.                             IniWrite("setting.ini", "Auto", "latest_part", $filePart)
  834.  
  835.                             IniWrite("setting.ini", "Auto", "latest_nametime", $nametime)
  836.                             IniWrite("setting.ini", "Auto", "latest_day", @MDAY)
  837.                         EndIf
  838.  
  839.                         $newEnd = $oldEnd + $after
  840.                         If $newEnd = 2360 Then
  841.                             $newEnd = 2358
  842.                         EndIf
  843.  
  844.                         ; กรณีคืนค่าเดิม
  845.                         ;IniWrite("setting.ini", "Auto", "latest_newEnd", $newEnd)
  846.                         ;IniWrite("setting.ini", "Auto", "latest_section", $section)
  847.  
  848.                         $record_state = "stop"
  849.                         startRecord()
  850.  
  851.                         ExitLoop
  852.                     EndIf
  853.                 Else
  854.                     doShutdown()
  855.                     ExitLoop
  856.                 EndIf
  857.             Next
  858.  
  859.         Case "stop"
  860.             $current_time = Int(@HOUR & @MIN)
  861.             If $current_time >= $newEnd Then
  862.                 $record_state = "start"
  863.                 $newEnd = 0
  864.                 $section = 0
  865.  
  866.                 stopRecord()
  867.                   ;;end state
  868.                   Local $startTime = $tempstartH & $tempstartM
  869.                   Local $endTime = $tempendH & $tempendM
  870.                   funcFileMove($startTime,$endTime) ;<<
  871.  
  872.                 Sleep(5000)
  873.             EndIf
  874.     EndSwitch
  875.  
  876. EndFunc   ;==>Timer
  877.  
  878. Func Debug()
  879.  
  880. EndFunc
  881.  
  882. Func funcFileMove($startTime,$endTime)
  883.  
  884.  
  885.    $sDate = StringReplace(_NowDate(), "/", "-")
  886.    $folderLocate = "C:\Encode File\"
  887.    $todayFloder = $sDate &"\"
  888.  
  889.    $fileNameTime = $startTime&"_"& $startTime & "__" & $sDate
  890.  
  891.  
  892.  
  893.  
  894.    $desFileName = $folderLocate & $todayFloder & $fileNameTime & ".wmv"
  895.    FileMove($folderLocate&"temp.wmv", $desFileName, $FC_OVERWRITE + $FC_CREATEPATH)
  896.  
  897.    ConsoleWrite("FileMove Execute")
  898. EndFunc
  899.  
  900. Func setTime()
  901.     $before = GUICtrlRead(Eval("startBefore"))
  902.     $after = GUICtrlRead(Eval("endAfter"))
  903.  
  904.     IniWrite("setting.ini", "Auto", "startBefore", $before)
  905.     IniWrite("setting.ini", "Auto", "endAfter", $after)
  906. EndFunc   ;==>setTime
  907.  
  908. Func startRecord()
  909.     WinActivate($title)
  910.     If Not WinActive($title) Then
  911.         Run("C:\Program Files\Windows Media Components\Encoder\wmenc.exe")
  912.         WinWaitActive($title)
  913.         WinActivate($title)
  914.         Sleep(25000)
  915.     ; กด Stop กำลังบันทึกปัจจุบัน เพื่อจะเริ่มกด Start ใหม่ต่อไป
  916.     Else
  917.         Local $status = ControlGetText($title, "", "[CLASS:Titan:CStatusBar; INSTANCE:1]")
  918.         If $status == " Encoder capturing" Then
  919.             Sleep(1000)
  920.             ControlSend($title, "", "", "^+{S}")
  921.  
  922.             Do
  923.                Local $status = ControlGetText($title, "", "[CLASS:Titan:CStatusBar; INSTANCE:1]")
  924.                Sleep(10)
  925.             Until $status == " Encoder ready"
  926.             Sleep(4000)
  927.         EndIf
  928.     EndIf
  929.  
  930.     ;Sleep(1000)
  931.     ;WinSetState("Adobe Flash Media Live Encoder 3.2", "", @SW_MAXIMIZE) ; Maximize windows
  932.  
  933.     ; กด Start
  934.     $sDate = StringReplace(_NowDate(), "/", "-")
  935.     $fileName = $save_file & $nametime & "__" & $sDate & "__" & $filePart & $fileExtension
  936.  
  937.     ;Sleep(1000)
  938.     ;ControlSetText("Adobe Flash Media Live Encoder 3.2", "", "[CLASS:Edit;INSTANCE:24]", $fileName)
  939.     Sleep(2000)
  940.     ControlSend($title, "", "", "^+{E}")
  941.     Sleep(5000)
  942. EndFunc   ;==>startRecord
  943.  
  944. Func stopRecord()
  945.  
  946.    Sleep(1000)
  947.    WinActivate($title)
  948.    Sleep(500)
  949.  
  950.    ControlSend($title, "", "", "^+{S}")
  951.  
  952.  
  953. ;~    Do
  954. ;~    Local $status = ControlGetText($title, "", "[CLASS:Titan:CStatusBar; INSTANCE:1]")
  955. ;~    Sleep(10)
  956. ;~    Until $status == " Encoder capturing"
  957. ;~
  958. ConsoleWrite("Stop")
  959.    Sleep(5000)
  960. EndFunc   ;==>stopRecord
  961.  
  962. Func browse()
  963.     ; Create a constant variable in Local scope of the message to display in FileSelectFolder.
  964.     Local Const $sMessage = "เลือก Folder"
  965.  
  966.     ; Display an open dialog to select a file.
  967.     Local $sFileSelectFolder = FileSelectFolder($sMessage, "")
  968.     If @error Then
  969.         ; Display the error message.
  970.         $target = IniRead("setting.ini", "Auto", "FileSelectFolder", "0")
  971.         $save_file = $target & "\" & $day & "\"
  972.         MsgBox(0, "แจ้งเตือน", "คุณไม่ได้เลือกที่อยู่ Folder ชื่อ Encoder File ดังนั้น จะใช้ที่่อยู่ล่าสุดที่เคยเลือกไว้:" & @CRLF & $target)
  973.     Else
  974.         ; Display the selected folder.
  975.         $target = $sFileSelectFolder
  976.         IniWrite("setting.ini", "Auto", "FileSelectFolder", $target)
  977.         $save_file = $target & "\" & $day & "\"
  978.         MsgBox($MB_SYSTEMMODAL, "แจ้งเตือน", "คุณได้เลือกที่อยู่ Folder ชื่อ Encoder File สำหรับจัดเก็บข้อมูลดังต่อไปนี้:" & @CRLF & $target)
  979.     EndIf
  980. EndFunc   ;==>browse
  981.  
  982. Func setShutdown()
  983.     Local $shutdownH2 = GUICtrlRead(Eval("shutdownH"))
  984.     Local $shutdownM2 = GUICtrlRead(Eval("shutdownM"))
  985.  
  986.     IniWrite("setting.ini", "Auto", "shutdownH", $shutdownH2)
  987.     IniWrite("setting.ini", "Auto", "shutdownM", $shutdownM2)
  988.  
  989.     If $shutdownH2 == "none" Or $shutdownM2 == "none" Then
  990.         $shutdowntime = "none"
  991.     Else
  992.         $shutdowntime = Int($shutdownH2 & $shutdownM2)
  993.     EndIf
  994. EndFunc
  995.  
  996. Func doShutdown()
  997.     If $shutdowntime <> "none" Then
  998.         $current_time = Int(@HOUR & @MIN)
  999.         If $current_time = $shutdowntime Then
  1000.             Sleep(5000)
  1001.             WinClose("Adobe Flash Media Live Encoder 3.2")
  1002.             Sleep(10000)
  1003.             Shutdown(1)
  1004.             Exit
  1005.         EndIf
  1006.     EndIf
  1007. EndFunc
  1008.  
  1009. Func copyDay()
  1010.     $cday = GUICtrlRead(Eval("copytoDay"))
  1011.  
  1012.     Switch $cday
  1013.         Case "อาทิตย์"
  1014.             getSetting(1)
  1015.         Case "จันทร์"
  1016.             getSetting(2)
  1017.         Case "อังคาร"
  1018.             getSetting(3)
  1019.         Case "พุธ"
  1020.             getSetting(4)
  1021.         Case "พฤหัสบดี"
  1022.             getSetting(5)
  1023.         Case "ศุกร์"
  1024.             getSetting(6)
  1025.         Case "เสาร์"
  1026.             getSetting(7)
  1027.  
  1028.     EndSwitch
  1029. EndFunc
  1030.  
  1031. Func getSetting($iValue)
  1032.  
  1033.     reset()
  1034.  
  1035.     For $i = 1 To 10 Step 1
  1036.  
  1037.         $loadLecture = IniRead("setting.ini", "Day-" & $iValue, "lecture" & $i, "0")
  1038.  
  1039.         If $loadLecture = 1 Then
  1040.  
  1041.             GUICtrlSetState(Eval("lecture" & $i), $GUI_Checked)
  1042.  
  1043.             $loadstartH = IniRead("setting.ini", "Period-" & $iValue, $i & "-startH", "none")
  1044.             GUICtrlSetData(Eval("startH" & $i), $loadstartH, "none")
  1045.  
  1046.             $loadstartM = IniRead("setting.ini", "Period-" & $iValue, $i & "-startM", "none")
  1047.             GUICtrlSetData(Eval("startM" & $i), $loadstartM, "none")
  1048.  
  1049.             $loadendH = IniRead("setting.ini", "Period-" & $iValue, $i & "-endH", "none")
  1050.             GUICtrlSetData(Eval("endH" & $i), $loadendH, "none")
  1051.  
  1052.             $loadendM = IniRead("setting.ini", "Period-" & $iValue, $i & "-endM", "none")
  1053.             GUICtrlSetData(Eval("endM" & $i), $loadendM, "none")
  1054.  
  1055.             GUICtrlSetState(Eval("startH" & $i), $GUI_ENABLE)
  1056.             GUICtrlSetState(Eval("startM" & $i), $GUI_ENABLE)
  1057.  
  1058.             GUICtrlSetState(Eval("endH" & $i), $GUI_ENABLE)
  1059.             GUICtrlSetState(Eval("endM" & $i), $GUI_ENABLE)
  1060.  
  1061.             GUICtrlSetState(Eval("check" & $i), $GUI_ENABLE)
  1062.             GUICtrlSetState(Eval("check" & $i), $GUI_SHOW)
  1063.         Else
  1064.  
  1065.             GUICtrlSetState(Eval("lecture" & $i), $GUI_Unchecked)
  1066.  
  1067.             GUICtrlSetData(Eval("startH" & $i), "none", "none")
  1068.             GUICtrlSetData(Eval("startM" & $i), "none", "none")
  1069.             GUICtrlSetData(Eval("endH" & $i), "none", "none")
  1070.             GUICtrlSetData(Eval("endM" & $i), "none", "none")
  1071.             GUICtrlSetState(Eval("check" & $i), $GUI_HIDE)
  1072.         EndIf
  1073.     Next
  1074. EndFunc   ;==>getSetting
  1075.  
  1076. Func _ReduceMemory($i_PID = -1)
  1077.     If $i_PID <> -1 Then
  1078.         Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID)
  1079.         $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
  1080.         DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
  1081.     Else
  1082.         $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
  1083.     EndIf
  1084.  
  1085.     Return $ai_Return[0]
  1086. EndFunc ;==>_ReduceMemory
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement