how to get output( result ) as text once text is recognized ?

There are methods available to clear, undo, redo and get stats but i don't see any methods available to get the result of recognized result.

I am using myscript-text-web and here is the documentation https://myscript.github.io/myscript-text-web/components/myscript-text-web/#myscript-text-web:method-getStats but there is no method available to get the result.

1 person has this question

Dear Akash,

thank you for contacting us.

Currently, the text result is available when the myscript-text-web-result event is fired: https://myscript.github.io/myscript-text-web/components/myscript-text-web/#myscript-text-web:event-myscript-text-web-result

Best regards,


Hello Olivier,

Yes, when text is recognized at that time that event gets triggered but how can i get the 'Recognized Text' out of it ? Is there any specific method available or any line of code that can help me to get the output when that even gets triggered ?



1 person likes this

I am also interested in using the web components in this way, but having trouble using the calls in the 'Events' subsection. I can successfully use all the 'Methods' from the console. If I'm using the REST protocol how do I access the 'changed' event listener and thereby capture the result as it comes back?

I would like to append the result to a textarea like:

$('myscript-text-web').on('change', function() {


1 person likes this
Dear Akash,

currently, when setting a websocket connection, the websocket object reacts to messages from the server with 3 event managers:
onopen,  when a connection is opened with the server
onclose, when when server closes the connection
onmessage, that receives data.

In your case, when the onmessage occurs, after unserialize the JSON response, you first have to check if the event is "myscript-text-web-result". If so, then get the "value" object in the JSON response. You can use the library you prefer to extract data from JSON (many languages have a default one).

Best regards,

Dear Kamille,

if using the REST protocol, it doesn't have an event listener. When posting a REST request, you just get the JSON response, that you have to parse by yourself. After each request, context is lost, contrary to the websocket.

To append text to the result, you then need to do this by yourself in your display.

Best regards,


Hello Olivier,

Thanks for your response but i still don't understand why i need to use web-sockets for this ?

Here is the demo i installed on my server https://www.potionowl.com/web-samples/

Consider a case where i want to alert the recognized text instead of showing that text on the top. How can i do that ?

textInput.addEventListener('myscript-text-web-result', function () {
console.log("myscript-text-web-result event executed");



Dear Akash,

currently, would it be possible to have more specification?

Indeed, which kind of application do you want to have? A continuous recogniton, or send the message once and get the result?

Indeed, in the first case, then the websocket API is the choice.
If you want to send the message once, you should rather use the REST API.

Or you would like to have a "continous writing", but only get the result after a certain amount of time when no stroke was entered?

If no, please provide with more explanation, so that we can provide with an accurate answer.

Best regards,


Hi Oliver,

Even I am looking for the same answer. It would be great if you could provide an answer for both the cases.


Dear Samip,

can you please provide with more information about what you want to achieve?

Using the REST API, you can get the result parsing the "label' (see success response): http://doc.myscript.com/MyScriptCloud/3.2.0/reference/index.html#api-Text_Recognition-doSimpleRecognition
WIth the WebSocket, you should also get the label when the myscript-text-web-result event if fired (see what the response looks like: http://doc.myscript.com/MyScriptCloud/3.2.0/reference/index.html#api-Text_Websocket_Recognition-Continue).

If this doesn't help, please provide with more precise specification about your use-case.

Best regards,


I'm following this link: https://developer.myscript.com/get-started/web

Now, I am trying to fetch the recognized text using: 

textInput.addEventListener('myscript-text-web-result', function(e) {


            console.log('Inner Text: ' + e.target.innerText.trim());


Is this the correct way? 

Dear Samip,

that's exactly it.

When the myscript-text-web-result event is fired, you should parse the JSON response, and you  can get the text label.

Best regards,



Thanks for this helpful thread.



Gives me the text of the previous match result and not the latest match result.

Groping through the output of "console.dir(e)" showed me this path to the latest output:


Did I miss some better approach to getting the output or is this the recommended route?

Dear Emeka,

Here is another approach that should help you, replace the default 'index.js' example by the one available here: https://gist.github.com/padewitte/802ce33c27a049c8ea678e20434dee1d

You will then see how to get a full working example.

Best regards,

Login or Signup to post a comment