Jump to content

mouse over a part of a window with a class control name


Recommended Posts

I want to do an operation when I'm passing over with the mouse on the video part of a VLC window.

It has:

Title:VLC

Class: QWidget

Handle: 0x00180926

>>>> Control <<<<

Class: VLC DirectX video

Handle: 0x00050A08

How can I detect when the mouse pass over that 'VLC DirectX video Control' in that 'VLC' window?

Link to comment
Share on other sites

In practice, I want to send a 'Space' inpunt when I click the left mouse button on the film window.

I tried

if WinActive("CLASS:VLC DirectX video") and _IsPressed("01") ) Then

Send ('{Space}')

endif

Link to comment
Share on other sites

In practice, I want to send a 'Space' input when I click the left mouse button on the film window.

I tried:

if WinActive("CLASS:VLC DirectX video") and _IsPressed("01") ) Then 
    Send ('{Space}')
endif

but it doesn't detect the window because that is the name of the control, not the window.

If I put

if WinActive("VLC") and _IsPressed("01") ) Then

it works, but it sends the space also when I click the mouse button on other part of the window where I don't want to send space.

So, how can this be made?

Link to comment
Share on other sites

Maybe something like this

$hwnd = WinGetHandle("VLC")

If WinActive($hwnd) And _IsPressed("01")) Then
    $controlpos = ControlGetPos($hwnd, "", "[CLASS:VLC DirectX video]")
    $Mousepos = MouseGetPos()
    If $Mousepos[0] >= $controlpos[0] And $Mousepos[0] <= $controlpos[0] + $controlpos[2] Then
        If $Mousepos[1] >= $controlpos[1] And $Mousepos[1] <= $controlpos[1] + $controlpos[3] Then
            ControlSend($hwnd, "", "[CLASS:VLC DirectX video]", " ")
        EndIf
    EndIf
EndIf

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Thanks a lot for the code.

Apart for a missing ( after If, it partially works. That is it doesn't work in windowed mode but only in fullscreen mode.

Your code doesn't work in windowed mode, but if I put

_ArrayDisplay($controlpos)

for debug purpose, before $mousepos

it works after the array popup !

Why there's such behaviour and how can I solve this?

Edited by frank10
Link to comment
Share on other sites

Thank you. Now it works.

EDIT (it works also with Opt("MouseCoordMode", 0))

The only 'problem' is when I want to make a double click.

When you make doubleclick you want to toggle to fullscreen.

To be able to differentiate between the double and single, I made a 250ms Sleep.

If I make less, it's difficult to perform the double, but at 250ms some single click

doesn't recognize.

Is there another way to detect a single or double click:

i.e. single click--> send space, double-->toggle fullscreen ?

Edited by frank10
Link to comment
Share on other sites

I would use mode 2 as you will probably find it wont work on the right and bottom of control if its 0

As for your doubleclick, I would use TimerInit() and TimerDiff() functions to check for double click.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...