Jump to content

_IEFormElementGetValue() doesn't work right.


Recommended Posts

Hello there,

I am trying 1 week now to find a solution. This is the code.

#include <IE.au3>
$oIE = _IECreate([url="http://translate.google.com/"]http://translate.google.com/[/url]#)
$oForm = _IEFormGetObjByName($oIE, "text_form")
$oText = _IEFormElementGetObjByName($oForm, "text")
_IEFormElementSetValue($oText, "hello")
Sleep(3000)
$oText1 = _IEFormElementGetObjByName($oForm, "source")
MsgBox(0, "Value", _IEFormElementGetValue($oText1))

I am trying to take the value of the second box that translates but it seems to give me value of the first box that you write......

I have found two Obj that gives values but i dont know why they are not working...

Please someone who know help me. Any help would be apreciated :oops:

Edited by ileandros

I feel nothing.It feels great.

Link to comment
Share on other sites

What made you think the result box is a form element? It is not, it is a span

<span class="short_text" id="result_box" lang="en">

Get a reference to it and use _IEPropertyGet innertext

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Dale

Holy shit! You are damn right. I was so confused so i didn't think about it. Concerating in the name and never thought about that...

It works fine now. Thank you so much. I am one whole week on this and got stuck...

Can i make an other question? Is it possible to set and take the values of the page without having to navigate the page???

I feel nothing.It feels great.

Link to comment
Share on other sites

You can make the page invisible and not show it on the screen (see _IEAction). There may be an API you can use instead of the browser interface - I have not investigated). You could also put the page in an invisible iFrame if you are tying it to an existing web page.

Other than that, I can't say.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

I already used the _IEAction($oIE, "invisible") but its shit. It opens first the page then makes it invisible. I am creating an GuiCtrlCreateObj on an IECreateEmbbeded and hide it so it is gonna be invisible but this is a shit solution. Sth else would be better. Well thank you very much. You solved my

biggest problem :oops:

I feel nothing.It feels great.

Link to comment
Share on other sites

You can also use invisible with _IECreate

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Just note that creating topics stating that a function doesn't work right (when the trouble is that you don't know how to use it) or saying that an idea offered is a "shit solution", do not endear you to the people you are asking for help.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

I am not saying that your idea is shit relax :bye: I said i knew already and... Well nvm my mistake :oops:

I am creating a GUICtrlCreateCombo() to set the language. The way to change the language is a button that opens a list.

I found it but there is a problem.

<div tabIndex="0" class="goog-inline-block goog-flat-menu-button je" id="gt-sl-gms" role="listbox" aria-expanded="false" aria-haspopup="false" unselectable="on">

After getting controlID of the button how can i set an other language?ControlClick is possible to help(i have never used it)?? I can't find the "listbox" with the language at the source code...

Edit: If you want i can post the working code so you can work on it to help me.

Edited by ileandros

I feel nothing.It feels great.

Link to comment
Share on other sites

You can post the code, but I don't want to see a complicated script that includes things not related to your question. Create a simple reproducer that contains no more code than necessary to demonstrate your problem and ask your question.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Here it is. As simple as i could

#include <IE.au3>
#include <EditConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>

