Jump to content



Photo

Upload photo to website form


  • Please log in to reply
15 replies to this topic

#1 darkyr

darkyr

    Seeker

  • Active Members
  • 13 posts

Posted 20 October 2011 - 06:02 PM

$oForm=_IEFormGetObjByName($oIE, "uploadfile") $oInputFile=_IEFormElementGetObjByName($oForm, "photo_upload") _IEAction($oInputFile, "click") WinWait("Choose File to Upload") $hChoose = WinGetHandle("Choose File to Upload") ControlSetText($hChoose, "", "Edit1", "C:\AUTOEXEC.BAT") ControlClick($hChoose, "", "Button2")


The internet explorer "choose file to upload" pops up but after that the functions don't set the text nor do they click the button.
Could somebody take a look and tell me if I'm missing something?





#2 rcmaehl

rcmaehl

    No where near a noob nor a pro coder.

  • Active Members
  • PipPipPipPipPipPip
  • 642 posts

Posted 20 October 2011 - 06:08 PM

$oForm=_IEFormGetObjByName($oIE, "uploadfile") $oInputFile=_IEFormElementGetObjByName($oForm, "photo_upload") _IEAction($oInputFile, "click") WinWait("Choose File to Upload") $hChoose = WinGetHandle("Choose File to Upload") ControlSetText($hChoose, "", "Edit1", "C:\AUTOEXEC.BAT") ControlClick($hChoose, "", "Button2")


The internet explorer "choose file to upload" pops up but after that the functions don't set the text nor do they click the button.
Could somebody take a look and tell me if I'm missing something?


Try


$oForm=_IEFormGetObjByName($oIE, "uploadfile") $oInputFile=_IEFormElementGetObjByName($oForm, "photo_upload") _IEAction($oInputFile, "click") $Window = WinWait("Choose File to Upload") ControlSetText($Window, "", "Edit1", "File here") ControlClick($Window, "", "Button2")


Also, C:\Autoexec.bat != photo
  • darkyr likes this
Making dumb decisions and posting without thinking since August 7, 2011.Jury-rigging AutoIt to work how I want successfully since a while.Reading the manual since no one else seems to.My Github: https://github.com/rcmaehl/FCoFix-SoftwareWarning!: I'm a compulsive poster. When I post something in chat, ignore it unless it's a huge wall of text, because it's probably a compulsive post.

#3 darkyr

darkyr

    Seeker

  • Active Members
  • 13 posts

Posted 20 October 2011 - 06:11 PM

still didn't work and C:\Autoexec.bat was from an example i found in the forums, thanks for replying

#4 rcmaehl

rcmaehl

    No where near a noob nor a pro coder.

  • Active Members
  • PipPipPipPipPipPip
  • 642 posts

Posted 20 October 2011 - 06:16 PM

Try

$oForm=_IEFormGetObjByName($oIE, "uploadfile") $oInputFile=_IEFormElementGetObjByName($oForm, "photo_upload") _IEAction($oInputFile, "click") $Window = WinWait("Choose File to Upload") $1 = ControlSetText($Window, "", "Edit1", "File here") If $1 = 0 Then Msgbox(0x0, "Error", "Failed at $1") $2 = ControlClick($Window, "", "Button2") If $2 = 0 Then Msgbox(0x0, "Error", "Failed at $2")

It should tell you where it's failing.
  • darkyr likes this
Making dumb decisions and posting without thinking since August 7, 2011.Jury-rigging AutoIt to work how I want successfully since a while.Reading the manual since no one else seems to.My Github: https://github.com/rcmaehl/FCoFix-SoftwareWarning!: I'm a compulsive poster. When I post something in chat, ignore it unless it's a huge wall of text, because it's probably a compulsive post.

#5 darkyr

darkyr

    Seeker

  • Active Members
  • 13 posts

Posted 20 October 2011 - 06:22 PM

thank you, i got it to work, it seemed the problem was that it didnt finish loading the last page so the script didn't go forward, it just needed a _IeloadWait() .. i kinda feel stupid now
$Window = WinWait("Choose File to Upload") ControlSetText($Window, "", "Edit1", "File here") ControlClick($Window, "", "Button2")


but this works perfectly, thanks again !

Edited by darkyr, 20 October 2011 - 06:23 PM.


#6 darkyr

darkyr

    Seeker

  • Active Members
  • 13 posts

Posted 20 October 2011 - 06:40 PM

actually it seems it doesnt work until i click the browse button myself then it proceeds to fill and submit, does anybody know why doesnt it pick up the _IeAction popup window and only picksup the mouse click one?



MouseMove(_IEPropertyGet($oInputFile, "screenx") + _IEPropertyGet($oInputFile, "width") - 10, _           _IEPropertyGet($oInputFile, "screeny") + _IEPropertyGet($oInputFile, "height")/2) MouseClick("left") $Window = WinWait("Choose File to Upload","",5) ControlSetText($Window, "", "Edit1", "File here") ControlClick($Window, "", "Button2")

found dale's example to work but its still interesting if somebody could explain why the IeAction popup doesn't get catched by winwait, thanks!

Edited by darkyr, 20 October 2011 - 06:53 PM.


