Advertisement
OgreVorbis

Immediate Bitcoin Price Display

Jul 9th, 2022
1,461
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.38 KB | None | 0 0
  1. #include <Misc.au3>
  2. #include <WindowsConstants.au3>
  3. #include <WinAPISysWin.au3>
  4.  
  5. ; THIS SCRIPT WILL IMMEDIATELY DISPLAY BITCOIN PRICE WHEN PRESSING CTRL + ALT + B
  6.  
  7. HotKeySet("^!b", "DispPrice")
  8.  
  9. Func HttpGet($sURL, $sData = "")
  10.     Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
  11.     $oHTTP.Open("GET", $sURL & "?" & $sData, False)
  12.     If (@error) Then Return SetError(1, 0, 0)
  13.     $oHTTP.Send()
  14.     If (@error) Then Return SetError(2, 0, 0)
  15.     If ($oHTTP.Status <> 200) Then Return SetError(3, 0, 0)
  16.  
  17.     Return SetError(0, 0, $oHTTP.ResponseText)
  18. EndFunc
  19.  
  20. Func GetPrice()
  21.     Local $thePrice = HttpGet("https://api.cryptowat.ch/markets/coinbase-pro/btcusd/price")
  22.     Local $begining = StringInStr($thePrice, '"price":') + 8
  23.     Local $ending = StringInStr($thePrice, '},')
  24.  
  25.     Return Int(StringMid($thePrice, $begining, $ending - $begining))
  26. EndFunc
  27.  
  28. Func DispPrice()
  29.     SplashTextOn("Bitcoin Price", GetPrice(), -1, 128, -1, -1, -1, -1, 72, 700)
  30.     Local $hWnd = WinGetHandle("Bitcoin Price")
  31.     _WinAPI_EnableWindow($hWnd, True)
  32.     Local $nStyle = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE)
  33.     _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, $nStyle + $WS_SYSMENU)
  34.     _WinAPI_SetWindowPos($hWnd, Null, 0, 0, 0, 0, $SWP_NOSIZE + $SWP_NOMOVE + $SWP_FRAMECHANGED)
  35.     While WinExists($hWnd)
  36.         Sleep(3000)
  37.         ControlSetText($hWnd, "", "Static1", GetPrice())
  38.     WEnd
  39.     SplashOff()
  40.     ;Exit
  41. EndFunc
  42.  
  43. While 1
  44.     GUIGetMsg()
  45. WEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement