Ivan_L

LongCutImpruved

Mar 15th, 2020
364
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Misc.au3>
  2. #include <Constants.au3>
  3. #include <MsgBoxConstants.au3>
  4. #include <WinAPI.au3>
  5. #include <Array.au3>
  6. #include <GUIConstants.au3>
  7.  
  8.  
  9. Global $LaserOff = 438782087
  10. Global $LaserOn = 2402470436
  11. Global $mousePos = MouseGetPos()
  12. Global $mouseX = $mousePos[0]
  13. Global $mouseY = $mousePos[1]
  14. Global $Value = 0
  15. Global $WTValue = 0
  16. Global $FTValue = 0
  17. Global $WTValueSec = 0
  18. Global $FTValueSec = 0
  19. Global $SliderValue = 0
  20. Global $sWTimer = 0
  21. Global $sFTimer = 0
  22.  
  23. Local $hGUI = GUICreate("Длинный рез",350,150)
  24.  
  25. GUICtrlCreateLabel("Для долгого реза с частым перегревом сопла.", 10,10,300,20)
  26. $Start= GUICtrlCreateButton("Start",10,110,90,30)
  27.  
  28.  
  29. $SliderWT = GUICtrlCreateSlider(10,40,150,20)
  30. GUICtrlSetLimit($SliderWT,6,1)
  31. $SliderFT = GUICtrlCreateSlider(10,70,150,20)
  32. GUICtrlSetLimit($SliderFT,10,1)
  33.  
  34. Global $sWorkTime = "Work time: "
  35. Global $sFlexTime = "Flex time: "
  36. Global $sWaitTime = "Wait time: "
  37.  
  38. $LableWT = GUICtrlCreateLabel($sWorkTime,170,40,100,20)
  39. $LableFT = GUICtrlCreateLabel($sFlexTime,170,70,100,20)
  40.  
  41. Global $WTimerLabel = GUICtrlCreateLabel($sWTimer,280,40,100,20)
  42. Global $FTimerLabel = GUICtrlCreateLabel($sFTimer,280,70,100,20)
  43. Global $WaitTimeLabel = GUICtrlCreateLabel($sWaitTime,210,100,100,20)
  44.  
  45. ;------------------------------------------------------------------------------------
  46. ;Push Start Button
  47. ;------------------------------------------------------------------------------------
  48. Func PushStart()
  49.  
  50.     WinActivate ("[CLASS:TfrmCypCut]","")
  51.     $mousePos = MouseGetPos()
  52.     $mouseX = $mousePos[0]
  53.     $mouseY = $mousePos[1]
  54.     MouseClick("left", 1059,481 ,1,1)
  55.     MouseMove($mouseX,$mouseY,1)
  56.  
  57. EndFunc
  58. ;------------------------------------------------------------------------------------
  59. ;Push Pause Button
  60. ;------------------------------------------------------------------------------------
  61. Func PushPause()
  62.  
  63.     WinActivate ("[CLASS:TfrmCypCut]","")
  64.     $mousePos = MouseGetPos()
  65.     $mouseX = $mousePos[0]
  66.     $mouseY = $mousePos[1]
  67.     MouseClick("left", 70,85 ,1,1)
  68.     MouseMove($mouseX,$mouseY,1)
  69.  
  70. EndFunc
  71. ;------------------------------------------------------------------------------------
  72. ; Push Resume Button
  73. ;------------------------------------------------------------------------------------
  74. Func PushResume()
  75.  
  76.     WinActivate ("[CLASS:TfrmCypCut]","")
  77.     $mousePos = MouseGetPos()
  78.     $mouseX = $mousePos[0]
  79.     $mouseY = $mousePos[1]
  80.     MouseClick("left", 122,85 ,1,1)
  81.     MouseMove($mouseX,$mouseY,1)
  82.  
  83. EndFunc
  84. ;------------------------------------------------------------------------------------
  85. Func ReadSliderWT()
  86.  
  87.     $Value = GUICtrlRead($SliderWT,$GUI_READ_EXTENDED)
  88.     $SliderValue = $Value * 5
  89.     Return $SliderValue
  90.  
  91. EndFunc
  92. ;------------------------------------------------------------------------------------
  93. Func ReadSliderFT()
  94.  
  95.     $Value = GUICtrlRead($SliderFT,$GUI_READ_EXTENDED)
  96.    
  97.     Return $Value
  98.  
  99. EndFunc
  100. ;------------------------------------------------------------------------------------
  101. Func DeleteLabels()
  102.  
  103.     GUICtrlDelete($WTimerLabel)
  104.     GUICtrlDelete($FTimerLabel)
  105.     GUICtrlDelete($WaitTimeLabel)
  106.  
  107. EndFunc
  108. ;------------------------------------------------------------------------------------
  109. Func UpDateLabels($WTimer,$FTimer,$WaitTime,$WorkTime,$FlexTime,$WaitTimeSec)
  110.  
  111.  
  112.     $sWTimer = $WTimer& " sec./"&$WorkTime& " sec."
  113.     $sFTimer = $FTimer& " sec./"&$FlexTime& " sec."
  114.     $sWaitTime = "Wait time: "&$WaitTime& " sec./"&$WaitTimeSec& " sec."
  115.  
  116. $WTimerLabel = GUICtrlCreateLabel($sWTimer,257,40,100,20)
  117. $FTimerLabel = GUICtrlCreateLabel($sFTimer,257,70,100,20)
  118. $WaitTimeLabel = GUICtrlCreateLabel($sWaitTime,207,100,140,20)
  119.  
  120.  
  121. EndFunc
  122. ;------------------------------------------------------------------------------------
  123. Func ESC()
  124.  
  125. EndFunc
  126. ;------------------------------------------------------------------------------------
  127. Func StartProcess($WorkTime,$FlexTime,$WaitTimeSec)
  128.  
  129. WinActivate ("[CLASS:TfrmCypCut]","")
  130.  
  131. $WTimer = 0
  132. $FTimer = 0
  133. $WaitTime = 0
  134.  
  135. While 1
  136. Sleep(500)
  137.     If _IsPressed("1B") Then
  138.         ExitLoop
  139.     EndIf
  140.  
  141.     $LaserCheck = PixelChecksum(1187,386,1260,408)
  142.  
  143.     If $LaserCheck = $LaserOff AND $WTimer = 0  Then
  144.         PushStart()
  145.         $WTimer = $WTimer + 0.5
  146.  
  147.  
  148.     ElseIf  $LaserCheck = $LaserOn Then    
  149.         $WTimer = $WTimer + 0.5
  150.  
  151.     EndIf
  152.  
  153.     If $LaserCheck = $LaserOff AND $FTimer = 0 AND $WTimer>=$WorkTime Then
  154.         PushPause()
  155.         $FTimer = $FTimer + 0.5
  156.  
  157.  
  158.     ElseIf $FTimer<=$FlexTime AND $LaserCheck = $LaserOff AND $WTimer>=$WorkTime Then
  159.         $FTimer = $FTimer + 0.5
  160.  
  161.        
  162.     ElseIf $FTimer>$FlexTime Then
  163.         PushResume()
  164.         $WTimer = 0.5
  165.         $FTimer = 0
  166.  
  167.     EndIf
  168.    
  169.     If $LaserCheck = $LaserOn   Then
  170.        
  171.         $WaitTime = 0
  172.        
  173.     EndIf
  174.  
  175.     If $LaserCheck = $LaserOff   Then
  176.  
  177.         $WaitTime = $WaitTime + 0.5
  178.  
  179.     EndIf
  180.  
  181.     If $WaitTime > $WaitTimeSec Then
  182.         ExitLoop   
  183.     EndIf
  184.  
  185.     DeleteLabels()
  186.     UpDateLabels($WTimer,$FTimer,$WaitTime,$WorkTime,$FlexTime,$WaitTimeSec)
  187.  
  188. WEnd
  189. EndFunc
  190. ;------------------------------------------------------------------------------------
  191. Func SliderRead()
  192. Local $aValueArr[3] = [0,0,0]
  193.     $WTValue = ReadSliderWT()
  194.     ;MsgBox("","",$WTValue)
  195.     $sWorkTime = "Work time "&$WTValue&" min." 
  196.     GUICtrlSetData($LableWT,$sWorkTime)
  197.  
  198.     $FTValue = ReadSliderFT()
  199.     ;MsgBox("","",$WTValue)
  200.     $sFlexTime = "Flex time "&$FTValue&" min." 
  201.     GUICtrlSetData($LableFT,$sFlexTime)
  202.  
  203.     $WTValueSec = $WTValue * 60
  204.     $FTValueSec = $FTValue * 60
  205.     $WaitTimeSec = $FTValueSec+10
  206.  
  207.     $aValueArr[0] = $WTValueSec
  208.     $aValueArr[1] = $FTValueSec
  209.     $aValueArr[2] = $WaitTimeSec
  210.     Return $aValueArr
  211. EndFunc
  212. ;------------------------------------------------------------------------------------
  213. ;Programm
  214. ;------------------------------------------------------------------------------------
  215.  
  216. GUISetState(@SW_SHOW,$hGUI)
  217. Sleep(5)
  218. WinMove("Длинный рез","", 914,500 )
  219. Sleep(5)
  220. WinSetOnTop("Длинный рез","",1)
  221. Local $aArr[3] = [0,0,0]
  222. While 1
  223. Sleep(100)
  224.  
  225.     $aArr  = SliderRead()
  226.  
  227.     Switch GUIGetMsg()
  228.         Case $GUI_EVENT_CLOSE
  229.         ExitLoop
  230.  
  231.         Case $Start
  232.         StartProcess($aArr[0],$aArr[1],$aArr[2])           
  233.            
  234.     EndSwitch
  235. WEnd
RAW Paste Data