#7 DelStone

DelStone

    Wayfarer

  • Active Members
  • Pip
  • 69 posts

Posted 06 March 2012 - 01:38 PM

I too would be interested in knowing why this is the case...

#8 DaleHohm

DaleHohm

    Think of IE as an API...

  • MVPs
  • 5,888 posts

Posted 06 March 2012 - 02:21 PM

When you click the button using the DOM, control does not return to your script until the dialog has been processed. Usint the mouse-click avoids this since control returns to you immediately after the click is processed.

Dale
  • DelStone likes this
IE.au3 issues with Vista - Workarounds, Automate input type=file (Related)SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=YFree Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curlMSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model,Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbeddedFind and harvest Enum constants for COM codeAutoIt Snippets Database - you too can contribute!Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your troubleDoesn'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?

#9 DelStone

DelStone

    Wayfarer

  • Active Members
  • Pip
  • 69 posts

Posted 07 March 2012 - 02:01 AM

So Dale, it seems if I want to avoid keyboard interruption, ie not using a mouseclick, the only approach appears to be to use IEACTION to select the button, and kick off a second process that can complete and close the input box, so processing can effectively be done in the background - would you agree?

#10 DaleHohm

DaleHohm

    Think of IE as an API...

  • MVPs
  • 5,888 posts

Posted 07 March 2012 - 02:14 AM

No, I don't agree. Use the code in @darkyr's last reply - it came from the examples I write and you'll find in my sig.

Dale
IE.au3 issues with Vista - Workarounds, Automate input type=file (Related)SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=YFree Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curlMSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model,Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbeddedFind and harvest Enum constants for COM codeAutoIt Snippets Database - you too can contribute!Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your troubleDoesn'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?

#11 DelStone

DelStone

    Wayfarer

  • Active Members
  • Pip
  • 69 posts

Posted 07 March 2012 - 03:55 AM

his last example was

MouseMove(_IEPropertyGet($oInputFile, "screenx") + _IEPropertyGet($oInputFile, "width") - 10, _           _IEPropertyGet($oInputFile, "screeny") + _IEPropertyGet($oInputFile, "height")/2) MouseClick("left") $Window = WinWait("Choose File to Upload","",5) ControlSetText($Window, "", "Edit1", "File here") ControlClick($Window, "", "Button2")


which requires a mousemove/click - which is what I'm trying to avoid...

#12 DaleHohm

DaleHohm

    Think of IE as an API...

  • MVPs
  • 5,888 posts

Posted 08 March 2012 - 05:42 AM

My sig contains two examples. Look at them.

Dale
IE.au3 issues with Vista - Workarounds, Automate input type=file (Related)SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=YFree Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curlMSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model,Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbeddedFind and harvest Enum constants for COM codeAutoIt Snippets Database - you too can contribute!Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your troubleDoesn'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?

#13 DelStone

DelStone

    Wayfarer

  • Active Members
  • Pip
  • 69 posts

Posted 08 March 2012 - 06:04 PM

the first example is the same as above Dale
#include <IE.au3> $oIE = _IE_Example("form") $oT = _IEGetObjById($oIE, 'fileExample') MouseMove(_IEPropertyGet($oT, "screenx") + _IEPropertyGet($oT, "width") - 10, _          _IEPropertyGet($oT, "screeny") + _IEPropertyGet($oT, "height")/2) MouseClick("left") WinWait("Choose File to Upload") $hChoose = WinGetHandle("Choose File to Upload") ControlSetText($hChoose, "", "Edit1", "C:AUTOEXEC.BAT") ControlClick($hChoose, "", "Button2")


and I'm not sure which is the second example from all of the links... could you point the obvious out for me please?

#14 DelStone

DelStone

    Wayfarer

  • Active Members
  • Pip
  • 69 posts

Posted 23 March 2012 - 02:32 AM

It's strange that when I call an external program to complete an input box selected in IE via IEACTION($oIE, "clieck") it works fine but when I do the same via an adlibregister function it does not...

Func UploadPic()
If WinExists("Choose File") Then
ControlSetText("Choose File to Upload", "", "[CLASS:Edit; INSTANCE:1]", $photo)
Sleep(1000)
ControlClick("Choose File to Upload", "", "Button1")
AdlibUnRegister("UploadPic")
EndIf
EndFunc


Edited by DelStone, 23 March 2012 - 02:33 AM.


#15 DaleHohm

DaleHohm

    Think of IE as an API...

  • MVPs
  • 5,888 posts

Posted 23 March 2012 - 04:41 AM

and I'm not sure which is the second example from all of the links... could you point the obvious out for me please?


Automate input type=file (Related)

Those are two links from my sig with slightly different implementations.

Control is not returned to your script, AdLib functions can't run either. Look at the two examples.

Dale
IE.au3 issues with Vista - Workarounds, Automate input type=file (Related)SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=YFree Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curlMSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model,Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbeddedFind and harvest Enum constants for COM codeAutoIt Snippets Database - you too can contribute!Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your troubleDoesn'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?

#16 DelStone

DelStone

    Wayfarer

  • Active Members
  • Pip
  • 69 posts

Posted 26 March 2012 - 03:18 AM

Thanks Dale - problem solved :oops:




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users