kjpolker Posted February 14, 2018 Share Posted February 14, 2018 (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: Edited February 14, 2018 by kjpolker Link to comment Share on other sites More sharing options...
Danp2 Posted February 14, 2018 Share Posted February 14, 2018 Is this running in a Chrome browser window or something else? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
kjpolker Posted February 14, 2018 Author Share Posted February 14, 2018 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. Link to comment Share on other sites More sharing options...
Danp2 Posted February 14, 2018 Share Posted February 14, 2018 There's a Chrome UDF that should allow you to simulate a click in the browser window. You could also take a look at the Webdriver UDF in my signature. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
kjpolker Posted February 14, 2018 Author Share Posted February 14, 2018 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? Link to comment Share on other sites More sharing options...
Danp2 Posted February 14, 2018 Share Posted February 14, 2018 Sorry, but I've never used the Chrome UDF. If you search, I'm sure you can find the answer on the forum. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
kjpolker Posted February 15, 2018 Author Share Posted February 15, 2018 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. Link to comment Share on other sites More sharing options...
Deye Posted February 15, 2018 Share Posted February 15, 2018 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now