Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoEnv
- #SingleInstance Force
- SendMode Input
- SetWorkingDir %A_ScriptDir%
- ; ======================================================================
- ; INITIAL CONFIGURATION
- ; ======================================================================
- ; ⚠️ EDIT THIS PATH! Put the exact location of your SyncplayConsole.exe here
- ; if you installed it in a folder different from the default Windows path.
- rutaSyncplay := "C:\Program Files (x86)\Syncplay\SyncplayConsole.exe"
- ; Global counter to know how many active notifications there are and stack them in cascade
- global cantNotificaciones := 0
- ; Native AHK function: Runs automatically every time the clipboard content changes
- OnClipboardChange("AlCopiarAlgo")
- return
- ; ======================================================================
- ; AUTOMATIC CLIPBOARD SENSOR (DETECTS LINK IN BACKGROUND)
- ; ======================================================================
- AlCopiarAlgo(Tipo) {
- global rutaSyncplay
- ; 1. If what you copied is not text (e.g. images or files), the script ignores it
- if (Tipo != 1)
- return
- ; 2. APP WINDOW FILTER: Only triggers if you are inside Stremio OR Nuvio
- if (!WinActive("ahk_exe stremio-shell-ng.exe") && !WinActive("ahk_exe Nuvio.exe"))
- return
- ; 3. CONTENT FILTER: We grab the clipboard and check if it's a valid streaming link
- enlace := Clipboard
- if !(InStr(enlace, "http://") || InStr(enlace, "https://") || InStr(enlace, "magnet:"))
- return
- ; --- AUTOMATIC PROCESS STARTED! ---
- CrearNotificacion("🔗 Link detected for Syncplay...", "Blue")
- Sleep, 300 ; Short pause for stability
- ; CASE A: If Syncplay and MPV player were already open beforehand
- If (WinExist("ahk_exe SyncplayConsole.exe") && WinExist("ahk_exe mpv.exe"))
- {
- Gosub, ActivarYPegar
- }
- ; CASE B: If the programs are closed, the script boots them up for you
- Else
- {
- CrearNotificacion("Starting Syncplay...", "Orange")
- ; Runs Syncplay minimized so its command line console doesn't clutter the desktop
- Run, "%rutaSyncplay%", , Min
- ; We wait a maximum of 10 seconds for the MPV player to open and respond
- WinWait, ahk_exe mpv.exe, , 10
- If (ErrorLevel = 0) ; If it opened successfully within the time limit
- {
- Gosub, ActivarYPegar
- }
- Else ; If it timed out or errored
- {
- CrearNotificacion("⚠️ Error: MPV took too long", "Red")
- }
- }
- }
- return
- ; ======================================================================
- ; ACTION SUBROUTINES (MPV CONTROL)
- ; ======================================================================
- ActivarYPegar:
- ; Brings the MPV player to the front of the screen
- WinActivate, ahk_exe mpv.exe
- WinWaitActive, ahk_exe mpv.exe, , 2
- Sleep, 200
- ; Sends the Windows Ctrl+V command to paste the link directly into the player
- Send, ^v
- ; Sync pause: Let MPV process the link before triggering the fullscreen shortcut
- Sleep, 300
- ; Sends the 'f' key (native MPV shortcut) to automatically toggle Fullscreen
- Send, f
- CrearNotificacion("✅ Link sent and Maximized!", "Green")
- return
- ; ======================================================================
- ; OSD NOTIFICATION SYSTEM (DYNAMIC VISUAL INTERFACE)
- ; ======================================================================
- CrearNotificacion(texto, colorTexto) {
- static TextoMedido ; Prevents duplicate variable errors in simultaneous threads
- cantNotificaciones++
- idGui := cantNotificaciones + 10 ; Assigns a unique ID to each card so they don't overwrite each other
- ; Card config: Always on top, borderless, and doesn't steal keyboard focus
- Gui, %idGui%:+AlwaysOnTop -Caption +ToolWindow +E0x20
- Gui, %idGui%:Color, 1A1A1A ; Premium dark grey background
- ; Font settings (Bold and conditional color based on status)
- Gui, %idGui%:Font, s12 bold c%colorTexto%, Segoe UI
- ; We add the text and calculate its size dynamically so the card adjusts to the phrase width
- Gui, %idGui%:Add, Text, x15 y12 vTextoMedido, %texto%
- GuiControlGet, TextoPos, %idGui%:Pos, TextoMedido
- anchoCartel := TextoPosW + 30
- altoCartel := 45
- espaciado := 10 ; Separation between notifications if multiple stack up
- ; Gets the bounds of your current screen resolution
- SysGet, Mon, MonitorWorkArea
- ; Positions the card in the top-right corner and calculates the offset for cascading stacks
- xPos := MonRight - anchoCartel - 20
- yPos := MonTop + 20 + ((cantNotificaciones - 1) * (altoCartel + espaciado))
- ; Displays the floating notification without activating it as the primary window
- Gui, %idGui%:Show, x%xPos% y%yPos% w%anchoCartel% h%altoCartel% NoActivate
- WinSet, Transparent, 255, ahk_id %idGui%
- ; Schedules a timer to start a smooth fade-out effect after 4.5 seconds
- ContadorBorrado := Func("IniciarFadeOut").Bind(idGui)
- SetTimer, %ContadorBorrado%, -4500
- }
- IniciarFadeOut(idGui) {
- ; Loop that progressively reduces notification opacity (fade-out effect)
- Loop, 15 {
- transparencia := 255 - (A_Index * 17)
- WinSet, Transparent, %transparencia%, ahk_id %idGui%
- Sleep, 20
- }
- ; Destroys the notification interface from memory and subtracts one from global counter
- Gui, %idGui%:Destroy
- cantNotificaciones--
- if (cantNotificaciones < 0)
- cantNotificaciones := 0
- }
Advertisement
Add Comment
Please, Sign In to add comment