darkyr Posted October 20, 2011 Posted October 20, 2011 $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?
rcmaehl Posted October 20, 2011 Posted October 20, 2011 $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 1 My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated. My Projects WhyNotWin11, MSEdgeRedirect Cisco Finesse, Github, IRC UDF, WindowEx UDF
darkyr Posted October 20, 2011 Author Posted October 20, 2011 still didn't work and C:\Autoexec.bat was from an example i found in the forums, thanks for replying
rcmaehl Posted October 20, 2011 Posted October 20, 2011 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 1 My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated. My Projects WhyNotWin11, MSEdgeRedirect Cisco Finesse, Github, IRC UDF, WindowEx UDF
darkyr Posted October 20, 2011 Author Posted October 20, 2011 (edited) 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 October 20, 2011 by darkyr
darkyr Posted October 20, 2011 Author Posted October 20, 2011 (edited) 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 October 20, 2011 by darkyr
DelStone Posted March 6, 2012 Posted March 6, 2012 I too would be interested in knowing why this is the case...
DaleHohm Posted March 6, 2012 Posted March 6, 2012 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 1 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
DelStone Posted March 7, 2012 Posted March 7, 2012 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?
DaleHohm Posted March 7, 2012 Posted March 7, 2012 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 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
DelStone Posted March 7, 2012 Posted March 7, 2012 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...
DaleHohm Posted March 8, 2012 Posted March 8, 2012 My sig contains two examples. Look at them. 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
DelStone Posted March 8, 2012 Posted March 8, 2012 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?
DelStone Posted March 23, 2012 Posted March 23, 2012 (edited) 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 March 23, 2012 by DelStone
DaleHohm Posted March 23, 2012 Posted March 23, 2012 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 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 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now