Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[AHK_L] Screen Reader -- a tool to get text anywhere


  • Please log in to reply
46 replies to this topic
robert_ilbrink
  • Members
  • 561 posts
  • Last active: Mar 10 2015 08:36 PM
  • Joined: 05 May 2012

Same here, useless Chinese in my display. Did it not originate from the Chinese forum?



jethrow
  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009

Thanks again for the code - quite educational. Question: for clearnup, shouldn't you be releasing trueCondition & walker from the GetElementWhole function before the script terminates?

 

Also, on a side note, is there a way to access the UIA interface from a UIA Element? I tried ComObjQuery, but no luck. For instance, in GetElementWhole(), you made uia global. Simple enough, but I'd think there would be a way to get it from the element. Or I suppose you could just create a local UIA Interface, if you wanted to avoid always defining uia as global/super-global.

 

BTW, sorry for hijacking your thread with UIA questions. Let me know if you'd like my UIA questions split off into a separate thread.



nepter
  • Members
  • 53 posts
  • Last active: Jun 05 2019 07:59 AM
  • Joined: 29 Jun 2012

Thanks again for the code - quite educational. Question: for clearnup, shouldn't you be releasing trueCondition & walker from the GetElementWhole function before the script terminates?

 

Also, on a side note, is there a way to access the UIA interface from a UIA Element? I tried ComObjQuery, but no luck. For instance, in GetElementWhole(), you made uia global. Simple enough, but I'd think there would be a way to get it from the element. Or I suppose you could just create a local UIA Interface, if you wanted to avoid always defining uia as global/super-global.

 

BTW, sorry for hijacking your thread with UIA questions. Let me know if you'd like my UIA questions split off into a separate thread.

It is supposed that intfc is released when program exits. Msdn doesn't tell, or I have not found. I will test it.

Global UIA or static other intfc is only for memory/time-saving. It exactly is not a good method. I will modify it, thanks. I will finish wrapping UIA by class soon, Storing pointer to UIA in class can solve it.

Any discussion about UIA is appreciated.



jethrow
  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009

... static other intfc is only for memory/time-saving.


Sure - I was thinking perhaps put the script in charge of Releasing them when it terminates:
#SingleInstance,force
#InstallKeybdHook
;#NoTrayIcon
global $ObjToRelease := new Object_Release

;/ ...

