Sign in to follow this  
Followers 0
kalavo

Embedded IE - how do you activate arrow keys without left clicking?

10 posts in this topic

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:

; *******************************************************
; 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  

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try this:

; *******************************************************
; 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 by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My 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

 

Share this post


Link to post
Share on other sites

That's perfect. Thankyou MikahS. Much appreciated.

Cheers

Kalavo

Share this post


Link to post
Share on other sites

My pleasure. ;)


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My 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

 

Share this post


Link to post
Share on other sites

.... also another way

_IENavigate($oIE, "http://www.autoitscript.com")
Local $oDoc = _IEDocGetObj($oIE)
_IEAction($oDoc, "focus")

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
Share on other sites

#7 ·  Posted (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 by Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

Chimp, does this work for you on the 3.3.12.0/W7 x64?

_IELoadWait($oIE)
$oIE.document.parentwindow.focus()
1 person likes this

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.

Share this post


Link to post
Share on other sites

 

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


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0