sirmarvado99

autosyncplay v3

Jul 6th, 2026
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.62 KB | None | 0 0
  1. #NoEnv
  2. #SingleInstance Force
  3. SendMode Input
  4. SetWorkingDir %A_ScriptDir%
  5.  
  6. ; ======================================================================
  7. ; INITIAL CONFIGURATION
  8. ; ======================================================================
  9.  
  10. ; ⚠️ EDIT THIS PATH! Put the exact location of your SyncplayConsole.exe here
  11. ; if you installed it in a folder different from the default Windows path.
  12. rutaSyncplay := "C:\Program Files (x86)\Syncplay\SyncplayConsole.exe"
  13.  
  14. ; Global counter to know how many active notifications there are and stack them in cascade
  15. global cantNotificaciones := 0
  16.  
  17. ; Native AHK function: Runs automatically every time the clipboard content changes
  18. OnClipboardChange("AlCopiarAlgo")
  19. return
  20.  
  21. ; ======================================================================
  22. ; AUTOMATIC CLIPBOARD SENSOR (DETECTS LINK IN BACKGROUND)
  23. ; ======================================================================
  24. AlCopiarAlgo(Tipo) {
  25. global rutaSyncplay
  26.  
  27. ; 1. If what you copied is not text (e.g. images or files), the script ignores it
  28. if (Tipo != 1)
  29. return
  30.  
  31. ; 2. APP WINDOW FILTER: Only triggers if you are inside Stremio OR Nuvio
  32. if (!WinActive("ahk_exe stremio-shell-ng.exe") && !WinActive("ahk_exe Nuvio.exe"))
  33. return
  34.  
  35. ; 3. CONTENT FILTER: We grab the clipboard and check if it's a valid streaming link
  36. enlace := Clipboard
  37. if !(InStr(enlace, "http://") || InStr(enlace, "https://") || InStr(enlace, "magnet:"))
  38. return
  39.  
  40. ; --- AUTOMATIC PROCESS STARTED! ---
  41. CrearNotificacion("🔗 Link detected for Syncplay...", "Blue")
  42. Sleep, 300 ; Short pause for stability
  43.  
  44. ; CASE A: If Syncplay and MPV player were already open beforehand
  45. If (WinExist("ahk_exe SyncplayConsole.exe") && WinExist("ahk_exe mpv.exe"))
  46. {
  47. Gosub, ActivarYPegar
  48. }
  49. ; CASE B: If the programs are closed, the script boots them up for you
  50. Else
  51. {
  52. CrearNotificacion("Starting Syncplay...", "Orange")
  53.  
  54. ; Runs Syncplay minimized so its command line console doesn't clutter the desktop
  55. Run, "%rutaSyncplay%", , Min
  56.  
  57. ; We wait a maximum of 10 seconds for the MPV player to open and respond
  58. WinWait, ahk_exe mpv.exe, , 10
  59.  
  60. If (ErrorLevel = 0) ; If it opened successfully within the time limit
  61. {
  62. Gosub, ActivarYPegar
  63. }
  64. Else ; If it timed out or errored
  65. {
  66. CrearNotificacion("⚠️ Error: MPV took too long", "Red")
  67. }
  68. }
  69. }
  70. return
  71.  
  72. ; ======================================================================
  73. ; ACTION SUBROUTINES (MPV CONTROL)
  74. ; ======================================================================
  75.  
  76. ActivarYPegar:
  77. ; Brings the MPV player to the front of the screen
  78. WinActivate, ahk_exe mpv.exe
  79. WinWaitActive, ahk_exe mpv.exe, , 2
  80. Sleep, 200
  81.  
  82. ; Sends the Windows Ctrl+V command to paste the link directly into the player
  83. Send, ^v
  84.  
  85. ; Sync pause: Let MPV process the link before triggering the fullscreen shortcut
  86. Sleep, 300
  87.  
  88. ; Sends the 'f' key (native MPV shortcut) to automatically toggle Fullscreen
  89. Send, f
  90.  
  91. CrearNotificacion("✅ Link sent and Maximized!", "Green")
  92. return
  93.  
  94.  
  95. ; ======================================================================
  96. ; OSD NOTIFICATION SYSTEM (DYNAMIC VISUAL INTERFACE)
  97. ; ======================================================================
  98.  
  99. CrearNotificacion(texto, colorTexto) {
  100. static TextoMedido ; Prevents duplicate variable errors in simultaneous threads
  101. cantNotificaciones++
  102. idGui := cantNotificaciones + 10 ; Assigns a unique ID to each card so they don't overwrite each other
  103.  
  104. ; Card config: Always on top, borderless, and doesn't steal keyboard focus
  105. Gui, %idGui%:+AlwaysOnTop -Caption +ToolWindow +E0x20
  106. Gui, %idGui%:Color, 1A1A1A ; Premium dark grey background
  107.  
  108. ; Font settings (Bold and conditional color based on status)
  109. Gui, %idGui%:Font, s12 bold c%colorTexto%, Segoe UI
  110.  
  111. ; We add the text and calculate its size dynamically so the card adjusts to the phrase width
  112. Gui, %idGui%:Add, Text, x15 y12 vTextoMedido, %texto%
  113. GuiControlGet, TextoPos, %idGui%:Pos, TextoMedido
  114.  
  115. anchoCartel := TextoPosW + 30
  116. altoCartel := 45
  117. espaciado := 10 ; Separation between notifications if multiple stack up
  118.  
  119. ; Gets the bounds of your current screen resolution
  120. SysGet, Mon, MonitorWorkArea
  121.  
  122. ; Positions the card in the top-right corner and calculates the offset for cascading stacks
  123. xPos := MonRight - anchoCartel - 20
  124. yPos := MonTop + 20 + ((cantNotificaciones - 1) * (altoCartel + espaciado))
  125.  
  126. ; Displays the floating notification without activating it as the primary window
  127. Gui, %idGui%:Show, x%xPos% y%yPos% w%anchoCartel% h%altoCartel% NoActivate
  128. WinSet, Transparent, 255, ahk_id %idGui%
  129.  
  130. ; Schedules a timer to start a smooth fade-out effect after 4.5 seconds
  131. ContadorBorrado := Func("IniciarFadeOut").Bind(idGui)
  132. SetTimer, %ContadorBorrado%, -4500
  133. }
  134.  
  135. IniciarFadeOut(idGui) {
  136. ; Loop that progressively reduces notification opacity (fade-out effect)
  137. Loop, 15 {
  138. transparencia := 255 - (A_Index * 17)
  139. WinSet, Transparent, %transparencia%, ahk_id %idGui%
  140. Sleep, 20
  141. }
  142.  
  143. ; Destroys the notification interface from memory and subtracts one from global counter
  144. Gui, %idGui%:Destroy
  145. cantNotificaciones--
  146. if (cantNotificaciones < 0)
  147. cantNotificaciones := 0
  148. }
  149.  
Advertisement
Add Comment
Please, Sign In to add comment