Source language: Translate to:

problem with BrowserSetElement

General questions about NeoBook

Moderator: Neosoft Support

problem with BrowserSetElement

Postby mohsen.zeus » Wed Aug 27, 2014 1:04 pm

Greetings
I am using BrowserGetElement ، BrowserSetElement action code
And I want to show the result_box from translate.google.com/?hl=en&tab=wT
but i cant show result translate in neobook :|
how it can be added? :!:
mohsen.zeus
 
Posts: 14
Joined: Mon Oct 07, 2013 9:29 am

Re: problem with BrowserSetElement

Postby mohsen.zeus » Thu Aug 28, 2014 4:02 am

No one came to help me?
:(
mohsen.zeus
 
Posts: 14
Joined: Mon Oct 07, 2013 9:29 am

Re: problem with BrowserSetElement

Postby Tony Kroos » Thu Aug 28, 2014 6:37 am

Browser(Set/Get)Element has no problem and nothing to do here. They work only for elements with "NAME" tag.
Code: Select all
BrowserExecScript "WebBrowser1" "var i = document.getElementById('result_box').getElementsByTagName('span');|var t = '';for(var j=0; j<i.length; j++){t += i(j).textContent+' '};|window.external.nbSetVar('Google',t)" "JScript"
Tony Kroos
 
Posts: 402
Joined: Thu Oct 15, 2009 3:43 pm

Re: problem with BrowserSetElement

Postby mohsen.zeus » Thu Aug 28, 2014 6:57 am

Thank you for the answer
I'm amateur
If possible More explain .
I just want to show translated result in label .
thank you again
mohsen.zeus
 
Posts: 14
Joined: Mon Oct 07, 2013 9:29 am

Re: problem with BrowserSetElement

Postby Tony Kroos » Thu Aug 28, 2014 7:18 am

What exactly you did not understand? Open your link in neobook's WebBrowser object, then execute BrowserExecScript code for that object and you will get result in [Google] variable.
Tony Kroos
 
Posts: 402
Joined: Thu Oct 15, 2009 3:43 pm

Re: problem with BrowserSetElement

Postby mohsen.zeus » Thu Aug 28, 2014 8:17 am

sorry but realy i don't know how to use this code
can you make a simple pub for me ?
mohsen.zeus
 
Posts: 14
Joined: Mon Oct 07, 2013 9:29 am

Re: problem with BrowserSetElement

Postby Neosoft Support » Thu Aug 28, 2014 10:32 am

Hi Mohsen,

There is a sample publication included with NeoBook called "Browser Elements.pub" which you should find in your documents folder under "NeoBook 5\Sample Apps\Browser Communication". This pub demonstrates how to use the BrowserSetElement action.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: problem with BrowserSetElement

Postby dpayer » Thu Aug 28, 2014 11:30 am

mohsen.zeus wrote:sorry but realy i don't know how to use this code
can you make a simple pub for me ?


First, you should always show what you have already done before asking for someone to do something for you. Post your sample that didn't work as you expected or the actions you used.

I could not get this to work either.

I looked at this and the element that contains the resultant translation is not easy to find. the Div does have an ID and when I inspect the element in Firefox it shows the style of the translated area to be "result_box". When I look in the source HTML I see that this style is being applied against the textarea field named edit-text.
Code: Select all
<span id=result_box class="short_text"></span></div></div><div id="gt-edit" style="display:none"><div style="width: 100%;"><textarea id=contribute-target name=edit-text wrap=SOFT tabindex=0 spellcheck="false" autocapitalize="off" autocomplete="off" autocorrect="off" ></textarea></div>


When I create a pub that lets you put the translate page in a webbrowser object and then you put in text to translate. THat works ok. But if I attempt to get element by name, it does not get the content of that text entry element. Here is my sample pub. (Create a new pub 800x600 and paste this content into it)
Code: Select all
 {NeoBook 5 Objects}
NeoBookVer=5.80
ObjectType=14
Name=WebBrowser1
X=11
Y=15
W=777
H=407
Anchor=0
FileName=about:blank
VarName=[WebBrowser1Status]
TitleVarName=[WebBrowser1Title]
URLVarName=[WebBrowser1Addr]
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=2
ObjectType=3
Name=PushButton1
X=19
Y=439
W=158
H=39
Anchor=0
Text=Go To Translate
Align=2
ImageStyle=0
ObjAction=BrowserGoTo "WebBrowser1" "https://translate.google.com"¶EnableObject "PushButton2"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=3
ObjectType=3
Name=PushButton2
X=627
Y=435
W=158
H=39
Anchor=0
Text=Get Translation
Align=2
ImageStyle=0
ObjAction=BrowserGoTo "WebBrowser1" "https://translate.google.com"¶BrowserGetElement "WebBrowser1" "edit-text" "[result]"¶AlertBox "Translation" "This is the translated text:|[result]"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
Enabled=No
TabOrder=4

Image
I use this action on the page that has the translated text:

BrowserGetElement "WebBrowser1" "edit-text" "[result]"

When enacted on the page that contains the translation, the result variable is empty and the google translate page clears itself and resets.

David P.
Last edited by dpayer on Thu Aug 28, 2014 4:26 pm, edited 1 time in total.
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: problem with BrowserSetElement

Postby mohsen.zeus » Thu Aug 28, 2014 11:43 am

tnq so much dpayer
how can find button in site browser element
Because browserElement just have text field
mohsen.zeus
 
Posts: 14
Joined: Mon Oct 07, 2013 9:29 am

Re: problem with BrowserSetElement

Postby dpayer » Thu Aug 28, 2014 12:04 pm

mohsen.zeus wrote:tnq so much dpayer
how can find button in site browser element
Because browserElement just have text field


Mohsen,

I guess you didn't realize from my post that I too have a problem getting the text to be returned from the browsergetelement action.

I think we both need someone with additional javascript knowledge or someone who can give a new idea. You shouldn't need the button to give you text, we should be able to retrieve it by obtaining the value of the element.

David P.
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: problem with BrowserSetElement

Postby David de Argentina » Thu Aug 28, 2014 5:05 pm

Be carefull using Google services !

They are free for final users, not for programmers.

Take a look of this:

viewtopic.php?f=1&t=20296&p=11212334

My defaulted cent,
David de Argentina
User avatar
David de Argentina
 
Posts: 1553
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina

Re: problem with BrowserSetElement

Postby Tony Kroos » Thu Aug 28, 2014 8:42 pm

Looks like we have different Googles )

