Sign in to follow this  
Followers 0
jjj

google page creator auto upload help

16 posts in this topic

#1 ·  Posted (edited)

can anyone help me with an automated upload to gpc...

i have a script that will automatically log in to the site, using the ie.au3, but i can't get the rest. i need to select the link 'upload' then fill in the text field with the filename and path, then hit enter. i am trying to do this without using mouseclicks, as i want it to work hidden. i have tried the click link by text command, but it wont work.

i have attached the source for the section that contains the upload portion -its all one line-, but if you havent seen the google page creator site, it probably wont be any help.

with the text form closed, and the upload 'link'...

[<span id="tr_toggle-upload-form" onclick="_TR_toggleSmUploadDrawer(this)" class="tr_pseudo-link">upload</span>] </div>

with the text form open...

<form method="post" enctype="multipart/form-data" accept-charset="utf-8" target="tr_post-iframe-tr_1161296296433" style="margin-bottom: 0px;" onsubmit="return false" action="/upload-file-simple/mynamehere/?authtoken=83d6a667dad07b47d4bfe91a2befb041d7f377d6"><input style="-moz-user-select: none;" name="file" size="7" type="file"></form></div></div> [<span id="tr_toggle-upload-form" onclick="_TR_toggleSmUploadDrawer(this)" class="tr_pseudo-link">close</span>] </div></div>  </td> <td></td> </tr>
Edited by jjj

Share this post


Link to post
Share on other sites



this is just a bump to see if anyone can help me out, please...

Share this post


Link to post
Share on other sites

I think dale mentioned something about File forms having to be filled in a different way. Perhaps use an _IEAction with a "Click" then a controlSend

Share this post


Link to post
Share on other sites

Unfortunately you cannot script the browser to insert text into an INPUT TYPE=FILE element -- it is a security restriction.

You must use Send or ControlSend. Here is an example:

; *******************************************************
; Example 4 - Set the value of an INPUT TYPE=FILE element
;               (security restrictions prevent using _IEFormElementSetValue)
; *******************************************************
;
#include <IE.au3>

$oIE = _IE_Example("form")
$oForm = _IEFormGetObjByName($oIE, "ExampleForm")
$oInputFile = _IEFormElementGetObjByName($oForm, "fileExample")

