AHK use UIA (inspect) get the text problem Topic is solved
AHK use UIA (inspect) get the text problem
Anybody can help me.
How to write the code to get the text from (inspect) LegacyIAccessible. Value.
Please see the picture.
How to write the code to get the text from (inspect) LegacyIAccessible. Value.
Please see the picture.
- Attachments
-
- Screenshot_2022-08-13-01-01-17-96_6012fa4d4ddec268fc5c7112cbb265e7.jpg (227.2 KiB) Viewed 1442 times
-
- Posts: 4393
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: AHK use UIA (inspect) get the text problem
Try this:
Code: Select all
ControlGetText, text, RichEdit20W1, Inspect
RegExMatch(text, "LegacyIAccessible\.Value:\t\K\V+", m)
MsgBox, % m
Re: AHK use UIA (inspect) get the text problem
Thanks for your reply.
If I want get more texts from multiple positions, how to put your code in my script??
If I want get more texts from multiple positions, how to put your code in my script??
Code: Select all
#Include uia.ahk
$u:=new IUIAutomation
$e:=new IUIAutomationElement
$c:=new IUIAutomationCondition
$r:=new IUIAutomationCacheRequest
$t:=new IUIAutomationTreeWalker
^6::
Loop 1
{
Element1 := $u.ElementFromPoint(65|99<<32)
V1 := $e.(Element1).CurrentName() . "`n"
V1 := Trim(V1, " `t`r`n")
Element2 := $u.ElementFromPoint(382|134<<32)
V2 := $e.(Element2).CurrentValue() . "`n"
V2 := Trim(V2, " `t`r`n")
Element3 := $u.ElementFromPoint(590|210<<32)
V3 := $e.(Element3).CurrentName() . "`n"
V3 := Trim(V3, " `t`r`n")
Element4 := $u.ElementFromPoint(650|210<<32)
V4 := $e.(Element4).CurrentName() . "`n"
V4 := Trim(V4, " `t`r`n")
Element5 := $u.ElementFromPoint(700|210<<32)
V5 := $e.(Element5).CurrentName() . "`n"
V5 := Trim(V5, " `t`r`n")
MsgBox, % V1 " "V2 " " V3 " " V4 " " V5
}
return
- Attachments
-
- Screenshot_2022-08-13-10-17-47-78_6012fa4d4ddec268fc5c7112cbb265e7.jpg (99.16 KiB) Viewed 1312 times
Re: AHK use UIA (inspect) get the text problem
See example 1 in this thread
viewtopic.php?f=6&t=104999
viewtopic.php?f=6&t=104999
Re: AHK use UIA (inspect) get the text problem Topic is solved
@Lo4438, you haven't said which UIA library you are using, so I can only give a general answer. To get the Value.Value with UIA you need to either
1) Use IUIAutomationElement.GetCurrentPropertyValue with UIA_ValueValuePropertyId
2) Use IUIAutomationElement.GetCurrentPattern with UIA_ValuePatternId and then access CurrentValue from ValuePattern
With the UIA_Interface.ahk you can do it easier:
1) Use IUIAutomationElement.GetCurrentPropertyValue with UIA_ValueValuePropertyId
2) Use IUIAutomationElement.GetCurrentPattern with UIA_ValuePatternId and then access CurrentValue from ValuePattern
With the UIA_Interface.ahk you can do it easier:
Code: Select all
#Include UIA_Interface.ahk
UIA := UIA_Interface()
Element1 := UIA.ElementFromPoint(65, 99)
MsgBox, % Element1.Value
Re: AHK use UIA (inspect) get the text problem
Descolada, thank you so much.
Sorry Bro, I have another Problem ( about FileAppend)
When I run the script, MsgBox can show the text,
But the ( FileAppend ) function doesn't work, s.txt file doesn't create.
Please help to solve this problem.
Sorry Bro, I have another Problem ( about FileAppend)
When I run the script, MsgBox can show the text,
But the ( FileAppend ) function doesn't work, s.txt file doesn't create.
Please help to solve this problem.
Code: Select all
#Include UIA_Interface.ahk
UIA := UIA_Interface()
^5::
Loop 1
{
Element1 := UIA.ElementFromPoint(40, 90)
V1 := Element1.Value
Element2 := UIA.ElementFromPoint(380, 120)
V2 := Element2.Value
Element3 := UIA.ElementFromPoint(492, 210)
V3 := Element3.Name
Element4 := UIA.ElementFromPoint(566, 210)
V4 := Element4.Name
Element5 := UIA.ElementFromPoint(606, 210)
V5 := Element5.Name
FileAppend, % V1 " "V2 " " V3 " " V4 " " V5, C:\Users\k\OneDrive\桌面\text file\s.txt
MsgBox, % V1 " "V2 " " V3 " " V4 " " V5
}
return
- Attachments
-
- Screenshot_2022-08-14-01-31-55-85_6012fa4d4ddec268fc5c7112cbb265e7.jpg (41.35 KiB) Viewed 939 times
Re: AHK use UIA (inspect) get the text problem
Make sure your target directory "text file" exists, and that your script is saved in UTF-8-BOM encoding. Other than that I don't know what the problem might be
Re: AHK use UIA (inspect) get the text problem
Descolada, you are a genius.