GetElementWhole(element){
	global uia
	static init:=1,trueCondition,walker
	if init
		init:=DllCall(vt(uia,21),"ptr",uia,"ptr*",trueCondition) ;IUIAutomation::CreateTrueCondition
		,init+=DllCall(vt(uia,14),"ptr",uia,"ptr*",walker) ;IUIAutomation::ControlViewWalker
		,$ObjToRelease.Add(trueCondition,walker)

;// ...

class Object_Release {
	Add(p*) { ;// need to be byref?
		for k,v in p
			this.insert(v)
	}
	__Delete() {
		for k,v in this
			ObjRelease(v)
	}
}
 
 

... I will finish wrapping UIA by class soon ...

Do you mean you're creating a generic UIA wrapper, or just wrapping enough of UIA for this project? I was thinking about how much it would take to create a full UIA wrapper - that seems like a big project though.

nepter
  • Members
  • 53 posts
  • Last active: Jun 05 2019 07:59 AM
  • Joined: 29 Jun 2012
Do you mean you're creating a generic UIA wrapper, or just wrapping enough of UIA for this project? I was thinking about how much it would take to create a full UIA wrapper - that seems like a big project though.

First, generic full UIA wrapper. Second, rewrap for advanced use.



Guest10
  • Members
  • 1216 posts
  • Last active: Oct 30 2015 05:12 PM
  • Joined: 27 Oct 2012

how to find out the version of XP i am running?



ozzii
  • Members
  • 167 posts
  • Last active: Oct 30 2015 04:54 PM
  • Joined: 23 Mar 2011

Win+Pause or under cmd : winver



Guest10
  • Members
  • 1216 posts
  • Last active: Oct 30 2015 05:12 PM
  • Joined: 27 Oct 2012

thanks, i am running Version 5.1 (Service Pack 2). so i guess i can't use this script?



jethrow
  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009

thanks, i am running Version 5.1 (Service Pack 2). so i guess i can't use this script?

 
You could try - but UIAutomation requires Service Pack 3. You could utilize IAccessible though. I use this at work to get info from the screen (requires the Acc Library):
#If GetKeyState("LButton")
	^c:: ;// Extract Text from Point
	{
		val := ""
		Acc := Acc_ObjectFromPoint(child)
		try val := Acc.accValue(child) ""
		if Not val
			try val := Acc.accName(child) ""
		if val
			clipboard := val ""
		ToolTip, % (val? val:"<No Value>")
		SetTimer, RemoveToolTip, -2000
		return
	}
RemoveToolTip:
{
	ToolTip
	return
}


jethrow
  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009

First, generic full UIA wrapper. Second, rewrap for advanced use.

 

I'd be quite interested in seeing both of these. I am writting a wrapper myself - mainly to learn the interfaces. If you'd like to collaborate, let me know - though you have more windows api expertise.



nepter
  • Members
  • 53 posts
  • Last active: Jun 05 2019 07:59 AM
  • Joined: 29 Jun 2012

I'd be quite interested in seeing both of these. I am writting a wrapper myself - mainly to learn the interfaces. If you'd like to collaborate, let me know - though you have more windows api expertise.

I am just a newcome ahk learner and win32 coder, and I have little time to develop it because of finance job burden. If you have interests, it is appreciated that you develop it. My work is here for your reference , not completed. https://github.com/n...cn/UIAutomation



segalion
  • Members
  • 50 posts
  • Last active: Oct 16 2014 09:20 AM
  • Joined: 02 Feb 2011

Hello nepter

I´ve been your incredible code... and I think is very promissing and powerful . Seems that all this stuff could be included in ahk by default...

 

I´ve been trying this on a WXP SP3 and works fine with some code but only get the firts character of almost everithig... Do you know if unicode ahk_L version is a requirement? Im ussing ansi ahk_L and i suspect that problem could be this.

 

 

 

Thanks a lot...

 

PD. I have been seen your git code too, and I cant understand howto make work the example code. It doesnt work at all... Maybe I can make a OnMessage(0x4e,"WM_NOTIFY") to tooltip everithing....



nepter
  • Members
  • 53 posts
  • Last active: Jun 05 2019 07:59 AM
  • Joined: 29 Jun 2012

Hello nepter

I´ve been your incredible code... and I think is very promissing and powerful . Seems that all this stuff could be included in ahk by default...

 

I´ve been trying this on a WXP SP3 and works fine with some code but only get the firts character of almost everithig... Do you know if unicode ahk_L version is a requirement? Im ussing ansi ahk_L and i suspect that problem could be this.

 


Thanks a lot...

 

PD. I have been seen your git code too, and I cant understand howto make work the example code. It doesnt work at all... Maybe I can make a OnMessage(0x4e,"WM_NOTIFY") to tooltip everithing....

Sorry for that, I have not considered of ansi version, you can change all strget(...) to strget(...,"utf-16") in script to run it.



robert_ilbrink
  • Members
  • 561 posts
  • Last active: Mar 10 2015 08:36 PM
  • Joined: 05 May 2012

Changed all strget(...) to strget(...,"utf-16") and still I get Chinese characters.



segalion
  • Members
  • 50 posts
  • Last active: Oct 16 2014 09:20 AM
  • Joined: 02 Feb 2011

Sorry for that, I have not considered of ansi version, you can change all strget(...) to strget(...,"utf-16") in script to run it.

Thanks a lot...

 

With "utf-16" works fine!!!.

 

I found only two things to be perfect:

 

1. Forcing allways to "utf-16" fails the the code that  it,s not utf-16 (i.e. Scite4autohotkey, that was the only that work without utf-16). Could be great to discover the kind of text to capure..

 

2. With some apps (like excel, outlook text mail, some parts of html code) dont work, and only capture part of the file name or title window... I dont know if could be possible to get more info about this or its limited by UIAutomation....

 

This is one of the best & powefull functionality since COM I,ve  been seen for AHK !!!

 

Please, Lexikos, considere this for integrate in next AHK_L releases....