Image

When I look in the source HTML I see that this style is being applied against the textarea field named edit-text.

I guess you won't find results here (and source string either), since it's dynamically generated content. Try to use "Inspect code" option to see generated content on-the-fly.
Also, Browser(GEt/Set)Element works only with source code of the page. So no wonder if it doesnt work for dynamic content handled by the browser itself, it just cannot be seen by Browser(GEt/Set)Element.

p.s: I admit that my JS code doesnt work for your sample pub ) Looks like it's another google code for different languages or smth... will research more )

EDIT: Uncheck "Enchanced security" and "IE7 compatibility" options in WebBrowser object, and JS works just fine. - http://oi59.tinypic.com/9gll5c.jpg
Tony Kroos
 
Posts: 402
Joined: Thu Oct 15, 2009 3:43 pm

Re: problem with BrowserSetElement

Postby mohsen.zeus » Thu Aug 28, 2014 11:08 pm

Thank you all
so can not build a dictionary with google
Now I have a question
i need a app use a website for show mobile model with number phone
http://92.42.49.87:8080/mtn_ir-dms-scw/ ... tlocale=en
this site is for iran
how can i make this app it posibble ?
mohsen.zeus
 
Posts: 14
Joined: Mon Oct 07, 2013 9:29 am

Re: problem with BrowserSetElement

Postby dpayer » Fri Aug 29, 2014 6:48 am

Tony Kroos wrote:Also, Browser(GEt/Set)Element works only with source code of the page. So no wonder if it doesnt work for dynamic content handled by the browser itself, it just cannot be seen by Browser(GEt/Set)Element.
EDIT: Uncheck "Enchanced security" and "IE7 compatibility" options in WebBrowser object, and JS works just fine. - http://oi59.tinypic.com/9gll5c.jpg


Good work Tony. That does give the desired result.

David P.
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: problem with BrowserSetElement

Postby Wrangler » Tue Mar 29, 2016 4:16 pm

I can use this function. Tony shows a screenshot that it is working, but I can't get it to work. Pasted in David's browser code. Unchecked Enhanced Security. The variable is empty. What was done with the code to make this work?
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1505
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Next

Return to General NeoBook Discussions

Who is online

Users browsing this forum: No registered users and 2 guests

cron