Hello David,

Looking at Chip's example,
you said that:
First of all, you define a Function, which takes one parameter; X1. What is it, that is supposed to be passed into the function?

What I think is being passed into the function is
something called
FirstPress
which is an optional Boolean
which indicates whether a key has been pressed for the first time (True) or has been pressed more than one time in succession (False). If this parameter is True, then x1 will have a value of True
otherwise x1 will have a value of false.

you then said:
I thought that would be the actual highlighted text.

the actual highlighted text is represented by
highlight.clipstext
and this is what is spoken by the
speakhl function
with the following line

speak highlight.clipstext

I hope this helps,

Mike.

At 03:18 30/09/2011, you wrote:
Thanks Chip, for your efforts.

Apparently, I am missing out something here. At least, I am not capable of applying your example, the way it stands.

First of all, you define a Function, which takes one parameter; X1. What is it, that is supposed to be passed into the function? I thought that would be the actual highlighted text. But there you have my understanding.

Further, you set an Object, called X. Not X1? Got confused about that one.

After all, here is my real problem in applying your code. I have built my app, using the Script Framework app from Gw. As you know, it will automatically generate the code needed for registering hotkeys. I had it register the hotkey of Ctrl-Windows-C, and that one calls a sub called ClipboardCalculation. I have pasted the ClipboardCalculation sub below. That is, I have stripped it from any of the calculation code itself, since that might not be relevant in this case. What am I doing wrong? I don't know where the function you supplied me, would fit in? Guess I am pretty dumb-headed right now, but there you have me. Sorry for bothering you.


Sub RegisterHotkeys()
If Not SO_HotkeyManager Is Nothing Then
If UBound(Split(INIFile(myINIFile).GetSectionKeys(SO_HotkeyManager.INISectionName), vbNullChar)) < 0 Then If Instr(INIFile(myINIFile).GetSectionKeys(SO_HotkeyManager.INISectionName), "Key01") <= 0 Then
   SO_HotkeyManager.Add "Key01", "Windows-C", "ManuallyCalculation"
  End If
If Instr(INIFile(myINIFile).GetSectionKeys(SO_HotkeyManager.INISectionName), "Key02") <= 0 Then
   SO_HotkeyManager.Add "Key02", "Kontroll-Windows-C", "ClipboardCalculation"
  End If
 End If

 If Not registeredHotkeys Is Nothing Then
  If registeredHotkeys.Count > 0 Then
   registeredHotkeys.RemoveAll
  End If
 End If

Set registeredHotkeys("Key01") = Keyboard.RegisterHotkey(SO_HotkeyManager.Key("Key01"), SO_HotkeyManager.Data("Key01"), Nothing, "Key01") Set registeredHotkeys("Key02") = Keyboard.RegisterHotkey(SO_HotkeyManager.Key("Key02"), SO_HotkeyManager.Data("Key02"), Nothing, "Key02")

End If
End Sub

Sub ClipboardCalculation(myKeyId)
'This routine is called when the hotkey Kontroll-Windows-C is pressed.
If Keyboard.KeyDescriberActive Then
 Speak myStrings(myKeyId & "_Description")
Else
 'Main routine functionality goes here
msgbox highlight.clipstext
' I inserted this line, so as to check what would actually be sent forth. Simply just a debugging line.
' And, of course, it comes out empty.

CurrencyCalculator( Highlight.ClipsText )
' The CurrencyCalculator is a sub, that takes one parameter - the expression that is to be converted. In this case, it will have the highlighted text passed on to it. ' Since the user also will have a chance of typing an expression manually, I decided to put all the calculation (or conversion, if you want) into a seperate Sub routine. ' The one hotkey of my app, will result in an input box, where the user enters his manual expression. ' The other hotkey, will grab the highlighted text, and pass that on as an expression. ' In both cases, the expression will be passed on to the Sub routine called CurrencyCalculator.
End If
End Sub



Thanks for all your feedback. I sure am missing some point here. Not too much brain activity, at 4AM in the morning. Smile!

----- Original Message ----- From: "Chip Orange" <[email protected]>
To: <[email protected]>
Sent: Friday, September 30, 2011 2:19 AM
Subject: RE: How to retrieve marked text?


