Advertisement
OgreVorbis

AutoIT Main Script

Oct 16th, 2022 (edited)
2,519
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 7.88 KB | None | 0 0
  1. #include <WinApi.au3>
  2. #include <WinAPISysWin.au3>
  3. #include <WindowsConstants.au3>
  4. #include <Clipboard.au3>
  5. #include <Array.au3>
  6. #include <String.au3>
  7. #include <Misc.au3>
  8.  
  9. ; THIS IS MY MAIN AUTOIT BACKGROUND PROCESS SCRIPT TO DO VARIOUS IMPORTANT THINGS :)
  10. ; IT ALLOWS FOR PINNING WINDOWS TO TOP, FIXING STUPID YOUTUBE KEYBINDINGS THAT F-UP...
  11. ; AND DISPLAYS CRYPTO PRICES (CURRENTLY JUST MONERO AND BITCOIN)
  12. ; **NOTE** DELETE THE MOUSEPROC STUFF - THAT'S JUST TO FIX MY STUPID BUGGY MOUSE WHEEL THAT STICKS
  13.  
  14.  
  15. HotKeySet("`", "PinWindow") ; TILDA KEY KEEPS CURRENT WINDOW ON TOP
  16. HotKeySet("{APPSKEY}", "YouTube_Keymap") ; THE MENU KEY (NEXT TO RIGHT-CTRL) FORCES THE YOUTUBE KEYBINDINGS TO WORK
  17. HotKeySet("^!b", "CoinPrice") ; CTRL-ALT-B WILL SHOW THE CURRENT COIN PRICE
  18. HotKeySet("^!n", "DollarToCoin") ; ENTER YOUR AMOUNT OF DOLLARS TO CONVERT TO CURRENT COIN
  19. HotKeySet("^!m", "CoinToDollar") ; COIN TO DOLLARS
  20. HotKeySet("^!s", "SwitchCoin") ; SWITCHES WHAT COIN IS CURRENTLY ACTIVE
  21. HotKeySet("^!g", "GmailSelectAll") ; MASS DELETE EMAILS IN GMAIL HTML MODE (HTML GMAIL DOESN'T HAVE A BUTTON TO SELECT ALL)
  22.  
  23. Global Const $MSLLHOOKSTRUCT = $tagPOINT & ";dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo"
  24. Global $hHook, $n, $delay = 2000
  25. Local $hFunc, $pFunc, $hMod
  26.  
  27. Local Const $YT_WINDOW = "- YouTube"
  28. Local $toggle = False
  29. Local $YTtoggle = False
  30. Local $currentCoin = "Bitcoin"
  31.  
  32. ; FIXES THE STUPID MIDDLE MOUSE BUTTON PROBLEM - ANOTHER USER - DELETE IT
  33. $hFunc = DllCallbackRegister('_MouseProc', 'long', 'int;wparam;lparam')
  34. $pFunc = DllCallbackGetPtr($hFunc)
  35. $hMod = _WinAPI_GetModuleHandle(0)
  36. $hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, $pFunc, $hMod)
  37.  
  38. ; GMAIL HTML MODE SELECT ALL
  39. ; ==========================
  40. Func GmailSelectAll()
  41.     Local $count = Number(InputBox("Gmail Selector", "This will select many emails in HTML mode gmail. How many emails do you want to select?", "99"))
  42.     MsgBox(64, "Gmail Selector", "After pressing OK, quickly check off the first email in the list.")
  43.     Local $i = 0
  44.     Sleep(4000)
  45.     For $i = 1 To $count
  46.         Send("{TAB}")
  47.         Sleep(16)
  48.         Send("{TAB}")
  49.         Sleep(16)
  50.         Send("{SPACE}")
  51.         Sleep(16)
  52.     Next
  53.     MsgBox(64, "Gmail Selector", "DONE!")
  54. EndFunc
  55.  
  56. ; BITCOIN PRICE STUFF
  57. ; ===================
  58. Func HttpGet($sURL, $sData = "")
  59.     Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
  60.     $oHTTP.Open("GET", $sURL & "?" & $sData, False)
  61.     If (@error) Then Return SetError(1, 0, 0)
  62.     $oHTTP.Send()
  63.     If (@error) Then Return SetError(2, 0, 0)
  64.     If ($oHTTP.Status <> 200) Then Return SetError(3, 0, 0)
  65.  
  66.     Return SetError(0, 0, $oHTTP.ResponseText)
  67. EndFunc
  68.  
  69. Func GetPrice()
  70.     Local $thePrice = ""
  71.     If $currentCoin = "Bitcoin" Then
  72.         $thePrice = HttpGet("https://api.cryptowat.ch/markets/coinbase-pro/btcusd/price")
  73.     Else
  74.         $thePrice = HttpGet("https://api.cryptowat.ch/markets/bitfinex/xmrusd/price")
  75.     EndIf
  76.     Local $begining = StringInStr($thePrice, '"price":') + 8
  77.     Local $ending = StringInStr($thePrice, '},')
  78.  
  79.     Return Int(StringMid($thePrice, $begining, $ending - $begining))
  80. EndFunc
  81.  
  82. Func SwitchCoin()
  83.     Local $oldCoin = $currentCoin
  84.     Local $hWndCoin
  85.     If $currentCoin = "Bitcoin" Then
  86.         $currentCoin = "Monero"
  87.     Else
  88.         $currentCoin = "Bitcoin"
  89.     EndIf
  90.     If WinExists($oldCoin & " Price") Then
  91.         $hWndCoin = WinGetHandle($oldCoin & " Price")
  92.         WinSetTrans($hWndCoin, "", 48)
  93.         WinSetTitle($hWndCoin, "", $currentCoin & " Price")
  94.         Sleep(500)
  95.         WinSetTrans($hWndCoin, "", 255)
  96.         ControlSetText($hWndCoin, "", "Static1", ". . .")
  97.     EndIf
  98.     ToolTip("Current coin is " & $currentCoin, @DesktopWidth / 2, (@DesktopHeight / 2) - 128, "Coin", 1, 2)
  99.     Sleep(1750)
  100.     ToolTip("")
  101. EndFunc
  102.  
  103. Func CoinPrice()
  104.     DispPrice(1, 0)
  105. EndFunc
  106.  
  107. Func DollarToCoin()
  108.     Local $dollars = Number(InputBox("Dollars", "Type in your amount of dollars to convert to " & $currentCoin & ":"))
  109.     If $dollars > 0 Then DispPrice(0, $dollars)
  110. EndFunc
  111.  
  112. Func CoinToDollar()
  113.     Local $coins = Number(InputBox("Enter Coin", "Type in your amount of " & $currentCoin & ":"))
  114.     If $coins > 0 Then DispPrice($coins, 0)
  115. EndFunc
  116.  
  117. Func DispPrice($coins, $dollars)
  118.     Local $price = 0.0
  119.     Local $fontSize = 64
  120.     If $coins <> 1 Then $fontSize = 48
  121.     If $dollars = 0 Then
  122.         $price = GetPrice() * $coins
  123.     Else
  124.         $price = Round($dollars / GetPrice(), 6)
  125.     EndIf
  126.     ClipPut(String($price))
  127.     SplashTextOn($currentCoin & " Price", $price, -1, 128, -1, -1, -1, -1, $fontSize, 700)
  128.     Local $hWnd = WinGetHandle($currentCoin & " Price")
  129.     _WinAPI_EnableWindow($hWnd, True)
  130.     Local $nStyle = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE)
  131.     _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, $nStyle + $WS_SYSMENU)
  132.     _WinAPI_SetWindowPos($hWnd, Null, 0, 0, 0, 0, $SWP_NOSIZE + $SWP_NOMOVE + $SWP_FRAMECHANGED)
  133.     While WinExists($hWnd)
  134.         Sleep(3000)
  135.         If $dollars = 0 Then
  136.             ControlSetText($hWnd, "", "Static1", GetPrice() * $coins)
  137.         Else
  138.             ControlSetText($hWnd, "", "Static1", Round($dollars / GetPrice(), 6))
  139.         EndIf
  140.     WEnd
  141.     SplashOff()
  142. EndFunc
  143.  
  144. ; YOUTUBE KEYBOARD CONTROL BUG FIX
  145. ; ================================
  146. Func YouTube_Active()
  147.     Local $sTitle = WinGetTitle("[active]")
  148.     If StringInStr($sTitle, $YT_WINDOW, 1) = 0 Then ; We check if current open window title does NOT end with - YouTube
  149.         $YTtoggle = False
  150.         HotKeySet("{SPACE}")
  151.         HotKeySet("{LEFT}")
  152.         HotKeySet("{RIGHT}")
  153.         Return False
  154.     Else
  155.         Return True
  156.     EndIf
  157. EndFunc
  158.  
  159. Func YouTube_Spacebar()
  160.     If YouTube_Active() = True Then
  161.         Send("k")
  162.     Else
  163.         Send("{SPACE}")
  164.     EndIf
  165. EndFunc
  166.  
  167. Func YouTube_Left()
  168.     If YouTube_Active() = True Then
  169.         Send("j")
  170.     Else
  171.         Send("{LEFT}")
  172.     EndIf
  173. EndFunc
  174.  
  175. Func YouTube_Right()
  176.     If YouTube_Active() = True Then
  177.         Send("l")
  178.     Else
  179.         Send("{RIGHT}")
  180.     EndIf
  181. EndFunc
  182.  
  183. Func YouTube_Keymap()
  184.     Local $sTitle = WinGetTitle("[active]")
  185.     If StringInStr($sTitle, $YT_WINDOW, 1) <> 0 Then ; If the youtube window is open and has focus
  186.         If $YTtoggle = False Then
  187.             $YTtoggle = True
  188.             Sleep(150)
  189.             Send("{ESC}")
  190.             Sleep(50)
  191.             MouseClick($MOUSE_CLICK_LEFT, 750, 500, 1, 4)
  192.             Sleep(250)
  193.             Send("{SPACE}")
  194.             ;ToolTip("The youtube feature is ON.", 350, 350, "Engine", 1)
  195.             ;Sleep(750)
  196.             ;ToolTip("")
  197.             HotKeySet("{SPACE}", "YouTube_Spacebar")
  198.             HotKeySet("{LEFT}", "YouTube_Left")
  199.             HotKeySet("{RIGHT}", "YouTube_Right")
  200.         Else
  201.             $YTtoggle = False
  202.             Sleep(150)
  203.             Send("{ESC}")
  204.             HotKeySet("{SPACE}")
  205.             HotKeySet("{LEFT}")
  206.             HotKeySet("{RIGHT}")
  207.         EndIf
  208.     Else
  209.         HotKeySet("{APPSKEY}") ; Unhook the hotkey when outside firefox
  210.         Send("{APPSKEY}") ; Send the key like normal so windows can process it
  211.         HotKeySet("{APPSKEY}", "YouTube_Keymap") ; Hook the hotkey again
  212.     EndIf
  213. EndFunc
  214.  
  215. ; KEEP THE WINDOW ON TOP BY PRESSING THE TILDA KEY
  216. ; ================================================
  217. Func PinWindow()
  218.     If $toggle = False Then
  219.         $toggle = True
  220.         ; Retrieve the handle of the active window.
  221.         Local $hWnd = WinGetHandle("[ACTIVE]")
  222.         ; Set the active window as being ontop using the handle returned by WinGetHandle.
  223.         WinSetOnTop($hWnd, "", $WINDOWS_ONTOP)
  224.     Else
  225.         $toggle = False
  226.         ; Retrieve the handle of the active window.
  227.         Local $hWnd = WinGetHandle("[ACTIVE]")
  228.         ; Set the active window as being ontop using the handle returned by WinGetHandle.
  229.         WinSetOnTop($hWnd, "", $WINDOWS_NOONTOP)
  230.     EndIf
  231. EndFunc
  232.  
  233. ; PREVENT THE MIDDLE MOUSE CLICK FROM BEING GLITCHY AND OPENING MULTIPLE TABS
  234. ; ===========================================================================
  235. Func _MouseProc($iCode, $iwParam, $ilParam)
  236.     Static $t = $delay
  237.     If $iCode < 0 Then Return _WinAPI_CallNextHookEx($hHook, $iCode, $iwParam, $ilParam)
  238.     Local $info = DllStructCreate($MSLLHOOKSTRUCT, $ilParam)
  239.     Switch $iwParam
  240.         Case $WM_MBUTTONDOWN
  241.             If TimerDiff($t) < $delay Then Return 1  ;<<< disable
  242.             $t = TimerInit()
  243.     EndSwitch
  244.     Return _WinAPI_CallNextHookEx($hHook, $iCode, $iwParam, $ilParam)
  245. EndFunc
  246.  
  247. While 1
  248.     ;If GuiGetMsg() = -3 Then _Close()
  249.     GUIGetMsg()
  250. WEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement