Code: Select all
modeEl := davinci.FindFirstBy("Name='Mode' AND Type=Text")
modeEl.FindByPath("-2").Highlight() ; moves two elements to the left (or I guess the upward direction in the UIAViewer image)
Code: Select all
modeEl := davinci.FindFirstBy("Name='Mode' AND Type=Text")
modeEl.FindByPath("-2").Highlight() ; moves two elements to the left (or I guess the upward direction in the UIAViewer image)
Code: Select all
#Requires AutoHotkey v2.0
#include <UIA>
x::
{
if !(dvEl := GetDavinciElement())
return
MediaPool := dvEl.ElementExist({AutomationId:"UiMainWindow.bigBossWidget.widgetStack_Panel.WStackPage_Conform.m_pConformPanel.frameEditPageWidgetsContainer.frameEditPageMediaPool.frameMultipleBinGridLayoutContainer.frameMultipleBinLayoutTopLeft.frameTopLeftContent.mediaPoolWidget.frameContainer.frameMediaPoolViews.mediaPoolViewSplitter.frameMediaPoolClipViewContainer"}) ; Media Pool
Media2 := dvEl.ElementExist({AutomationId:"UiMainWindow.bigBossWidget.widgetStack_Panel.WStackPage_Conform.m_pConformPanel.frameEditPageWidgetsContainer.frameEditTimelinesHolder.frameConformTimelines.frameEditTimelineAndAudioView.frameEditTimelinesContainer.splitterEditTimelinesContainer.frameTimelineContainer.frameTimelineViewContainer.timelineViewsSplitter"}) ; timeline
if IsMouseInElement(MediaPool, Media2) {
soundbeep 900, 20
}
}
;\\\\\\\\\\\\\\\\\\\\\\\ FUNCTION \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
GetDavinciElement() {
static davinciId := 0, davinciElement := 0
if (!(dvId := WinExist("ahk_exe Resolve.exe")))
return
if ((davinciId == dvId) && davinciElement)
return davinciElement
else {
davinciElement := "", davinciId := dvId
while (!davinciElement && WinExist("ahk_exe Resolve.exe"))
try davinciElement := UIA.ElementFromHandle(dvId)
return davinciElement
}
}
IsMouseInElement(els*) { ; Returns 1 in the mouse is inside any of the provided UIA elements
for el in els {
if !IsObject(el)
continue
Coords := el.BoundingRectangle
if IsMouseInRect(Coords.l, Coords.t, Coords.r, coords.b)
return 1
}
return 0
}
IsMouseInRect(X1, Y1, X2, Y2, relative:="screen") {
savedCoordMode := A_CoordModeMouse
CoordMode "Mouse", relative
MouseGetPos &mouseX, &mouseY
CoordMode "Mouse", savedCoordMode
return (mouseX > X1 && mouseX < X2) && (mouseY > Y1 && mouseY < Y2)
}
Code: Select all
#Requires AutoHotkey v2.0
#include <UIA>
#HotIf WinActive("ahk_exe Resolve.exe")
x::
{
static cacheRequest := UIA.CreateCacheRequest(["AutomationId", "BoundingRectangle"],,, "None")
if !(dvEl := GetDavinciElement())
return
; Find all elements with one search, and if need to determine which elements were found use el.CachedAutomationId
els := dvEl.FindElements([{AutomationId:"UiMainWindow.bigBossWidget.widgetStack_Panel.WStackPage_Conform.m_pConformPanel.frameEditPageWidgetsContainer.frameEditPageMediaPool.frameMultipleBinGridLayoutContainer.frameMultipleBinLayoutTopLeft.frameTopLeftContent.mediaPoolWidget.frameContainer.frameMediaPoolViews.mediaPoolViewSplitter.frameMediaPoolClipViewContainer"} ; Media Pool
, {AutomationId:"UiMainWindow.bigBossWidget.widgetStack_Panel.WStackPage_Conform.m_pConformPanel.frameEditPageWidgetsContainer.frameEditTimelinesHolder.frameConformTimelines.frameEditTimelineAndAudioView.frameEditTimelinesContainer.splitterEditTimelinesContainer.frameTimelineContainer.frameTimelineViewContainer.timelineViewsSplitter"}],,,,cacheRequest) ; timeline
;for el in els {
; br := el.CachedBoundingRectangle
; MsgBox el.CachedAutomationId " is located at x" br.l " y" br.t
;}
if IsMouseInElement(els*) {
soundbeep 900, 20
}
}
;\\\\\\\\\\\\\\\\\\\\\\\ FUNCTION \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
GetDavinciElement() {
static davinciId := 0, davinciElement := 0
if (!(dvId := WinExist("ahk_exe Resolve.exe")))
return
if ((davinciId == dvId) && davinciElement)
return davinciElement
davinciElement := 0, davinciId := dvId
while (!davinciElement && WinExist("ahk_exe Resolve.exe"))
try davinciElement := UIA.ElementFromHandle(dvId)
return davinciElement
}
IsMouseInElement(els*) { ; Returns 1 in the mouse is inside any of the provided UIA elements
for el in els {
if !IsObject(el)
continue
Coords := el.CachedBoundingRectangle
if IsMouseInRect(Coords.l, Coords.t, Coords.r, coords.b)
return 1
}
return 0
}
IsMouseInRect(X1, Y1, X2, Y2, relative:="screen") {
savedCoordMode := A_CoordModeMouse
CoordMode "Mouse", relative
MouseGetPos &mouseX, &mouseY
CoordMode "Mouse", savedCoordMode
return (mouseX > X1 && mouseX < X2) && (mouseY > Y1 && mouseY < Y2)
}
UIA-v2 FindElement and ElementFromPath throw errors if the element is not found, because they assume you've done all the checking necessary to ensure the elements are there. This is for easier debugging, because you'll instantly get feedback about what went wrong. In this case you can instead use the corresponding "Exist" methods: ElementExist or ElementFromPathExist, which return either 0 or the element. FindElements doesn't throw an error, instead an empty array is returned in that case.
Code: Select all
static cacheRequest := UIA.CreateCacheRequest(["Type", "AutomationId", "ClassName", "Name", "BoundingRectangle"],,5, "None") ; 5 == Descendants + Element
if !(dvEl := GetDavinciElement())
return
cachedEl := dvEl.BuildUpdatedCache(cacheRequest)
found := cachedEl.CachedElementFromPath(({T:11,CN:"UiMenuItemAction", i:15})
Users browsing this forum: No registered users and 121 guests