Hi David,

sorry for the delay in answering this for you.

I just found today the .highlight property of the application object, which
returns a clips collection of any selected (marked) text.  I tried it out by
opening an internet explorer web page, then opened an immediate mode window
and typed in:

function speakhl(x1): speak highlight.clipstext: end function

set x=keyboard.registerhotkey("control-shift-z", "speakhl", , "")

going back to my web page, selecting some text, and pressing my hotkey. the
selected text was read out.
and   it should work anywhere.

hth,

Chip


-----Original Message-----
From: David [mailto:[email protected]]
Sent: Saturday, September 10, 2011 9:07 PM
To: [email protected]
Subject: Re: How to retrieve marked text?

Chip, and the rest:

I did try your suggested way of retrieving the marked text, by use of the
FocusedWindow.Control. Here is my findings.

Firstly, if you are focused on an edit box, i.e you are positioned in a
Notepad document, the approach you gave me Chip, is working perfectly.
Thanks.

The problem arises, if you are focused on a non-Edit box. Try for instance
the approach, if you are in a window under Explorer. That is, Open Windows
Explorer, and try to do the following two lines:

   Set FWC = FocusedWindow.Control
   ST = FWC.Selection

. You will get the following error message:

Object doesn't support this property or method: 'FWC.Selection'
< 0x800A01B6 >.

Any fix for this? Is there a way for my app to ignore the Selection, if it
cannot be retrieved in a given context?

I need the routine in my Currency Calculator. The user should be able to
mark the text holding a currency value (like a price), for instance on a
webpage. This seems to work with the above approach. But including the two
lines in the app, and then running the app from a non-edit boxed window,
causes the error shown above. I want to allow the user to run the app - for
manual entry of the currency value - from anywhere. Why I need a way to have
the app ignore the Selected Text session, if it cannot handle it in a given
case.

Any fix?

Thanks for helping out.

----- Original Message -----
From: "Chip Orange" <[email protected]>
To: <[email protected]>
Sent: Tuesday, September 06, 2011 1:25 AM
Subject: RE: How to retrieve marked text?


Hi David,

You have at least two ways of doing this that I know about.  the easiest
for
you is built into the window-eyes object model, and that is, anything
which
has text which can be selected is almost always an editbox (or
richEditBox)
control.  you can look in the app developers manual under objects, and
then
the controls topic, and in there the types of controls topic, and finally
in
there you'll find the editbox entry.  It's selection property returns a
string of the text which is selected.

I tried this out on notepad; and like most applications, it's focused
window
is nothing but one editbox control, so I just used the two lines below in
immediate mode (after I had opened a file and selected some text), to see
what the text was:

set c=focusedwindow.control
print c.selection

If you need to know more than what text is selected (such as whether it's
bolded etc.), then you'll have to likely do this another way; but if just
the text will do what you want, then this should work in any editbox or
richeditbox control.

hth,

Chip



________________________________

From: David [mailto:[email protected]]
Sent: Monday, September 05, 2011 5:02 PM
To: [email protected]
Subject: Re: How to retrieve marked text?


Thanks for the idea. It might of course eventually work; but would require

a
chunk of coding.

GW staff, why not have a method implemented in the Toolkit, that would
return marked text right away?



----- Original Message ----- From: Jared Wright <mailto:[email protected]>
To: [email protected]
Sent: Monday, September 05, 2011 10:51 PM
Subject: Re: How to retrieve marked text?


            FYI there's a hotkey that does this in Wineyes itself,
Ctrl+Shift+M by default. Don't know if there's a way to get at it through
the object model or not. I guess you could overload the hotkey and hook
onSpeak and dump what it says into a string if nothing else.
On 9/5/2011 1:50 PM, David wrote:

In my app, I want to be able to retrieve the text a user has
marked. That is, if you for instance are in a text document, and use the
Shift-Arrow keys to mark a text, then hit the hotkey of my app, the app
should retrieve the text you have marked, and do its job with the
retrieved
text. Hopefully this could be performed whether you are in a text editor,
in
browse mode on a wbpage, or from any other situation where it is possible
to
mark text the normal way.

Is there an easy to reach method in WE to achieve this?

Thanks,




Reply via email to