aa2zz6

YouTube ControlClick help

3 posts in this topic

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, _
        $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)

$wPos = WinGetPos($hMain)

GUISetState(@SW_SHOW)

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()
    Sleep(50)
    $pos2 = MouseGetPos()

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

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

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

Func Terminate()
    Exit
EndFunc   ;==>Terminate

 

AutoIt V3 Window Info.png

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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
1 person likes this

Share this post


Link to post
Share on other sites

Thank you, InunoTaishou.

Share this post


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