Advertisement
OgreVorbis

AutoIT Main Script V4

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