Jump to content

Recommended Posts

Posted (edited)

As the title suggests I am looking for a way to pause YouTube videos using ControlSend as the video is an inactive window.

I am only aware that pausing a video can be done so by hitting the "Space" key WITHIN the video. I assumed I could achieve this by using the following code:

ControlSend("[CLASS:Chrome_WidgetWin_1]", "", "[CLASS:Chrome_RenderWidgetHostHWND]", "{SPACE}")

This is not doing anything though. I have also tried ControlClick but with no success.

Is there something outside the box I am not thinking of? If all else fails I will just activate the window and click at a coordinate.

Snapshot of window information:

example.jpg

Edited by kjpolker
Posted
1 minute ago, Danp2 said:

Is this running in a Chrome browser window or something else?

This is running in a Chrome browser yes. Specifically, with the widget parameter built into Chrome.

Posted

I am not very familiar with UDF, It seems as though I need to install the support into my Chrome? Which in turn means that the function will only ever work on a computer with it installed?

Posted

Well what I ended up doing as a placeholder is just to activate the window. Not sure why the window needs to be activated but without that line the video continues to run.

WinActivate($hWnd)
ControlSend($hWnd, "", "Chrome_RenderWidgetHostHWND1", "{SPACE}")
Sleep(10)

I was hoping it would be an easy solution.

Posted

Provided you where getting the correct $hWnd and the last click was in the video frame then this should work for you without any problems, maybe its possible to pin in to the video frame control with the chrome UDF  not sure, didn't look into it
Otherwise this might be the easiest - simple solution yet .. 

  

#include <WinAPI.au3>

$hWnd = WinGetHandle("[CLASS:Chrome_WidgetWin_1]")
If Not @error Then _PlayPause(_WinAPI_GetWindow($hWnd, $GW_HWNDNEXT))

Func _PlayPause($hWnd)
    If Not StringInStr(WinGetTitle($hWnd, ""), "YouTube") Then Return
    Local $hC = "Chrome_RenderWidgetHostHWND1"
    ControlFocus($hWnd, "", $hC)
    ControlSend($hWnd, "", $hC, "{SPACE}")
EndFunc

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...