how to read VLC text element (QWidget) with Acc.ahk

Get help with using AutoHotkey and its commands and hotkeys

how to read VLC text element (QWidget) with Acc.ahk

02 Mar 2016, 11:38

I want to read the current time and video duration from a VLC video player window.
An archived forum thread post suggests the ACC library can do that.

I also found the ACC library helper tool called Accessible Info Viewer .

I drag the "cross" in the info viewer onto the VLC window duration text element (the text in red box here ).
This information is then shown in the info viewer:

The data I want is called Name in the info viewer, "1:57:02" in this example

But I've so far failed to make a small script with acc.ahk to read that into a variable for use in the script.

I've tried the below and a few more variations. But I probably misunderstand something about the syntax for the Acc_Get command. Help!

Code: [Select all] [Download] GeSHi © Codebox Plus

SetWorkingDir %A_ScriptDir%
#SingleInstance force
SetTitleMatchMode 2
#Include Acc.ahk
;test := Acc_Get(Cmd, ChildPath="", ChildID=0, WinTitle="", WinText="", ExcludeTitle="", ExcludeText="")
test1 := Acc_Get("Name","3",0, "ahk_class QWidget5") ;test = nothing
test2 := Acc_Get("Name","3",0, "ahk_exe vlc.exe") ;test = Application
test3 := Acc_Get("Name",3,0, "ahk_id 0x480AEC") ;test = Application
msgbox %test1%`n%test2%`n%test3%

Re: how to read VLC text element (QWidget) with Acc.ahk

03 Mar 2016, 14:04

Hurrah I got it now! The trick was to first use the Accessible Info Viewer on the whole VLC window and then work our way down to the specific control from there.

The method to use Accessible Info Viewer and acc.ahk then goes like this
1 Open Accessible Info Viewer and click the crosshair and drag it to the outer edge of the VLC window until a red border is shown there. Release the mouse button.
2 Click "Show Acc Structure" in Accessible Info Viewer. You will see a tree structure.
3 Expand and click on items and you'll see the red border move to smaller and smaller elements in the window. Keep going until the wanted control is in red. Click on that item. The statusbar in the Info Viewer now has the path string we will use. 4,3,3,3 in my example. That is what we are after. However the commas must be changed to dots, . (If there was no statusbar text we could still calculate the value by taking the number for each level in the Acc Structure tree view. In this example window > [4] window > [3] client > [3] border > [3] text which make up the string )
Screenshot here
4 Next use the detected path value, , into a script that also includes Acc.ahk

Code: [Select all] [Download] GeSHi © Codebox Plus

#Include Acc.ahk
test := Acc_Get("Name","",0, "ahk_exe vlc.exe")
msgbox %test%

...and we get the value of the field "Name" for that element. Success!

With the same method we can figure out more paths and get more element values. For example both the length and duration of the currently playing video.

Code: [Select all] [Download] GeSHi © Codebox Plus

#Include Acc.ahk
length := Acc_Get("Name","4,3,3,3",0, "ahk_exe vlc.exe")
position := Acc_Get("Name","",0, "ahk_exe vlc.exe")
msgbox length = %length%`nposition = %position%

Return to “Ask For Help”

Who is online

Users browsing this forum: argau, astrals, Bing [Bot], Cuadrix, holahapi, Yahoo [Bot] and 24 guests