kalavo Posted November 21, 2014 Share Posted November 21, 2014 If I run the example code for _IECreateEmbedded it is always necessary for me to navigate my cursor to the ie page and left click on it before I can use the arrow keys to scroll around the embedded page. On the project I'm working on, the user will not have access to a mouse (just a limited number of keys including the arrows). How do I activate the arrows via a function call?. I feel I have tried just about everything but nothing works. Obviously, I could call Mousemove() and then MouseClick("left") but I feel there must be a more elegant solution. I'm on v3.3.8.1 Here's the example code: expandcollapse popup; ******************************************************* ; Example 1 - Trap COM errors so that 'Back' and 'Forward' ; outside of history bounds does not abort script ; (expect COM errors to be sent to the console) ; ******************************************************* #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> _IEErrorHandlerRegister() Local $oIE = _IECreateEmbedded() GUICreate("Embedded Web control Test", 640, 580, _ (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) GUICtrlCreateObj($oIE, 10, 40, 600, 360) Local $GUI_Button_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30) Local $GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30) Local $GUI_Button_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30) Local $GUI_Button_Stop = GUICtrlCreateButton("Stop", 340, 420, 100, 30) GUISetState() ;Show GUI _IENavigate($oIE, "http://www.autoitscript.com") ; Waiting for user to close the window While 1 Local $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $GUI_Button_Home _IENavigate($oIE, "http://www.autoitscript.com") Case $msg = $GUI_Button_Back _IEAction($oIE, "back") Case $msg = $GUI_Button_Forward _IEAction($oIE, "forward") Case $msg = $GUI_Button_Stop _IEAction($oIE, "stop") EndSelect WEnd GUIDelete() Exit Please note, my gui wont have any buttons or anything, I'm just using the above code to demonstrate the problem. Cheers Kalavo Link to comment Share on other sites More sharing options...
MikahS Posted November 21, 2014 Share Posted November 21, 2014 (edited) Try this: expandcollapse popup; ******************************************************* ; Example 1 - Trap COM errors so that 'Back' and 'Forward' ; outside of history bounds does not abort script ; (expect COM errors to be sent to the console) ; ******************************************************* #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> _IEErrorHandlerRegister() Local $oIE = _IECreateEmbedded() Local $GUI = GUICreate("Embedded Web control Test", 640, 580, _ (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) GUICtrlCreateObj($oIE, 10, 40, 600, 360) Local $GUI_Button_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30) Local $GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30) Local $GUI_Button_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30) Local $GUI_Button_Stop = GUICtrlCreateButton("Stop", 340, 420, 100, 30) GUISetState() ;Show GUI _IENavigate($oIE, "http://www.autoitscript.com") ControlFocus("", "", "[CLASS:Internet Explorer_Server]") ; <<<<<<<<<<<<<< this will give the embed IE window focus ; Waiting for user to close the window While 1 Local $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $GUI_Button_Home _IENavigate($oIE, "http://www.autoitscript.com") Case $msg = $GUI_Button_Back _IEAction($oIE, "back") Case $msg = $GUI_Button_Forward _IEAction($oIE, "forward") Case $msg = $GUI_Button_Stop _IEAction($oIE, "stop") EndSelect WEnd GUIDelete() Exit Edited November 21, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
kalavo Posted November 21, 2014 Author Share Posted November 21, 2014 That's perfect. Thankyou MikahS. Much appreciated. Cheers Kalavo Link to comment Share on other sites More sharing options...
MikahS Posted November 21, 2014 Share Posted November 21, 2014 My pleasure. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
Gianni Posted November 21, 2014 Share Posted November 21, 2014 .... also another way _IENavigate($oIE, "http://www.autoitscript.com") Local $oDoc = _IEDocGetObj($oIE) _IEAction($oDoc, "focus") Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
kalavo Posted November 21, 2014 Author Share Posted November 21, 2014 Sorry Chimp that doesn't appear to work for me. I don't really understand it. Some things that I would expect to work, don't. But then again, I only have a small brain. For example I did try Controlfocus before raising the topic as follows: $id = GUICtrlCreateObj($oIE, 10, 40, 600, 360) ; ...other code ControlFocus("", "", $id) That didn't work. However, specifying the CLASS (as suggested by MikahS) rather than the controlID works fine. Link to comment Share on other sites More sharing options...
Gianni Posted November 21, 2014 Share Posted November 21, 2014 (edited) about above code from post #5: on a pc with IE10 AutoIt 3.3.8.1 win7-64 it works for me, on another pc with IE9 AutoIt 3.3.12.0 win7-64 it doesn't work..... sorry edit from post #5 not post #6 Edited November 21, 2014 by Chimp Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 21, 2014 Moderators Share Posted November 21, 2014 Chimp, does this work for you on the 3.3.12.0/W7 x64? _IELoadWait($oIE) $oIE.document.parentwindow.focus() MikahS 1 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Gianni Posted November 21, 2014 Share Posted November 21, 2014 Chimp, does this work for you on the 3.3.12.0/W7 x64? _IELoadWait($oIE) $oIE.document.parentwindow.focus() the $oIE.document.parentwindow.focus() method works on both of above systems .... nice Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
kalavo Posted November 21, 2014 Author Share Posted November 21, 2014 Chimp, I was running your code via the SciTE editor. It works if I compile it x86 or X64 on Win7 / IE11 / v3.3.8.1. $oIE.document.parentwindow.focus() works regardless of how I run/compile it. 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