dv8 Posted September 28, 2009 Share Posted September 28, 2009 (edited) Like this: #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") ControlSend($hChoose, "", "Edit1", "C:\AUTOEXEC.BAT") ControlClick($hChoose, "", "Button2") Dale This is a great example, but unfortunately it does not work for embedded IE. Any idea how I can make this work: #include <IE.au3> $MyIE=GUICreate("Test Input File",800,600,-1,-1) $oIE=ObjCreate("Shell.Explorer.2") $GUIActiveX=GUICtrlCreateObj($oIE,5,5,790,590) GUISetState() _IENavigate($oIE,"http://vnccontrol.hit.bg/FileTest.html") $oT = _IEGetObjById($oIE, 'File1') MouseMove(_IEPropertyGet($oT, "screenx") + _IEPropertyGet($oT, "width") - 10, _IEPropertyGet($oT, "screeny") + _IEPropertyGet($oT, "height")/2) MouseClick("left") WinWait("Choose") MsgBox(64,"","") $hChoose = WinGetHandle("Choose File to Upload") ControlSend($hChoose, "", "Edit1", "C:\AUTOEXEC.BAT") MsgBox(64,"Success","Success!") ??? Edited September 28, 2009 by dv8 Free Remote Desktop Software For Windows Link to comment Share on other sites More sharing options...
DaleHohm Posted September 29, 2009 Share Posted September 29, 2009 I have been finding that the GuiCtrlCreateObj has many issues with IE. I now believe that the method of displaying a full IE in kiosk mode inside an AutoIt GUI is much more reliable. Please search the forum for _IECreate2 and use that method - I expect it to be flawless. 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 More sharing options...
dv8 Posted September 29, 2009 Share Posted September 29, 2009 I have been finding that the GuiCtrlCreateObj has many issues with IE. I now believe that the method of displaying a full IE in kiosk mode inside an AutoIt GUI is much more reliable. Please search the forum for _IECreate2 and use that method - I expect it to be flawless. Dale THANK YOU DALE!!! Using this method I managed to do what I wanted, but it's not exactly flawless. I Had some problems attaching by HWND but they disappeared after a restart (as someone suggested here in the forum). The big issue I have now is to resize the kiosk window along with the GUI. In the example below the GUI is resizable, but the IE window stays the same size. I couldn't find a way to do that. Another issue I have is, if the script crashes for some reason and exits unexpectedly, the IE process stays active and invisible. After many tests and failures I've noticed I had more than a dozen active iexplere.exe processes in the Task Manager. Also couldn't figure out a way to prevent this. Any suggestions are welcome! Thanks again Dale! You are a lifesaver! Here is the script: expandcollapse popup#Include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #Include <Constants.au3> #Include <IE.au3> $xWidth = 800 $xHeight = 600 $hGUI = GUICreate("Test",$xWidth,$xHeight,-1,-1,BitOr($WS_SIZEBOX,$WS_MINIMIZEBOX,$WS_CAPTION,$WS_POPUP,$WS_MAXIMIZEBOX)) ;$oIE=_IECreate2($xWidth,$xHeight,$hGUI,"about:blank1") $oIE=_IECreate2($xWidth,$xHeight,$hGUI,"about:blank") _IENavigate($oIE,"http://vnccontrol.hit.bg/FileTest.html") $oT = _IEGetObjById($oIE,'File1') MouseMove(_IEPropertyGet($oT,"screenx") + _IEPropertyGet($oT,"width") - 10,_IEPropertyGet($oT,"screeny") + _IEPropertyGet($oT,"height")/2,0) MouseClick("left") WinWait("Choose") $hChoose = WinGetHandle("Choose File to Upload") ControlSetText($hChoose,"","Edit1","C:\test_file.txt") While 1 $MSG=GUIGetMsg() Switch $MSG Case $GUI_EVENT_CLOSE ProcessClose($ExplorerPID) Exit EndSwitch Wend Func _IECreate2($xWidth,$xHeight,$hGUI,$sURL) GLOBAL $ExplorerPID = Run(@ProgramFilesDir & "\internet explorer\iexplore.exe -k " & $sURL,"",@SW_HIDE) Sleep(2000) $hHandle = _ProcessGetHWnd($ExplorerPID) $o_ie=_IEAttach($hHandle,"HWND") If $o_ie=0 Then $o_ie=_IEAttach($sURL,"URL") If $o_ie=0 Then MsgBox(64,"_IECreate2","Error: "&@ERROR) MyExit() EndIf EndIf GUISetState(@SW_SHOW,$hGUI) _WinAPI_SetParent($hHandle,$hGUI) _WinAPI_MoveWindow($hHandle,5,5,$xWidth-10,$xHeight-10,True) _WinAPI_SetWindowLong($hHandle,$GWL_STYLE,$WS_POPUP + $WS_VISIBLE) _IEAction($o_ie,"refresh") Return $o_ie EndFunc Func _ProcessGetHWnd($iPid,$iOption = 1,$sTitle = "",$iTimeout = 2000) Local $aReturn[1][1] = [[0]],$aWin,$hTimer=TimerInit() While 1 $aWin=WinList($sTitle) For $i=1 To $aWin[0][0] If $iPid=WinGetProcess($aWin[$i][1]) Then If $iOption=1 Or ($iOption=0 And $aWin[$i][0] <> "") Then Return $aWin[$i][1] ElseIf $iOption=2 Then ReDim $aReturn[UBound($aReturn) + 1][2] $aReturn[0][0] += 1 $aReturn[$aReturn[0][0]][0]=$aWin[$i][0] $aReturn[$aReturn[0][0]][1]=$aWin[$i][1] EndIf EndIf Next If $iOption=2 And $aReturn[0][0] > 0 Then Return $aReturn If TimerDiff($hTimer) > $iTimeout Then ExitLoop Sleep(Opt("WinWaitDelay")) WEnd SetError(1) Return 0 EndFunc ;==>_ProcessGetHWnd Free Remote Desktop Software For Windows Link to comment Share on other sites More sharing options...
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