Jump to content

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


kalavo
 Share

Recommended Posts

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  

Link to comment
Share on other sites

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

 

Link to comment
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

 

Link to comment
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. 

Link to comment
Share on other sites

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

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

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

Link to comment
Share on other sites

  • Moderators

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

_IELoadWait($oIE)
$oIE.document.parentwindow.focus()

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

 

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

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...