$Form1 = GUICreate("iTranslate", 360, 400, 300, 124)
$Button1 = GUICtrlCreateButton("Translate", 270, 370, 75, 25)
$combo = GUICtrlCreateCombo("", 10, 35, 150)
GUICtrlSetData(-1,"English|French|Italian")
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
    Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$oIE = _IECreate("[url="http://translate.google.com/"]http://translate.google.com/[/url]#")
$oForm = _IEFormGetObjByName($oIE, "text_form")
$oText = _IEFormElementGetObjByName($oForm, "text")
_IEFormElementSetValue($oText, "hello")
Sleep(3000)
$id1 = _IEGetObjById($oIE, "gt-sl-gms")
ControlClick($oIE, "goog-inline-block goog-flat-menu-button je", $id1)
$id = _IEGetObjById($oIE, "result_box")
$oText1 = _IEPropertyGet($id, "innertext")
MsgBox(0, "Value", $oText1)
$select = GUICtrlRead($combo)
Switch $select
Case "French"
  MsgBox(0,"Message","This should translate French")
Case "English"
  MsgBox(0,"Message","This should translate English")
Case "Italian"
  MsgBox(0,"Message","This should translate Italian")
EndSwitch
EndSwitch
WEnd
Edited by ileandros

I feel nothing.It feels great.

Link to comment
Share on other sites

If you look at the address bar of IE each time you change the language, you'll notice that it changes. Each language has an abbreviation, which you could find, then put them in an array and have your script search the array based on your GUI input.

Link to comment
Share on other sites

If you look at the address bar of IE each time you change the language, you'll notice that it changes. Each language has an abbreviation, which you could find, then put them in an array and have your script search the array based on your GUI input.

Yes i know that is what im using now. But i hope there is an other options like clicking and changing tha language from the source code because this way i am doing i have to put thousands of urls for the thousands combination of the laguages. Thats why i am asking for an other solution also...

I feel nothing.It feels great.

Link to comment
Share on other sites

...this way i am doing i have to put thousands of urls for the thousands combination of the laguages.

Nonsense. You only need one URL that changes as the languages change--you just reload the same modified URL.

$sURL = "http://translate.google.com/#" & $sLanguage1 & "|" & $sLanguage2 & "|" & $sString
Link to comment
Share on other sites

Yes but to set the languages i have to read, know and them set them. It's the same....

$Language1 = bn|http://translate.google.com/#fr|bn
$Language2 = http://translate.google.com/#ar|bn|
and so goes on... Edited by ileandros

I feel nothing.It feels great.

Link to comment
Share on other sites

From examining the source with IE's F12 tools, here is your list:

<option value=af>Afrikaans</option>
<option value=sq>Albanian</option>
<option value=ar>Arabic</option>
<option value=hy>Armenian</option>
<option value=az>Azerbaijani</option>
<option value=eu>Basque</option>
<option value=be>Belarusian</option>
<option value=bn>Bengali</option>
<option value=bg>Bulgarian</option>
<option value=ca>Catalan</option>
<option value=zh-CN>Chinese</option>
<option value=hr>Croatian</option>
<option value=cs>Czech</option>
<option value=da>Danish</option>
<option value=nl>Dutch</option>
<option value=en>English</option>
<option value=eo>Esperanto</option>
<option value=et>Estonian</option>
<option value=tl>Filipino</option>
<option value=fi>Finnish</option>
<option value=fr>French</option>
<option value=gl>Galician</option>
<option value=ka>Georgian</option>
<option value=de>German</option>
<option value=el>Greek</option>
<option value=gu>Gujarati</option>
<option value=ht>Haitian Creole</option>
<option value=iw>Hebrew</option>
<option value=hi>Hindi</option>
<option value=hu>Hungarian</option>
<option value=is>Icelandic</option>
<option value=id>Indonesian</option>
<option value=ga>Irish</option>
<option value=it>Italian</option>
<option value=ja>Japanese</option>
<option value=kn>Kannada</option>
<option value=ko>Korean</option>
<option value=la>Latin</option>
<option value=lv>Latvian</option>
<option value=lt>Lithuanian</option>
<option value=mk>Macedonian</option>
<option value=ms>Malay</option>
<option value=mt>Maltese</option>
<option value=no>Norwegian</option>
<option value=fa>Persian</option>
<option value=pl>Polish</option>
<option value=pt>Portuguese</option>
<option value=ro>Romanian</option>
<option value=ru>Russian</option>
<option value=sr>Serbian</option>
<option value=sk>Slovak</option>
<option value=sl>Slovenian</option>
<option value=es>Spanish</option>
<option value=sw>Swahili</option>
<option value=sv>Swedish</option>
<option value=ta>Tamil</option>
<option value=te>Telugu</option>
<option value=th>Thai</option>
<option value=tr>Turkish</option>
<option value=uk>Ukrainian</option>
<option value=ur>Urdu</option>
<option value=vi>Vietnamese</option>
<option value=cy>Welsh</option>
<option value=yi>Yiddish</option>

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...