So if you look in my post history, I have a script that I run from launch that handles a multitude of hotkeys for my HTPC. I use chrome to watch youtube videos in the smart tv format using a user-agent string to spoof my pc being a PS5 and that works great. I use a library I found here viewtopic.php?t=82431 that allows me to load specific cursor schemes as well as a library a that user over at the Launchbox forums created for hiding/restoring the desktop. It works pretty good except if I use winwaitclose within the hotkey for YT, it hangs, never restoring my desktop and as a result I created a winwaitactive loop that waits for that tab to close and it restores the desktop and cursor scheme and now my hotkey works as expected. After figuring this out, I got the idea of extending the loop so it toggles the cursor when the tab is open and when I alt+tab out or press the windows key, it restores the desktop and original cursor scheme. I cannot seem to get this to work though. I have pasted my (currently) working hotkey below:
Code: Select all
#SingleInstance Force
#Persistent
#NoEnv
#Include, lib\Cursors.ahk
#Include, lib\DeskToggle.ahk
SendMode Input
SetWorkingDir, %A_ScriptDir%
SetTitleMatchMode, 2
insert:: ; Gives back mouse cursor, turns off SMS and kills nav sounds, while still allowing Chrome YTV to cont. running
keywait, insert
SoftClear()
return
^!v::
keywait, v
YouTubeTV()
return
;==========================================================================================================================================================
; Remapped for YouTube TV ONLY
;==========================================================================================================================================================
#IfWinActive, YouTube on TV - Google Chrome
~up::
SoundPlay, %A_ScriptDir%\lib\Data\Assets\Audio\keypress\Move.wav, wait
Return
~down::
SoundPlay, %A_ScriptDir%\lib\Data\Assets\Audio\keypress\Move.wav, wait
Return
~left::
SoundPlay, %A_ScriptDir%\lib\Data\Assets\Audio\keypress\Move.wav, wait
Return
~right::
SoundPlay, %A_ScriptDir%\lib\Data\Assets\Audio\keypress\Move.wav, wait
Return
~Enter::
SoundPlay, %A_ScriptDir%\lib\Data\Assets\Audio\keypress\select.wav, wait
Return
~esc::
SoundPlay, %A_ScriptDir%\lib\Data\Assets\Audio\keypress\escape.wav, wait
Return
~backspace::
SoundPlay, %A_ScriptDir%\lib\Data\Assets\Audio\keypress\backspace.wav, wait
Return
~Media_Play_Pause::
SoundPlay, %A_ScriptDir%\lib\Data\Assets\Audio\keypress\pause.wav, wait
Return
~Media_Stop::
SoundPlay, %A_ScriptDir%\lib\Data\Assets\Audio\keypress\pause.wav, wait
Return
~Media_next::
SoundPlay, "%A_ScriptDir%\lib\Data\Assets\Audio\keypress\nav fwd.wav", wait
Return
~Media_Prev::
SoundPlay, "%A_ScriptDir%\lib\Data\Assets\Audio\keypress\nav prev.wav", wait
Return
+x::Media_Stop
SoundPlay, %A_ScriptDir%\lib\Data\Assets\Audio\keypress\pause.wav, wait
Return
CharacterCycle(list){ ; cycles through characters
Static i
If (A_ThisHotKey = A_PriorHotKey and A_TimeSincePriorHotkey < 850) ; if you press the same key within 1 sec, cycle through characters
{
Send {BS} ; erases the last character put in
i++ ; selects the next character
}
Else i = 1 ; if you press a new key, select the first character
If (i > StrLen(list))
i = 1 ; wrap around at the end of list
StringMid c, list, i, 1
Send %c% ; sends the selected character
}
VideoSplash(file){
fs = --fullscreen ; self explanatory
ng = --intf dummy ;vlc no gui
pe = --play-and-exit
vc = --config=lib\Data\PortableApps\VLC\Data\settings\vlcrc ;vlc config file
VLC = lib\Data\PortableApps\VLC\VLCPortable.exe
spDir = lib\Data\Assets\Splash\Video ;Splash Videos
Run, %VLC% %spDir%\%file%.mp4 %fs% %vc% %ng% %pe% ;Run, % VLC " " spDir "\" file ".mp4 " fs " " ng " " pe
}
YouTubeTV(){
HideDesktop()
if WinExist("YouTube on TV - Google Chrome") ;Checks to see if the "YTTV" tab is open in Chrome in order to know how to proceed
{
WinActivate ;What "if WinExist" checked for in the previous instruction
MouseDisable()
Run, Z:\HTPC\Scripts\lib\Data\Tools\Gamepad_Tools\Controller_Companion\ControllerCompanion.exe
return
}
else
{
VideoSplash("YTTV") ; Video Intro for YTTV
MouseDisable()
Run, Z:\HTPC\Scripts\lib\Data\PortableApps\GoogleChromePortable64\App\Chrome-bin\chrome.exe --kiosk https://www.youtube.com/tv#/ --user-data-dir=Z:\HTPC\Scripts\lib\Data\PortableApps\GoogleChromePortable64\Data\profile --profile-directory=Default --user-agent="Mozilla/5.0 (PlayStation; PlayStation 5/2.26) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 Safari/605.1.15" ; Opens YTTV in Chrome in Kiosk mode (not window or tab)
Run, Z:\HTPC\Scripts\lib\Data\Tools\Gamepad_Tools\Controller_Companion\ControllerCompanion.exe
Return
}
}
loop {
WinWaitActive, YouTube on TV - Google Chrome
WinWaitClose
SoftClear()
}
SoftClear(){
KillCC() ;see above
KillVLC() ;see above
MouseEnable()
RestoreDesktop(ToggleEverything[1], ToggleEverything[2])
}
KillCC(){
if !A_IsAdmin
Run, % "*RunAs " (A_IsCompiled ? "" : A_AhkPath " ") Chr(34) A_ScriptFullPath Chr(34)
RunWait, TASKKILL /F /IM ControllerCompanion.exe /T,, Hide
}
KillVLC(){
if !A_IsAdmin
Run, % "*RunAs " (A_IsCompiled ? "" : A_AhkPath " ") Chr(34) A_ScriptFullPath Chr(34)
RunWait, TASKKILL /F /IM VLC.exe /T,, Hide
}
MouseEnable(){
SetCursorScheme("Volantes Dark")
BlockInput MouseMoveOff
}
MouseDisable(){
SetCursorScheme("YTTV") ; makes mouse cursor invisible, must install cursor scheme found in the lib\data\assets\cursors and icons folder
MouseMove, 0, 2159 ;move the mouse cursor out of the way
BlockInput MouseMove ;self-explanatory
}
[Mod action: Moved topic to v1 section. The main section is for v2.]