Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #SingleInstance Force
  2.  
  3. Gui, Font, s8, Verdana
  4. Gui, Margin, 10, 10
  5.  
  6. Gui, Add, Text, Section, Value 1:
  7. Gui, Add, Edit, vValue1 gFillInValue2 hwndHWND
  8.  
  9. Gui, Add, Text, , `% Increase:
  10. Gui, Add, Edit, vPercentIncrease gFillInValue2 hwndHWND
  11.  
  12. Gui, Add, Text, , `% Decrease:
  13. Gui, Add, Edit, vPercentDecrease hwndHWND
  14.  
  15. Gui, Add, Text, , Value 2:
  16. Gui, Add, Edit, vValue2 hwndHWND Disabled
  17.  
  18. Gui, Add, Button, wp gToggle hwndToggleHWND, Start
  19. Gui, Add, Button, wp gErase hwndHWND, Erase
  20. Gui, Add, ListView, YS h185 w550 , Time|Rate|Message
  21. Gui, Show,, GBP Rate Monitor
  22.  
  23.  
  24. Return
  25.  
  26. Erase:
  27.     SetTimer, GetRate, OFF
  28.     GuiControl,,Value1, % ""
  29.     GuiControl,,Value2, % ""
  30.     GuiControl,,PercentIncrease, % ""
  31.     GuiControl,,PercentDecrease, % ""
  32.     LV_Delete()
  33. Return
  34.  
  35. Toggle:
  36.     Gui, Submit, NoHide
  37.     If (!Value1 or !PercentIncrease or !PercentDecrease){
  38.         InsertLV("N/A", "Entered values are invalid")
  39.         Return
  40.     }
  41.    
  42.     If (Toggle := !Toggle){
  43.         SearchMode := 1
  44.         SetTimer, GetRate, 1000
  45.     }
  46.    
  47.     GuiControl, % (Toggle) ? "Disable" : "Enable", Value1
  48.     GuiControl, % (Toggle) ? "Disable" : "Enable", PercentIncrease
  49.     GuiControl, % (Toggle) ? "Disable" : "Enable", PercentDecrease
  50.     GuiControl,, % ToggleHWND, % (Toggle ? "Starting..." : "Stopping...")
  51.    
  52.     If (Toggle)
  53.         GoSub GetRate
  54. Return
  55.  
  56. FillInValue2:
  57.     Gui, Submit, NoHide
  58.     GuiControl,,Value2, % Round(Value1 * (100 + PercentIncrease ) / 100, 2)
  59. Return
  60.  
  61.  
  62. ; SubmitGUI:
  63. ;   Gui, Submit, NoHide
  64.     ; If (!Value1 OR !PercentIncrease){
  65.     ;   GuiControl,,Value2, % ""
  66.     ;   Return
  67.     ;   }
  68.    
  69.     ; Value2 := Round(Value1 * (100 + PercentIncrease ) / 100, 2)
  70.     ; GuiControl,,Value2, % Value2
  71. ; Return
  72.  
  73. GetRate:
  74.    
  75.     If Rate
  76.         RateOld := Rate
  77.    
  78.     Rate := GetRate()
  79.     If Rate {
  80.         If (SearchMode = 1){
  81.            
  82.             IF (Rate >= Value1){
  83.                 SearchMode := 2
  84.                 ; Click 1
  85.                 ; Click 2
  86.                 Value2 := Round(Value1 * (100 + PercentIncrease ) / 100, 2)
  87.                 GuiControl,,Value2, % Value2
  88.                 Message := "Rate was >= " Value1 " - Starting search for Rate <= " Value2
  89.             } else
  90.                 Message := "Rate was not >= " Value1
  91.         } else If (SearchMode = 2){
  92.            
  93.             If (Rate <= Value2){
  94.                 SearchMode := 1
  95.                 ; Click 1
  96.                 ; Click 2
  97.                 Value1 := Round(Value2 * (100 - PercentDecrease) / 100, 2)
  98.                 GuiControl,,Value1, % Value1       
  99.                 Message := "Rate was <= " Value2 " - Starting search for Rate >= " Value1
  100.             } else
  101.                 Message := "Rate was not <= " Value2
  102.         }
  103.        
  104.         If RateOld
  105.             Increase := ((Rate - RateOld) / RateOld) * 100
  106.     } else {
  107.         Message := "Could not find rate on page."
  108.     }
  109.  
  110.     InsertLV(Rate, Message)
  111.  
  112.     GuiControl,, % ToggleHWND, % Toggle ? "Stop" : "Start"
  113.     If (!Toggle)
  114.         SetTimer, GetRate, OFF
  115.  
  116. Return
  117.  
  118. GuiClose:
  119.     ExitApp
  120. Return
  121.  
  122. GetRate(){    
  123.     URL := "https://www.binance.com/en/trade/ETH_USDT"
  124.     whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
  125.     whr.Open("GET", URL)
  126.     whr.Send()
  127.     RegExMatch(whr.ResponseText, "cdRUYO"">([\d\.]+)<", Match)
  128.     Return Match1
  129. }
  130.  
  131. InsertLV(Rate, Message){
  132.     FormatTime, Time,, % "hh:mm tt"
  133.     LV_Add(, Time, Rate, Message)  
  134.  
  135.     Loop 3
  136.         LV_ModifyCol(A_Index, "AutoHdr")
  137. }
  138.  
  139. ^+a::
  140. MouseGetPos, OutputVarX, OutputVarY
  141. return
  142.  
  143. !+a::
  144. Click, %OutputVarX%, %OutputVarY%
  145. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement