· 4 months ago · May 24, 2025, 09:45 PM
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#include <GUIConstantsEx.au3>
9#include <GuiListView.au3>
10#include <File.au3>
11
12GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY_HANDLER")
13
14; THIS IS MY MAIN AUTOIT BACKGROUND PROCESS SCRIPT TO DO VARIOUS IMPORTANT THINGS :)
15; IT ALLOWS FOR PINNING WINDOWS TO TOP, FIXING STUPID YOUTUBE KEYBINDINGS THAT F-UP...
16; DISPLAYS CRYPTO PRICES (CURRENTLY JUST MONERO AND BITCOIN), AND MORE...
17
18HotKeySet("`", "PinWindow") ; TILDA KEY KEEPS CURRENT WINDOW ON TOP
19;HotKeySet("{APPSKEY}", "YouTube_Keymap") ; THE MENU KEY (NEXT TO RIGHT-CTRL) FORCES THE YOUTUBE KEYBINDINGS TO WORK
20HotKeySet("{PAUSE}", "YouTube_Keymap")
21HotKeySet("^!b", "CoinPrice") ; CTRL-ALT-B WILL SHOW THE CURRENT COIN PRICE
22HotKeySet("^!n", "DollarToCoin") ; ENTER YOUR AMOUNT OF DOLLARS TO CONVERT TO CURRENT COIN
23HotKeySet("^!m", "CoinToDollar") ; COIN TO DOLLARS
24HotKeySet("^!s", "SwitchCoin") ; SWITCHES WHAT COIN IS CURRENTLY ACTIVE
25HotKeySet("^g", "MapsXClick") ; REMAP THE LEFT MOUSE CLICK AND MOUSE DOWN, TO X KEY - MAKES GOOGLE MAPS NOT OVER-USE MOUSE BUTTON
26HotKeySet("^!1", "HideWin1") ; CTRL-ALT-1 HIDE THE CURRENT FOREGROUND WINDOW IN SLOT 1 - JUST PRESS AGAIN TO SHOW
27HotKeySet("^!2", "HideWin2") ; HIDE CURRENT WINDOW SLOT 2
28HotKeySet("^!3", "HideWin3") ; SLOT 3
29HotKeySet("^!0", "UnhideAll") ; UNHIDE ALL HIDDEN WINDOWS
30HotKeySet("^!c", "CheckSpelling") ; CHECK SPELLING OF THE CURRENT SELECTED WORD - PUTS RESULT IN CLIPBOARD
31
32Local Const $YT_WINDOW = "- YouTube"
33Local $toggle = False
34Local $currentCoin = "Bitcoin"
35
36Local $mapsToggle = False
37Local $mapsPressed = False
38
39Local $toggleWin[3] = [False, False, False]
40Local $origHWnd[3]
41
42; To-do list declarations
43Local $todoGUI, $todoList, $todoInput, $todoAddBtn, $todoClearBtn, $todoSaveBtn, $todoLoadBtn
44
45
46; BITCOIN PRICE STUFF
47; ===================
48Func HttpGet($sURL, $sData = "")
49 Local $oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
50 Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
51 $oHTTP.Open("GET", $sURL & "?" & $sData, False)
52 If (@error) Then Return SetError(1, 0, 0)
53 $oHTTP.Send()
54 If (@error) Then Return SetError(2, 0, 0)
55 If ($oHTTP.Status <> 200) Then Return SetError(3, 0, 0)
56
57 Return SetError(0, 0, $oHTTP.ResponseText)
58EndFunc
59
60Func MyErrFunc()
61 MsgBox(48, "Error", "API communication error. Check connection.", 5)
62EndFunc
63
64Func GetPrice()
65 Local $thePrice = ""
66 Local $begining = ""
67 Local $ending = ""
68 If $currentCoin = "Bitcoin" Then
69 $thePrice = HttpGet("[redacted]")
70 $begining = StringInStr($thePrice, '"last_price":"') + 14 ; 14 is just the Len of the string we are looking for
71 Else
72 $thePrice = HttpGet("[redacted]")
73 $begining = StringInStr($thePrice, '"last_price":"') + 14
74 EndIf
75 ;MsgBox(64,"price",$thePrice)
76 If @error Then
77 Return 0
78 EndIf
79 $ending = StringInStr($thePrice, '",', 0, 1, $begining)
80
81 Return Int(StringMid($thePrice, $begining, $ending - $begining))
82EndFunc
83
84Func SwitchCoin()
85 Local $oldCoin = $currentCoin
86 Local $hWndCoin
87 If $currentCoin = "Bitcoin" Then
88 $currentCoin = "Monero"
89 Else
90 $currentCoin = "Bitcoin"
91 EndIf
92 If WinExists($oldCoin & " Price") Then
93 $hWndCoin = WinGetHandle($oldCoin & " Price")
94 WinSetTrans($hWndCoin, "", 48)
95 WinSetTitle($hWndCoin, "", $currentCoin & " Price")
96 Sleep(500)
97 WinSetTrans($hWndCoin, "", 255)
98 ControlSetText($hWndCoin, "", "Static1", ". . .")
99 EndIf
100 ToolTip("Current coin is " & $currentCoin, @DesktopWidth / 2, (@DesktopHeight / 2) - 128, "Coin", 1, 2)
101 Sleep(1750)
102 ToolTip("")
103EndFunc
104
105Func CoinPrice()
106 DispPrice(1, 0)
107EndFunc
108
109Func DollarToCoin()
110 Local $dollars = Number(InputBox("Dollars", "Type in your amount of dollars to convert to " & $currentCoin & ":"))
111 If $dollars > 0 Then DispPrice(0, $dollars)
112EndFunc
113
114Func CoinToDollar()
115 Local $coins = Number(InputBox("Enter Coin", "Type in your amount of " & $currentCoin & ":"))
116 If $coins > 0 Then DispPrice($coins, 0)
117EndFunc
118
119Func DispPrice($coins, $dollars)
120 Local $price = 0.0
121 Local $fontSize = 64
122 Local $rawPrice = GetPrice()
123 If $rawPrice = 0 Then Return
124 If $coins <> 1 Then $fontSize = 48
125 If $dollars = 0 Then
126 $price = $rawPrice * $coins
127 Else
128 $price = Round($dollars / $rawPrice, 6)
129 EndIf
130 ClipPut(String($price))
131 SplashTextOn($currentCoin & " Price", $price, -1, 128, -1, -1, -1, -1, $fontSize, 700)
132 Local $hWnd = WinGetHandle($currentCoin & " Price")
133 _WinAPI_EnableWindow($hWnd, True)
134 Local $nStyle = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE)
135 _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, $nStyle + $WS_SYSMENU)
136 _WinAPI_SetWindowPos($hWnd, Null, 0, 0, 0, 0, $SWP_NOSIZE + $SWP_NOMOVE + $SWP_FRAMECHANGED)
137 While WinExists($hWnd)
138 Sleep(3000)
139 If $dollars = 0 Then
140 ControlSetText($hWnd, "", "Static1", GetPrice() * $coins)
141 Else
142 ControlSetText($hWnd, "", "Static1", Round($dollars / GetPrice(), 6))
143 EndIf
144 WEnd
145 SplashOff()
146EndFunc
147
148; YOUTUBE KEYBOARD CONTROL BUG FIX
149; ================================
150Func YouTube_Keymap()
151 Sleep(150)
152 MouseClick($MOUSE_CLICK_LEFT, 750, 500, 1, 4)
153 Sleep(250)
154 Send("{SPACE}")
155EndFunc
156
157; GOOGLE MAPS REMAP MOUSE CLICK TO X KEY
158; ======================================
159Func MapsXClick()
160 If $mapsToggle = False Then
161 $mapsToggle = True
162 MsgBox(64, "Google Maps Engine", "The X key remap is turned ON.")
163 Else
164 $mapsToggle = False
165 MsgBox(64, "Google Maps Engine", "The X key remap is turned OFF.")
166 EndIf
167EndFunc
168
169Func HoldDownMouse($keyCode)
170 If _IsPressed($keyCode) And $mapsPressed = False Then
171 $mapsPressed = True
172 MouseDown($MOUSE_CLICK_LEFT)
173 EndIf
174 If Not _IsPressed($keyCode) And $mapsPressed = True Then
175 MouseUp($MOUSE_CLICK_LEFT)
176 $mapsPressed = False
177 EndIf
178EndFunc
179
180; KEEP THE WINDOW ON TOP BY PRESSING THE TILDA KEY
181; ================================================
182Func PinWindow()
183 If $toggle = False Then
184 $toggle = True
185 ; Retrieve the handle of the active window.
186 Local $hWnd = WinGetHandle("[ACTIVE]")
187 ; Set the active window as being ontop using the handle returned by WinGetHandle.
188 WinSetOnTop($hWnd, "", $WINDOWS_ONTOP)
189 Else
190 $toggle = False
191 ; Retrieve the handle of the active window.
192 Local $hWnd = WinGetHandle("[ACTIVE]")
193 ; Set the active window as being ontop using the handle returned by WinGetHandle.
194 WinSetOnTop($hWnd, "", $WINDOWS_NOONTOP)
195 EndIf
196EndFunc
197
198; FUNCTIONS FOR HIDING WINDOWS
199; ============================
200Func HideWin1()
201 DoHideWin(0)
202EndFunc
203Func HideWin2()
204 DoHideWin(1)
205EndFunc
206Func HideWin3()
207 DoHideWin(2)
208EndFunc
209Func UnhideAll()
210 For $i = 0 To 2
211 If IsHWnd($origHWnd[$i]) Then
212 WinSetState($origHWnd[$i], "", @SW_SHOW)
213 $toggleWin[$i] = False
214 EndIf
215 Next
216EndFunc
217
218Func DoHideWin($winNumber)
219 If $toggleWin[$winNumber] = False Then
220 $origHWnd[$winNumber] = WinGetHandle("[ACTIVE]")
221 WinSetState("[ACTIVE]", "", @SW_HIDE)
222 $toggleWin[$winNumber] = True
223 Else
224 WinSetState($origHWnd[$winNumber], "", @SW_SHOW)
225 WinActivate($origHWnd[$winNumber])
226 $toggleWin[$winNumber] = False
227 EndIf
228EndFunc
229
230Func _SendEx($ss)
231 Local $iT = TimerInit()
232
233 While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12")
234 Sleep(50)
235 WEnd
236 Send($ss)
237EndFunc
238
239; CHECK SPELLING BY RUNNING EXTERNAL SPELL CHECKER
240; ================================================
241Func CheckSpelling()
242 Local $strClip
243
244 Sleep(150)
245 _SendEx("^c")
246 Sleep(50)
247 $strClip = ClipGet()
248 ShellExecuteWait("spellcheck.exe")
249 Sleep(150)
250 If $strClip <> ClipGet() Then
251 _SendEx("^v")
252 EndIf
253EndFunc
254
255; DISPLAY AND RUN THE TO-DO LIST
256; ==============================
257Func ShowTodoList()
258 Local $width = 400, $height = 350
259
260 $todoGUI = GUICreate("To-Do List", $width, $height, -1, -1)
261 $todoList = GUICtrlCreateListView("Task", 10, 10, $width - 20, 250, BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT, $LVS_SINGLESEL, $LVS_EDITLABELS))
262 Local $hListView = GUICtrlGetHandle($todoList)
263 _GUICtrlListView_SetExtendedListViewStyle($hListView, $LVS_EX_CHECKBOXES)
264 _GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE_USEHEADER)
265
266 $todoInput = GUICtrlCreateInput("", 10, 270, $width - 90, 24)
267 $todoAddBtn = GUICtrlCreateButton("Add", $width - 75, 270, 65, 24)
268
269 $todoClearBtn = GUICtrlCreateButton("Clear", 20, 310, 100, 30)
270 $todoSaveBtn = GUICtrlCreateButton("Save", 150, 310, 100, 30)
271 $todoLoadBtn = GUICtrlCreateButton("Load", 280, 310, 100, 30)
272
273 GUISetState(@SW_SHOW, $todoGUI)
274 LoadTodoList()
275
276 While True
277 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
278 Local $focusedCtrl = ControlGetFocus($todoGUI)
279 If ControlGetHandle($todoGUI, "", $focusedCtrl) = GUICtrlGetHandle($todoInput) Then
280 Local $text = GUICtrlRead($todoInput)
281 If StringStripWS($text, 3) <> "" Then
282 GUICtrlCreateListViewItem($text, $todoList)
283 _GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE_USEHEADER)
284 GUICtrlSetData($todoInput, "")
285 EndIf
286 EndIf
287 EndIf
288
289 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.
290 Case $GUI_EVENT_CLOSE
291 GUIDelete($todoGUI)
292 ExitLoop
293
294 Case $todoAddBtn
295 Local $text = GUICtrlRead($todoInput)
296 If StringStripWS($text, 3) <> "" Then
297 GUICtrlCreateListViewItem($text, $todoList)
298 _GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE_USEHEADER)
299 GUICtrlSetData($todoInput, "")
300 EndIf
301
302 Case $todoClearBtn
303 _GUICtrlListView_DeleteAllItems($hListView)
304
305 Case $todoSaveBtn
306 SaveTodoList()
307
308 Case $todoLoadBtn
309 LoadTodoList()
310 EndSwitch
311 WEnd
312EndFunc
313
314Func SaveTodoList()
315 Local $hListView = GUICtrlGetHandle($todoList)
316 Local $count = _GUICtrlListView_GetItemCount($hListView)
317 If $count <> 0 Then
318 Local $f = FileOpen(@ScriptDir & "\todo.ini", 2)
319 If $f = -1 Then
320 MsgBox(16, "Error", "Cannot save file!")
321 Return
322 EndIf
323 For $i = 0 To $count - 1
324 Local $text = _GUICtrlListView_GetItemText($hListView, $i)
325 Local $checked = _GUICtrlListView_GetItemChecked($hListView, $i)
326 FileWriteLine($f, $checked & "|" & $text)
327 Next
328 FileClose($f)
329 EndIf
330EndFunc
331
332Func LoadTodoList()
333 Local $hListView = GUICtrlGetHandle($todoList)
334 If Not FileExists(@ScriptDir & "\todo.ini") Then Return
335 _GUICtrlListView_DeleteAllItems($hListView)
336 Local $lines = FileReadToArray(@ScriptDir & "\todo.ini")
337 For $i = 0 To UBound($lines) - 1
338 Local $parts = StringSplit($lines[$i], "|", 2)
339 If UBound($parts) = 2 Then
340 GUICtrlCreateListViewItem($parts[1], $todoList)
341 Local $index = _GUICtrlListView_GetItemCount($hListView) - 1
342 _GUICtrlListView_SetItemChecked($hListView, $index, $parts[0] = "True")
343 EndIf
344 Next
345 _GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE_USEHEADER)
346EndFunc
347
348Func WM_NOTIFY_HANDLER($hWnd, $iMsg, $wParam, $lParam)
349 Local $tNMHDR = DllStructCreate("int;int;int", $lParam)
350 Local $hwFrom = DllStructGetData($tNMHDR, 1)
351 Local $code = DllStructGetData($tNMHDR, 3)
352 Local $hListView = GUICtrlGetHandle($todoList)
353
354 If $code = $NM_DBLCLK Then
355 If $hwFrom = $hListView Then
356 Local $index = _GUICtrlListView_GetSelectionMark($hListView)
357 If $index <> -1 Then
358 Local $oldText = _GUICtrlListView_GetItemText($hListView, $index)
359 Local $newText = InputBox("Edit Task", "Double-click edit:", $oldText)
360 If Not @error And StringStripWS($newText, 3) <> "" Then
361 _GUICtrlListView_SetItemText($hListView, $index, $newText)
362 _GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE_USEHEADER)
363 EndIf
364 EndIf
365 EndIf
366 EndIf
367 Return $GUI_RUNDEFMSG
368EndFunc
369
370
371; PREPARE THE TRAY MENUITEMS
372; ==========================
373Opt("TrayMenuMode", 3) ; Removes default behavior (no auto pause)
374Opt("TrayOnEventMode", 1) ; Enables event-driven tray menu
375TraySetClick(8) ; Enable right-click to show tray menu
376TrayCreateItem("To-Do List")
377TrayItemSetOnEvent(-1, "ShowTodoList")
378TrayCreateItem("")
379TrayCreateItem("Help")
380TrayItemSetOnEvent(-1, "ShowHelp")
381TrayCreateItem("")
382TrayCreateItem("Exit")
383TrayItemSetOnEvent(-1, "ExitScript")
384
385Func ExitScript()
386 Exit
387EndFunc
388
389Func ShowHelp()
390 Local $helpMsg = _
391 "(tilda) - Toggle 'Always on Top' for the active window" & @CRLF & _
392 "{PAUSE} - Fix YouTube keybinding issues (simulate SPACE click)" & @CRLF & _
393 "Ctrl+Alt+B - Show the current price of Bitcoin or Monero" & @CRLF & _
394 "Ctrl+Alt+N - Convert a dollar amount to the selected coin" & @CRLF & _
395 "Ctrl+Alt+M - Convert coin amount to dollars" & @CRLF & _
396 "Ctrl+Alt+S - Switch between Bitcoin and Monero" & @CRLF & _
397 "Ctrl+G - Enable/disable Google Maps mouse-to-X remap" & @CRLF & _
398 "Ctrl+Alt+1 - Hide/unhide the current window in slot 1" & @CRLF & _
399 "Ctrl+Alt+2 - Hide/unhide the current window in slot 2" & @CRLF & _
400 "Ctrl+Alt+3 - Hide/unhide the current window in slot 3" & @CRLF & _
401 "Ctrl+Alt+0 - Unhide all hidden windows" & @CRLF & _
402 "Ctrl+Alt+C - Check spelling of selected word" & @CRLF & @CRLF & _
403 "©2020-2025 DosaidSoft.com - By Paul Meyer"
404
405 MsgBox(64, "MouseWheel Hotkeys Help", $helpMsg)
406EndFunc
407
408; THE PROGRAM MAIN LOOP
409; =====================
410While True
411 If $mapsToggle = True Then HoldDownMouse(58) ;if the X key is pressed - hold down the mouse
412 GUIGetMsg()
413WEnd