Advertisement
OgreVorbis

AutoIT Main Script V5

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