Also if anybody else has the same problem with SmallestElementFromPoint as user Skrell, please PM me
![Smile :)](./images/smilies/icon_e_smile.gif)
Excellent. I can see it in the GitDescolada wrote: ↑11 Jul 2022, 23:13@mora145, I didn't find any problems with it, just uploaded the wrong file I think. Corrected it.
Also if anybody else has the same problem with SmallestElementFromPoint as user Skrell, please PM meI am unable to reproduce the issue, so the more people testing it out the better
Code: Select all
SetTitleMatchMode, 2
#Include <UIA_Interface>
UIA := UIA_Interface()
chromeId := WinExist("ahk_exe Chrome.exe")
WinActivate, ahk_id %chromeId%
WinWaitActive, ahk_id %chromeId%
chrome := UIA.ElementFromHandle(chromeId, True)
bulletText := chrome.FindFirstBy("Name=NO ME GUSTA OR Name=DISLIKE")
Sleep, 1000
dateUpload := bulletText.FindByPath("-2", UIA.CreateCondition("ControlType", "Text"))
MsgBox, % dateUpload.GetCurrentPropertyValueEx("Name")
Code: Select all
MsgBox, Windows version: %A_OSVersion%
UIA := UIA_Interface()
condition := UIA.CreatePropertyConditionEx(30005, "Anexar",,0x2) ; 30005=UIA_NamePropertyId. Flag 0x2 == PropertyConditionFlags_MatchSubstring (works on Windows 10 October 2018 Update (version 1809) and newer)
MsgBox, % UIA.ElementFromHandle(WinExist("ahk_exe chrome.exe"), True).FindFirst(condition, 0x4).Dump()
Code: Select all
buttons := cUIA.FindAllByType("Button")
counter := buttons.length()
Loop, %counter%
{
msg := buttons[A_Index].Dump()
if msg contains Anexar
{
buttons[A_Index].Click()
break
}
}
Code: Select all
cUIA.FindFirstByName("Anexar",,2,False).Click()
Code: Select all
1
1.1
1.1.1
1.2
Code: Select all
#SingleInstance, Force
SendMode Input
SetWorkingDir, %A_ScriptDir%
#Include <UIA_Interface>
UIA := UIA_Interface()
WinActivate, Microsoft Office 2010
cEl := UIA.ElementFromHandle(WinExist("Microsoft Office 2010"))
^<::
Begins:
next := cEl.FindFirstBy("Name=Siguiente")
MsgBox, % next.FindByPath("+1", UIA.CreateCondition("ControlType", "Image")).Dump()
Code: Select all
next := cEl.FindFirstBy("NOT Name= AND ControlType=Image")
MsgBox, % next.Dump()
It has also happened to me with Chrome, on pages with many elements. I thought TreeWalker consumed a lot of resources very fast and crashed the program.Descolada wrote: ↑16 Jul 2022, 00:23@mora145, you code is fine, but there is something broken with Microsofts implementation of the TreeWalker in that program (inspect.exe treewalking doesn't work properly either). I'm filing a bug report, but it probably won't be fixed very soon :/
A workaround to get the image element:Code: Select all
next := cEl.FindFirstBy("NOT Name= AND ControlType=Image") MsgBox, % next.Dump()
Code: Select all
#NoEnv
#SingleInstance force
#include <UIA_Interface>
UIA := UIA_Interface()
q::
Asiakastuote_lisäys:
WinActivate, Käynnin yhteenveto
Sleep, 100
;asiakastuote := % A_Args[2]
KäynninYhteenveto := UIA.ElementFromHandle(WinExist("Käynnin yhteenveto"))
Kontaktitiedot := KäynninYhteenveto.FindFirstBy("ClassName=ContactDataControl")
Kontaktitiedot.FindFirstBy("AutomationId=StatisticsContactDataInvoicingHyperlink").Click()
Return
Code: Select all
saveConnectionTimeout := UIA.ConnectionTimeout, saveTransactionTimeout := UIA.TransactionTimeout ; Save previous values for timeouts
UIA.ConnectionTimeout := 500, UIA.TransactionTimeout := 200 ; Set shorter timeouts (could experiment with even shorter ones, minimum is 50)
try Kontaktitiedot.FindFirstBy("AutomationId=StatisticsContactDataInvoicingHyperlink").Click() ; Use "try" to avoid the error being thrown
UIA.ConnectionTimeout := saveConnectionTimeout, UIA.TransactionTimeout := saveTransactionTimeout ; Restore previous timeout values
Return to “Scripts and Functions (v1)”
Users browsing this forum: No registered users and 273 guests