Jump to content

YouTube ControlClick help

Recommended Posts

I was looking at using a control click to click on the video when the mouse is inactive for a period of time. The control click doesn't seem to pause the videos. I'll provide the AutoIt V3 Window Info.png below. 

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <GDIPlus.au3>

HotKeySet("{ESC}", "Terminate")

$width = 800
$height = 625

$hMain = GUICreate("YouTube", 800, 585, @DesktopWidth / 2 - $width / 2, @DesktopHeight / 2 - $height / 2, _

$wPos = WinGetPos($hMain)


Local $oIE = _IECreateEmbedded()
GUICtrlCreateObj($oIE, 0, 0, $width + 0, $height + 0)
_IENavigate($oIE, "https://www.youtube.com/") ; Copy the login link here.

$begin = TimerInit()
While 1
    $moved = "no"
    $pos1 = MouseGetPos()
    $pos2 = MouseGetPos()

    If $pos1[0] <> $pos2[0] Then $moved = "yes"
    If $pos1[1] <> $pos2[1] Then $moved = "yes"

    If $moved = "yes" Then
        $begin = TimerInit()

    If TimerDiff($begin) > 10000 And $moved = "no" Then
        ControlClick("[CLASS:Internet Explorer_Server]", "", "left", 1, 335, 213)
        $begin = TimerInit()

Func Terminate()
EndFunc   ;==>Terminate


AutoIt V3 Window Info.png

Link to post
Share on other sites
ControlClick($hMain, "", "", "Left", 1, 50, 400)

Worked fine for me using your example. As did

ControlSend($hMain, "", "", "{Space}")

(If the youtube video is the active object)

Also, check out https://www.autoitscript.com/autoit3/docs/libfunctions/_Timer_GetIdleTime.htm instead of using your own timer, it might be a little simpler and cleaner ;)

Edited by InunoTaishou
Link to post
Share on other sites

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...