Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <WinApi.au3>
- #include <WinAPISysWin.au3>
- #include <WindowsConstants.au3>
- #include <Clipboard.au3>
- #include <Array.au3>
- #include <String.au3>
- #include <Misc.au3>
- #include <GUIConstantsEx.au3>
- #include <GuiListView.au3>
- #include <File.au3>
- GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY_HANDLER")
- ; THIS IS MY MAIN AUTOIT BACKGROUND PROCESS SCRIPT TO DO VARIOUS IMPORTANT THINGS :)
- ; IT ALLOWS FOR PINNING WINDOWS TO TOP, FIXING STUPID YOUTUBE KEYBINDINGS THAT F-UP...
- ; DISPLAYS CRYPTO PRICES (CURRENTLY JUST MONERO AND BITCOIN), AND MORE...
- HotKeySet("`", "PinWindow") ; TILDA KEY KEEPS CURRENT WINDOW ON TOP
- ;HotKeySet("{APPSKEY}", "YouTube_Keymap") ; THE MENU KEY (NEXT TO RIGHT-CTRL) FORCES THE YOUTUBE KEYBINDINGS TO WORK
- HotKeySet("{PAUSE}", "YouTube_Keymap")
- HotKeySet("^!b", "CoinPrice") ; CTRL-ALT-B WILL SHOW THE CURRENT COIN PRICE
- HotKeySet("^!n", "DollarToCoin") ; ENTER YOUR AMOUNT OF DOLLARS TO CONVERT TO CURRENT COIN
- HotKeySet("^!m", "CoinToDollar") ; COIN TO DOLLARS
- HotKeySet("^!s", "SwitchCoin") ; SWITCHES WHAT COIN IS CURRENTLY ACTIVE
- HotKeySet("^g", "MapsXClick") ; REMAP THE LEFT MOUSE CLICK AND MOUSE DOWN, TO X KEY - MAKES GOOGLE MAPS NOT OVER-USE MOUSE BUTTON
- HotKeySet("^!1", "HideWin1") ; CTRL-ALT-1 HIDE THE CURRENT FOREGROUND WINDOW IN SLOT 1 - JUST PRESS AGAIN TO SHOW
- HotKeySet("^!2", "HideWin2") ; HIDE CURRENT WINDOW SLOT 2
- HotKeySet("^!3", "HideWin3") ; SLOT 3
- HotKeySet("^!0", "UnhideAll") ; UNHIDE ALL HIDDEN WINDOWS
- HotKeySet("^!c", "CheckSpelling") ; CHECK SPELLING OF THE CURRENT SELECTED WORD - PUTS RESULT IN CLIPBOARD
- Local Const $YT_WINDOW = "- YouTube"
- Local $toggle = False
- Local $currentCoin = "Bitcoin"
- Local $mapsToggle = False
- Local $mapsPressed = False
- Local $toggleWin[3] = [False, False, False]
- Local $origHWnd[3]
- ; To-do list declarations
- Local $todoGUI, $todoList, $todoInput, $todoAddBtn, $todoClearBtn, $todoSaveBtn, $todoLoadBtn
- ; BITCOIN PRICE STUFF
- ; ===================
- Func HttpGet($sURL, $sData = "")
- Local $oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
- Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
- $oHTTP.Open("GET", $sURL & "?" & $sData, False)
- If (@error) Then Return SetError(1, 0, 0)
- $oHTTP.Send()
- If (@error) Then Return SetError(2, 0, 0)
- If ($oHTTP.Status <> 200) Then Return SetError(3, 0, 0)
- Return SetError(0, 0, $oHTTP.ResponseText)
- EndFunc
- Func MyErrFunc()
- MsgBox(48, "Error", "API communication error. Check connection.", 5)
- EndFunc
- Func GetPrice()
- Local $thePrice = ""
- Local $begining = ""
- Local $ending = ""
- If $currentCoin = "Bitcoin" Then
- $thePrice = HttpGet("[redacted]")
- $begining = StringInStr($thePrice, '"last_price":"') + 14 ; 14 is just the Len of the string we are looking for
- Else
- $thePrice = HttpGet("[redacted]")
- $begining = StringInStr($thePrice, '"last_price":"') + 14
- EndIf
- ;MsgBox(64,"price",$thePrice)
- If @error Then
- Return 0
- EndIf
- $ending = StringInStr($thePrice, '",', 0, 1, $begining)
- Return Int(StringMid($thePrice, $begining, $ending - $begining))
- EndFunc
- Func SwitchCoin()
- Local $oldCoin = $currentCoin
- Local $hWndCoin
- If $currentCoin = "Bitcoin" Then
- $currentCoin = "Monero"
- Else
- $currentCoin = "Bitcoin"
- EndIf
- If WinExists($oldCoin & " Price") Then
- $hWndCoin = WinGetHandle($oldCoin & " Price")
- WinSetTrans($hWndCoin, "", 48)
- WinSetTitle($hWndCoin, "", $currentCoin & " Price")
- Sleep(500)
- WinSetTrans($hWndCoin, "", 255)
- ControlSetText($hWndCoin, "", "Static1", ". . .")
- EndIf
- ToolTip("Current coin is " & $currentCoin, @DesktopWidth / 2, (@DesktopHeight / 2) - 128, "Coin", 1, 2)
- Sleep(1750)
- ToolTip("")
- EndFunc
- Func CoinPrice()
- DispPrice(1, 0)
- EndFunc
- Func DollarToCoin()
- Local $dollars = Number(InputBox("Dollars", "Type in your amount of dollars to convert to " & $currentCoin & ":"))
- If $dollars > 0 Then DispPrice(0, $dollars)
- EndFunc
- Func CoinToDollar()
- Local $coins = Number(InputBox("Enter Coin", "Type in your amount of " & $currentCoin & ":"))
- If $coins > 0 Then DispPrice($coins, 0)
- EndFunc
- Func DispPrice($coins, $dollars)
- Local $price = 0.0
- Local $fontSize = 64
- Local $rawPrice = GetPrice()
- If $rawPrice = 0 Then Return
- If $coins <> 1 Then $fontSize = 48
- If $dollars = 0 Then
- $price = $rawPrice * $coins
- Else
- $price = Round($dollars / $rawPrice, 6)
- EndIf
- ClipPut(String($price))
- SplashTextOn($currentCoin & " Price", $price, -1, 128, -1, -1, -1, -1, $fontSize, 700)
- Local $hWnd = WinGetHandle($currentCoin & " Price")
- _WinAPI_EnableWindow($hWnd, True)
- Local $nStyle = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE)
- _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, $nStyle + $WS_SYSMENU)
- _WinAPI_SetWindowPos($hWnd, Null, 0, 0, 0, 0, $SWP_NOSIZE + $SWP_NOMOVE + $SWP_FRAMECHANGED)
- While WinExists($hWnd)
- Sleep(3000)
- If $dollars = 0 Then
- ControlSetText($hWnd, "", "Static1", GetPrice() * $coins)
- Else
- ControlSetText($hWnd, "", "Static1", Round($dollars / GetPrice(), 6))
- EndIf
- WEnd
- SplashOff()
- EndFunc
- ; YOUTUBE KEYBOARD CONTROL BUG FIX
- ; ================================
- Func YouTube_Keymap()
- Sleep(150)
- MouseClick($MOUSE_CLICK_LEFT, 750, 500, 1, 4)
- Sleep(250)
- Send("{SPACE}")
- EndFunc
- ; GOOGLE MAPS REMAP MOUSE CLICK TO X KEY
- ; ======================================
- Func MapsXClick()
- If $mapsToggle = False Then
- $mapsToggle = True
- MsgBox(64, "Google Maps Engine", "The X key remap is turned ON.")
- Else
- $mapsToggle = False
- MsgBox(64, "Google Maps Engine", "The X key remap is turned OFF.")
- EndIf
- EndFunc
- Func HoldDownMouse($keyCode)
- If _IsPressed($keyCode) And $mapsPressed = False Then
- $mapsPressed = True
- MouseDown($MOUSE_CLICK_LEFT)
- EndIf
- If Not _IsPressed($keyCode) And $mapsPressed = True Then
- MouseUp($MOUSE_CLICK_LEFT)
- $mapsPressed = False
- EndIf
- EndFunc
- ; KEEP THE WINDOW ON TOP BY PRESSING THE TILDA KEY
- ; ================================================
- Func PinWindow()
- If $toggle = False Then
- $toggle = True
- ; Retrieve the handle of the active window.
- Local $hWnd = WinGetHandle("[ACTIVE]")
- ; Set the active window as being ontop using the handle returned by WinGetHandle.
- WinSetOnTop($hWnd, "", $WINDOWS_ONTOP)
- Else
- $toggle = False
- ; Retrieve the handle of the active window.
- Local $hWnd = WinGetHandle("[ACTIVE]")
- ; Set the active window as being ontop using the handle returned by WinGetHandle.
- WinSetOnTop($hWnd, "", $WINDOWS_NOONTOP)
- EndIf
- EndFunc
- ; FUNCTIONS FOR HIDING WINDOWS
- ; ============================
- Func HideWin1()
- DoHideWin(0)
- EndFunc
- Func HideWin2()
- DoHideWin(1)
- EndFunc
- Func HideWin3()
- DoHideWin(2)
- EndFunc
- Func UnhideAll()
- For $i = 0 To 2
- If IsHWnd($origHWnd[$i]) Then
- WinSetState($origHWnd[$i], "", @SW_SHOW)
- $toggleWin[$i] = False
- EndIf
- Next
- EndFunc
- Func DoHideWin($winNumber)
- If $toggleWin[$winNumber] = False Then
- $origHWnd[$winNumber] = WinGetHandle("[ACTIVE]")
- WinSetState("[ACTIVE]", "", @SW_HIDE)
- $toggleWin[$winNumber] = True
- Else
- WinSetState($origHWnd[$winNumber], "", @SW_SHOW)
- WinActivate($origHWnd[$winNumber])
- $toggleWin[$winNumber] = False
- EndIf
- EndFunc
- Func _SendEx($ss)
- Local $iT = TimerInit()
- While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12")
- Sleep(50)
- WEnd
- Send($ss)
- EndFunc
- ; CHECK SPELLING BY RUNNING EXTERNAL SPELL CHECKER
- ; ================================================
- Func CheckSpelling()
- Local $strClip
- Sleep(150)
- _SendEx("^c")
- Sleep(50)
- $strClip = ClipGet()
- ShellExecuteWait("spellcheck.exe")
- Sleep(150)
- If $strClip <> ClipGet() Then
- _SendEx("^v")
- EndIf
- EndFunc
- ; DISPLAY AND RUN THE TO-DO LIST
- ; ==============================
- Func ShowTodoList()
- Local $width = 400, $height = 350
- $todoGUI = GUICreate("To-Do List", $width, $height, -1, -1)
- $todoList = GUICtrlCreateListView("Task", 10, 10, $width - 20, 250, BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT, $LVS_SINGLESEL, $LVS_EDITLABELS))
- Local $hListView = GUICtrlGetHandle($todoList)
- _GUICtrlListView_SetExtendedListViewStyle($hListView, $LVS_EX_CHECKBOXES)
- _GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE_USEHEADER)
- $todoInput = GUICtrlCreateInput("", 10, 270, $width - 90, 24)
- $todoAddBtn = GUICtrlCreateButton("Add", $width - 75, 270, 65, 24)
- $todoClearBtn = GUICtrlCreateButton("Clear", 20, 310, 100, 30)
- $todoSaveBtn = GUICtrlCreateButton("Save", 150, 310, 100, 30)
- $todoLoadBtn = GUICtrlCreateButton("Load", 280, 310, 100, 30)
- GUISetState(@SW_SHOW, $todoGUI)
- LoadTodoList()
- While True
- If _IsPressed("0D") Then ; 0D is virtual key code for Enter - WE ARE ADDING A NEW ITEM TO THE LIST BY PRESSING ENTER KEY, NOT ONLY BY BUTTON CLICK
- Local $focusedCtrl = ControlGetFocus($todoGUI)
- If ControlGetHandle($todoGUI, "", $focusedCtrl) = GUICtrlGetHandle($todoInput) Then
- Local $text = GUICtrlRead($todoInput)
- If StringStripWS($text, 3) <> "" Then
- GUICtrlCreateListViewItem($text, $todoList)
- _GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE_USEHEADER)
- GUICtrlSetData($todoInput, "")
- EndIf
- EndIf
- EndIf
- Switch GUIGetMsg() ; SOMEDAY WE NEED TO PUMP THIS INTO ITS OWN VAR THAT WE SWITCH..CASE ON BELOW. THAT WAY WE CAN FAKE TRIGGER A CASE EVENT WHEREEVER WE WANT.
- Case $GUI_EVENT_CLOSE
- GUIDelete($todoGUI)
- ExitLoop
- Case $todoAddBtn
- Local $text = GUICtrlRead($todoInput)
- If StringStripWS($text, 3) <> "" Then
- GUICtrlCreateListViewItem($text, $todoList)
- _GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE_USEHEADER)
- GUICtrlSetData($todoInput, "")
- EndIf
- Case $todoClearBtn
- _GUICtrlListView_DeleteAllItems($hListView)
- Case $todoSaveBtn
- SaveTodoList()
- Case $todoLoadBtn
- LoadTodoList()
- EndSwitch
- WEnd
- EndFunc
- Func SaveTodoList()
- Local $hListView = GUICtrlGetHandle($todoList)
- Local $count = _GUICtrlListView_GetItemCount($hListView)
- If $count <> 0 Then
- Local $f = FileOpen(@ScriptDir & "\todo.ini", 2)
- If $f = -1 Then
- MsgBox(16, "Error", "Cannot save file!")
- Return
- EndIf
- For $i = 0 To $count - 1
- Local $text = _GUICtrlListView_GetItemText($hListView, $i)
- Local $checked = _GUICtrlListView_GetItemChecked($hListView, $i)
- FileWriteLine($f, $checked & "|" & $text)
- Next
- FileClose($f)
- EndIf
- EndFunc
- Func LoadTodoList()
- Local $hListView = GUICtrlGetHandle($todoList)
- If Not FileExists(@ScriptDir & "\todo.ini") Then Return
- _GUICtrlListView_DeleteAllItems($hListView)
- Local $lines = FileReadToArray(@ScriptDir & "\todo.ini")
- For $i = 0 To UBound($lines) - 1
- Local $parts = StringSplit($lines[$i], "|", 2)
- If UBound($parts) = 2 Then
- GUICtrlCreateListViewItem($parts[1], $todoList)
- Local $index = _GUICtrlListView_GetItemCount($hListView) - 1
- _GUICtrlListView_SetItemChecked($hListView, $index, $parts[0] = "True")
- EndIf
- Next
- _GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE_USEHEADER)
- EndFunc
- Func WM_NOTIFY_HANDLER($hWnd, $iMsg, $wParam, $lParam)
- Local $tNMHDR = DllStructCreate("int;int;int", $lParam)
- Local $hwFrom = DllStructGetData($tNMHDR, 1)
- Local $code = DllStructGetData($tNMHDR, 3)
- Local $hListView = GUICtrlGetHandle($todoList)
- If $code = $NM_DBLCLK Then
- If $hwFrom = $hListView Then
- Local $index = _GUICtrlListView_GetSelectionMark($hListView)
- If $index <> -1 Then
- Local $oldText = _GUICtrlListView_GetItemText($hListView, $index)
- Local $newText = InputBox("Edit Task", "Double-click edit:", $oldText)
- If Not @error And StringStripWS($newText, 3) <> "" Then
- _GUICtrlListView_SetItemText($hListView, $index, $newText)
- _GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE_USEHEADER)
- EndIf
- EndIf
- EndIf
- EndIf
- Return $GUI_RUNDEFMSG
- EndFunc
- ; PREPARE THE TRAY MENUITEMS
- ; ==========================
- Opt("TrayMenuMode", 3) ; Removes default behavior (no auto pause)
- Opt("TrayOnEventMode", 1) ; Enables event-driven tray menu
- TraySetClick(8) ; Enable right-click to show tray menu
- TrayCreateItem("To-Do List")
- TrayItemSetOnEvent(-1, "ShowTodoList")
- TrayCreateItem("")
- TrayCreateItem("Help")
- TrayItemSetOnEvent(-1, "ShowHelp")
- TrayCreateItem("")
- TrayCreateItem("Exit")
- TrayItemSetOnEvent(-1, "ExitScript")
- Func ExitScript()
- Exit
- EndFunc
- Func ShowHelp()
- Local $helpMsg = _
- "(tilda) - Toggle 'Always on Top' for the active window" & @CRLF & _
- "{PAUSE} - Fix YouTube keybinding issues (simulate SPACE click)" & @CRLF & _
- "Ctrl+Alt+B - Show the current price of Bitcoin or Monero" & @CRLF & _
- "Ctrl+Alt+N - Convert a dollar amount to the selected coin" & @CRLF & _
- "Ctrl+Alt+M - Convert coin amount to dollars" & @CRLF & _
- "Ctrl+Alt+S - Switch between Bitcoin and Monero" & @CRLF & _
- "Ctrl+G - Enable/disable Google Maps mouse-to-X remap" & @CRLF & _
- "Ctrl+Alt+1 - Hide/unhide the current window in slot 1" & @CRLF & _
- "Ctrl+Alt+2 - Hide/unhide the current window in slot 2" & @CRLF & _
- "Ctrl+Alt+3 - Hide/unhide the current window in slot 3" & @CRLF & _
- "Ctrl+Alt+0 - Unhide all hidden windows" & @CRLF & _
- "Ctrl+Alt+C - Check spelling of selected word" & @CRLF & @CRLF & _
- "©2020-2025 DosaidSoft.com - By Paul Meyer"
- MsgBox(64, "MouseWheel Hotkeys Help", $helpMsg)
- EndFunc
- ; THE PROGRAM MAIN LOOP
- ; =====================
- While True
- If $mapsToggle = True Then HoldDownMouse(58) ;if the X key is pressed - hold down the mouse
- GUIGetMsg()
- WEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement