MartinMerten Posted July 18, 2009 Share Posted July 18, 2009 (edited) Hi guys. I have a question regarding Internet Explorer and SendMessage/SendKey. Basically I created a gui with embedded internet explorer. ... $gui=GuiCreate($g_szVersion,@DesktopWidth-100,@DesktopHeight-100,-1,-1,$WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) $ie=_IECreateEmbedded() $ie_hwnd = GUICtrlGetHandle("[CLASS:Internet Explorer_Server; INSTANCE:1]") ;ConsoleWrite("_IEPropertySet silent: "&_IEPropertySet($ie,"silent",true)&@CRLF) ;ConsoleWrite("_IEPropertySet statusbar: "&_IEPropertySet($ie,"statusbar",true)&@CRLF) $ieActiveX=GUICtrlCreateObj($ie,0,0,@DesktopWidth-100,@DesktopHeight-100) _IENavigate ($ie,"about:blank") GUISetState(@SW_SHOW,$gui) ... I try to send keystrokes to it (f.ex. UP and DOWN for scrolling, STRG+/STRG- for zooming, ...), but whatever I try, I fail . I tried it with ControlSend, Send, _SendMessage. I just can't get it right. So, what can I do ? Thanks in advance . Edited July 18, 2009 by MartinMerten Link to comment Share on other sites More sharing options...
MartinMerten Posted July 19, 2009 Author Share Posted July 19, 2009 Hm. Too few information ? Do you need more ? Link to comment Share on other sites More sharing options...
MartinMerten Posted July 23, 2009 Author Share Posted July 23, 2009 Hm. Is no one able to help me ? BTW, I did search, but you find a gazillion number of threads about embedding Internet Explorer. Couldn't find the required information, though. Link to comment Share on other sites More sharing options...
MartinMerten Posted July 23, 2009 Author Share Posted July 23, 2009 Found an example in another thread, which I modified. Still no luck. What it should to: -open a gui -create embedded ie -load a page -send 10x the key {DOWN} to make IE scroll down in the thread #include <IE.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> _IEErrorHandlerRegister() $oIE = _IECreateEmbedded() $hGUI = GUICreate("myWindow", 800, 600, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 800, 600) GUISetState();Show GUI _IENavigate($oIE, "http://www.autoitscript.com/forum/index.php?showtopic=82184") $oSubmit = _IEGetObjByName ($oIE, "r_go") _IEAction ($oSubmit, "focus") for $i=1 to 10 ConsoleWrite("sending command:"&ControlSend($hGUI, "", $GUIActiveX, "{DOWN}")&@CRLF) sleep(1000) next The ControlSend doesn't work though, ControlSend returns a 0. Link to comment Share on other sites More sharing options...
DaleHohm Posted July 23, 2009 Share Posted July 23, 2009 Perhaps a method like this instead... http://www.autoitscript.com/forum/index.php?showtopic=88676&st=0&p=637240&hl=scrollto&fromsearch=1&#entry637240Dale 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...
trancexx Posted July 23, 2009 Share Posted July 23, 2009 There is one other option. The main problem is how to get control handle of the embedded object. You can do it like this: expandcollapse popup#include <IE.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> _IEErrorHandlerRegister() $oIE = _IECreateEmbedded() $hGUI = GUICreate("myWindow", 800, 600, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 800, 600) GUISetState();Show GUI _IENavigate($oIE, "http://www.autoitscript.com/forum/index.php?showtopic=82184") ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ; Get control handle Global $hHandle = _GetObjectWinHandle($oIE) ConsoleWrite("--- " & $hHandle & @CRLF) ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ; Focus it $oIE.document.focus For $i = 1 To 10 #cs $oIE.document.parentwindow.scrollBy(500, 500) ; DaleHohm's suggestion Sleep(1000) #ce ConsoleWrite("sending command:" & ControlSend($hHandle, 0, 0, "{DOWN}") & @CRLF) Sleep(1000) Next Func _GetObjectWinHandle($oObject) Local $aCall = DllCall("oleacc.dll", "int", "WindowFromAccessibleObject", _ "idispatch", $oObject, _ "hwnd*", 0) If @error Or $aCall[0] Then Return SetError(1, 0, 0) EndIf Return $aCall[2] EndFunc ;==>_GetObjectWinHandle SkysLastChance 1 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
MartinMerten Posted July 24, 2009 Author Share Posted July 24, 2009 (edited) Yay, this is working. At least trancexx's code, just tested it . But I will also take a look at the HTML DOM window object. Thanks alot guys . Edited July 24, 2009 by MartinMerten 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