Sign in to follow this  
Followers 0
Miguel

Input cursor not blinking after clicking Embedded IE

12 posts in this topic

#1 ·  Posted (edited)

Hi there,

Need help with this strange situation.

If i click in the embedded ie control and after click in the input control, the cursor doesnt blinks in the input control.

If i minimize and restore the window, the cursor blinks.

Does anyone has a suggestions to fix this?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>

Local $oIE = _IECreateEmbedded()
GUICreate("Embedded IE + Input", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
GUICtrlCreateObj($oIE, 10, 100, 600, 360)
$Input1 = GUICtrlCreateInput("", 10, 30, 100, 25)
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
EndSelect
WEnd
GUIDelete()
Exit
Edited by Miguel

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try this:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>

Local $oIE = _IECreateEmbedded()
GUICreate("Embedded IE + Input", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
GUICtrlCreateObj($oIE, 10, 100, 600, 360)
$Input1 = GUICtrlCreateInput("", 10, 30, 100, 25)
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= $Input1
   send("{TAB}")
EndSelect
WEnd
GUIDelete()
Exit
Edited by Aipion

Share this post


Link to post
Share on other sites

Aipion,

Thanks for your help, but that didn´t fixed the problem.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Aipion,

Thanks for your help, but that didn´t fixed the problem.

My bad it needs two sand functions. try and see, it worked for me.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>

Local $oIE = _IECreateEmbedded()
GUICreate("Embedded IE + Input", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
$OID = GUICtrlCreateObj($oIE, 10, 100, 600, 360)
$Input1 = GUICtrlCreateInput("", 10, 30, 100, 25)
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= $Input1
   GUICtrlSetState($Input1,$GUI_FOCUS)
   send("{TAB}")
   send("{TAB}")
EndSelect
WEnd
GUIDelete()
Exit
Edited by Aipion

Share this post


Link to post
Share on other sites

Still doesnt work for me.

Share this post


Link to post
Share on other sites

This should work, put any new control in the gui2.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
Local $oIE = _IECreateEmbedded()
$gui1 = GUICreate("Embedded IE + Input", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
$OID = GUICtrlCreateObj($oIE, 10, 100, 600, 360)
$gui2 = GUICreate("",640,580,0,0,$WS_CHILD,-1,$gui1)
$Input1 = GUICtrlCreateInput("", 10, 30, 100, 25)
$button1 = GUICtrlCreateButton("Go",120,30,50,25)
GUISetState(@SW_SHOW,$gui2) ;Show GUI
GUISetState(@SW_SHOW,$gui1) ;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 = $button1
   If GUICtrlRead($Input1) <> "" Then
   _IENavigate($oIE, GUICtrlRead($Input1))
   EndIf
  
EndSelect
WEnd
GUIDelete()
Exit

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I'd suggest that you look in my sig for an alternative to the embedded IE. There are long-standing issues with the embedded GUI Obj control and keyboard focus and the method used offers an alternative.

Dale

Edited by DaleHohm

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

Share this post


Link to post
Share on other sites

Thanks Dale,

The alternative approach to Embedd IE solved the not blinking cursor issue.

But now i have another problem.... The script exits as soon as enters the While loop. GUIGetMsg() retrieves $GUI_EVENT_CLOSE

My script below.

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <Constants.au3>
#include <IE.au3>
local $pid, $hHandle, $hGUI, $sURL, $xHeight, $xWidth
$sURL = "about:blank"
$xWidth = 640
$xHeight = 580
$hGUI = GUICreate("Embedded IE + Input", $xWidth, $xHeight, -1, -1, BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SIZEBOX))
$oIE = _IECreateEmbed2($xWidth-50, $xHeight-20, 10, 40, $hGUI)
$Input1 = GUICtrlCreateInput("", 10, 10, 100, 25)
GUISetState() ;Show GUI
_IENavigate($oIE, "http://www.autoitscript.com")
; Waiting for user to close the window
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $nMsg = $GUI_EVENT_CLOSE
   ConsoleWrite("close?"&@lf)
   ;ExitLoop
   Case $GUI_EVENT_RESIZED, $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE
            $newSize = WinGetClientSize($hGUI)
            _WinAPI_MoveWindow($hHandle, 10, 40, $newSize[0]-50, $newSize[1]-20, True)
EndSwitch
WEnd
_IEQuit($oIE)
Exit

Func _IECreateEmbed2($xWidth, $xHeight, $iX, $iY, $hGUI)
    $pID = Run(@ProgramFilesDir & "internet exploreriexplore.exe -k " & $sURL, "", @SW_HIDE)
    Do
        Sleep(100)
    Until Not (ProcessExists($pID) = 0)
    $hHandle = _ProcessGetHWnd($pID)
    Do
        $oIElocal = _IEAttach($hHandle, "HWND")
        Sleep(100)
    Until $oIElocal <> 0
    GUISetState(@SW_SHOW, $hGUI)
    _WinAPI_SetParent($hHandle, $hGUI)
    _WinAPI_MoveWindow($hHandle, $iX, $iY, $xWidth, $xHeight, True)
    _WinAPI_SetWindowLong($hHandle, $GWL_STYLE, BitOR($WS_CHILD, $WS_VISIBLE))
    Return $oIElocal
EndFunc   ;==>_IECreate2
Func _ProcessGetHWnd($iPid, $sTitle = "")
    Local $aWin
    While 1
        $aWin = WinList($sTitle)
        For $i = 1 To $aWin[0][0]
            If $iPid = WinGetProcess($aWin[$i][1]) Then
                Return $aWin[$i][1]
            EndIf
        Next
        Sleep(500) ; add a timer here
    WEnd
    SetError(1)
    Return 0
EndFunc   ;==>_ProcessGetHWnd

Share this post


Link to post
Share on other sites

Your mistake is at :

Case $nMsg = $GUI_EVENT_CLOSE

The loop layout should be like below:

While 1
   Switch GUIGetMsg()
   Case $GUI_EVENT_CLOSE
   ConsoleWrite("close?"&@lf)
   ;ExitLoop
   Case $GUI_EVENT_RESIZED, $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE
   $newSize = WinGetClientSize($hGUI)
   _WinAPI_MoveWindow($hHandle, 10, 40, $newSize[0]-50, $newSize[1]-20, True)
   EndSwitch
WEnd

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Thanks Albion.

Now i´ve realised that was a amateur question.... I´ve adapted the loop from "Select...Case...EndSelect" to "Switch...Case...EndSwitch" ... but forgotten to change this "Case $nMsg= $GUI_EVENT_CLOSE" to this "Case $GUI_EVENT_CLOSE"

Now it works.

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   ConsoleWrite("close?"&@lf)
   ;ExitLoop
   Case $GUI_EVENT_RESIZED, $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE
            $newSize = WinGetClientSize($hGUI)
            _WinAPI_MoveWindow($hHandle, 10, 40, $newSize[0]-50, $newSize[1]-20, True)
EndSwitch
WEnd
Edited by Miguel

Share this post


Link to post
Share on other sites

I have this exact issue. Using Dale's method does work, however it creates 2 iexplore processes, which I would like to avoid.

I believe it to be an issue with guictrlcreateobj I am not using ie.au3 to create the embedded IE window..

So has anyone else seen this? I believe it to be a bug..

Thanks

Share this post


Link to post
Share on other sites

Just tested with guirichedit and it did not experience the same issue.. I could use richedit, but I would prefer to use edit.. less coding. :)

any ideas?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <GuiRichEdit.au3>
Local $oIE = _IECreateEmbedded()
$hgui = GUICreate("Embedded IE + Input", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
$OID = GUICtrlCreateObj($oIE, 10, 100, 600, 360)
$Input1 = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300,25,BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
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= $Input1
   GUICtrlSetState($Input1,$GUI_FOCUS)
   send("{TAB}")
   send("{TAB}")
EndSelect
WEnd
GUIDelete()
Exit

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