; Assign input focus to the field and then send the text string
_IEAction($oInputFile, "focus")
Send("C:\myfile.txt")oÝ÷ Ù:,zwm¢Ø^Â)Ý£"¶.¶¯x"µúºÊÞ¦VzØ^IéÝr¦jwpØm+¢{k¢TÖ®¶­sd6öçG&öÅ6VæBôU&÷W'GvWBb33c¶ôRÂgV÷C¶væBgV÷C²ÂgV÷C²gV÷C²ÂgV÷C´çFW&æWBWÆ÷&W%õ6W'fW#gV÷C²ÂgV÷C´3¢b3#¶×fÆRçGBgV÷C²

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

Share this post


Link to post
Share on other sites

Here is an expanded example with an invisible window:

; *******************************************************
; Example 5 - Set the value of an INPUT TYPE=FILE element
;               Same as previous example, but with invisible window
;               (security restrictions prevent using _IEFormElementSetValue)
; *******************************************************
;
#include <IE.au3>

$oIE = _IE_Example("form")

; Hide the browser window to demonstrate sending text to invisible window
_IEAction($oIE, "invisible")

$oForm = _IEFormGetObjByName($oIE, "ExampleForm")
$oInputFile = _IEFormElementGetObjByName($oForm, "fileExample")

; Assign input focus to the field and then send the text string
_IEAction($oInputFile, "focus")
$hIE = _IEPropertyGet($oIE, "hwnd")
ControlSend($hIE, "", "Internet Explorer_Server1", "C:\myfile.txt")

MsgBox(0, "Success", "Value set to C:\myfile.txt")
_IEAction($oIE, "visible")

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

Share this post


Link to post
Share on other sites

thanks for the help dale, but i think i need a few other things figured out before i can use your suggestion. i need to hit the pseudo-link called 'upload', which will open the text input form, and then the file can be sent to the form.

have absolutely no idea if this is possible with the google page creator, but it would be great if i could get this to work.

Share this post


Link to post
Share on other sites

Are you needing to click on thaT first element?

If so,

$oThing = _IEGetObjByName($oIE, "tr_toggle-upload-form")
_IEAction($oThing, "click")
_IELoadWait($oIE)

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

Share this post


Link to post
Share on other sites

ok, the click on the element worked perfectly, but now i think i am having problems with using the correct name for the file box. can you pick out the names i should be using for the following lines...

$oForm = _IEFormGetObjByName($oIE, "ExampleForm")

$oInputFile = _IEFormElementGetObjByName($oForm, "fileExample")

Share this post


Link to post
Share on other sites

ok, the click on the element worked perfectly, but now i think i am having problems with using the correct name for the file box. can you pick out the names i should be using for the following lines...

$oForm = _IEFormGetObjByName($oIE, "ExampleForm")

$oInputFile = _IEFormElementGetObjByName($oForm, "fileExample")

The form in your example has no name or ID attribute, so you must get it by index instead. You do this with _IEFormGetCollection. For example, if it is the first form on the page, its index will be 0 and you would use:

$oForm = _IEFormGetCollection($oIE, 0)
$oInputFile = _IEFormElementGetObjByName($oForm, "file")

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

Share this post


Link to post
Share on other sites

thanks alot for the help, but i just cant get it to work. my script runs witout errors, but the filename does not appear in the file form, and the form does not submit. ive noticed that when the page is open, i cant manually fill in the file form even when i click on it with the mouse, and type in the filename with my keyboard, but it will allow this action if i hit the browse button next to the form. i cant find anything in the html for the browse button for me to simulate a click on that, so i guess im just s.o.l.

again, thanks for your help dale, but unless you have any other suggestions, i think i may not be able to do this.

Share this post


Link to post
Share on other sites

The fact that you cannot type into the file input box interactively is significant -- ControlSend will never work in that mode either.

I'm afraid you'll need to study and understand a lot more about what is being done on that page in order to make it work.

It is possible that the script on the page is setting the input field attribute to "disable" -- there is actually a function in IE.au3 to enable it, but if it is set to disable because there is page logic that depends on it you might screw things up to change it blindly.

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

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

there is actually a function in IE.au3 to enable it, but if it is set to disable because there is page logic that depends on it you might screw things up to change it blindly.

ok, the script has the form diabled with this line:

unselectable="on"

is this something i can change, and if so how? i will never know fully what is going on in the page's code, but i really want this to work, so i want to try everything. (thanks for your help)

EDIT: I just realized that i can interact with the form when i am using firefox, but not when i am using internet explorer. ill look into security stuff, but do you have any idea why this would happen?

Edited by jjj

Share this post


Link to post
Share on other sites

ok, the script has the form diabled with this line:

unselectable="on"

is this something i can change, and if so how? i will never know fully what is going on in the page's code, but i really want this to work, so i want to try everything. (thanks for your help)

EDIT: I just realized that i can interact with the form when i am using firefox, but not when i am using internet explorer. ill look into security stuff, but do you have any idea why this would happen?

You can override this by getting a reference to the form field, e.g. $oFormElement and then:

$oFormElement.unselectable = "off"

The property is only recognized by IE, not by other browsers, which explains why it would not affect FireFox.

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

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

ok, it is really close to being done!

i got the form to be interactive, and the script is filling the form, but it wont submit. any idea why it wont work?

here is the full line of code for this form after filling it in:

<FORM style="MARGIN-BOTTOM: 0px" accept-charset=utf-8 onsubmit="return false" action=/upload-file-simple/mynamehere/?authtoken=83ef0ff2f8785bf4ecc68cc238ae8377065e1aa8 method=post target=tr_post-iframe-tr_1161652623573 encType=multipart/form-data><INPUT type=file size=7 value=C:\myfile.txt name=file Yg="14" unselectable="off"></FORM>

Edited by jjj

Share this post


Link to post
Share on other sites

dale, thanks for the help with this, there is absolutely no way i would have been able to do it without your guidance. (you basically wrote it for me)

anyway, i got it to work, the submit was working, but the page just wasnt updating, so it didnt seem like anything was happening. ill post the finished script when i clean it up, thanks!

Share this post


Link to post
Share on other sites

(you basically wrote it for me)

No I didn't and I'll deny it if you ever repeat that in public! :whistle:

I think you learned some things along the way, so I was glad to 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

Share this post


Link to post
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
Sign in to follow this  
Followers 0