Sign in to follow this  
Followers 0
chenxu

embbeded web browser into AuToIt GUI

9 posts in this topic

I created a browser embedded into an AutoIt GUI, the code is shown as following:

CODE
_IEErrorHandlerRegister ()

$oIE = _IECreateEmbedded ()

$guiHandle = GUICreate("MyGUI", 640, 480, 1, 1, _

$WS_CAPTION + $WS_SYSMENU + $WS_MINIMIZEBOX + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 640, 480)

_IENavigate ($oIE, "http://nj.atm.zte.com.cn")

_IELoadWait ($oIE)

GUISetState()

and then, I will do some action in the browser I created including submitting a form to the server. And after clicking the submit button which is performed by _IEAction($oSubmit, "click"), there would be a dialog box pops up, telling me that the form is succefully submitted or error data submitted. It is easy to kown whether I succefully submitted by finding out what the dialog box says.

Here is the problem, the pop up dialog box seems to be part of my GUI, and as soon as it appears, the macro will pause until someone clicks the OK button. I can NOT perform a click command in the same macro. How can I solve this problem? Thanks very much~!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I created a browser embedded into an AutoIt GUI, the code is shown as following:

CODE
_IEErrorHandlerRegister ()

$oIE = _IECreateEmbedded ()

$guiHandle = GUICreate("MyGUI", 640, 480, 1, 1, _

$WS_CAPTION + $WS_SYSMENU + $WS_MINIMIZEBOX + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 640, 480)

_IENavigate ($oIE, "http://nj.atm.zte.com.cn")

_IELoadWait ($oIE)

GUISetState()

and then, I will do some action in the browser I created including submitting a form to the server. And after clicking the submit button which is performed by _IEAction($oSubmit, "click"), there would be a dialog box pops up, telling me that the form is succefully submitted or error data submitted. It is easy to kown whether I succefully submitted by finding out what the dialog box says.

Here is the problem, the pop up dialog box seems to be part of my GUI, and as soon as it appears, the macro will pause until someone clicks the OK button. I can NOT perform a click command in the same macro. How can I solve this problem? Thanks very much~!

"Take a look at the helpfile for _IEAction in the beta 3.2.5.4 or higher. Example 2 shows you how to avoid this."

Edited by Generator

Share this post


Link to post
Share on other sites

Thanks after all

I read the example a day or two ago, I found that the example you mensioned is do help if I navigate the page in a default web browser like IE or Maxthon, but it does not help in case that I've met here.

I've tried some different methods to do this, but it's a pity that I can not solve the problem by just in the macro. The other hand, I wrote simple macro to detect that the dialog box appears, and send an ENTER to it. I think this method is not very good and I believe that there should be a better method to do this.

any advice is appreciated, thank for helping

Share this post


Link to post
Share on other sites

Please explain why the example will not work in your situation.

Dale


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

Please explain why the example will not work in your situation.

Dale

To make it simple, I omit the former code which gets the form object, the submitting button object, and just start as following:

CODE

_IEAction ($oSubmit, "focus")

ControlSend($guiHandle, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")

the ControlSend function will send an ENTER to the focused submit button, and then, a dialog box will appear.

I tried to output some message to console with the function ConsoleWrite to make sure that the macro is running forward, like:

CODE

_IEAction ($oSubmit, "focus")

ControlSend($guiHandle, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")

ConsoleWrite ("running1")

ConsoleWrite ("running2")

ConsoleWrite ("running3")

ConsoleWrite ("running4")

ConsoleWrite ("running5")

ConsoleWrite ("running6")

sleep(500)

ConsoleWrite ("running7")

ConsoleWrite ("running8")

and I look in the messages typed out in the console, it is:

"running1running2running3running4running5running6"

and the message after sleep function do not appear. So, I kown that the macro is actually running before the dialog box appears, and as soon as the dialog box appears, the macro will stop and just wait for somebody to send a enter or click action to it.

This is a fatal error in my macro, my progress is greatly delayed by this error, I hope anybody please help me or give me some message or advice. Thanks very very very much

Share this post


Link to post
Share on other sites

I have to believe there is more to this scenario than what you have shared. I see nothing that would hang your script based on what you have posted.

Dale


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

I have to believe there is more to this scenario than what you have shared. I see nothing that would hang your script based on what you have posted.

Dale

Thanks a lot for your attention! I put the entire code here. you can look in the function: CheckNow which will invoke the functions setLayout(), login(), putValidateCode(), and the first two function works fine, the error happens in the function putValidateCode(), again, thanks for your time for helping me, the newbie :)

CODE

Func putValidateCode()

$oForm = _IEFormGetObjByName ($oIE, "RemedyFormEplyApy")

If @error == 3 Then

logger(10011)

SetError(10011)

Return

ElseIf @error == 7 Then

logger(10012)

SetError(10012)

Return

EndIf

$oText = _IEFormElementGetObjByName ($oForm, "txtpas")

If @error == 3 Then

logger(10013)

SetError(10013)

Return

ElseIf @error == 4 Then

logger(10014)

SetError(10014)

Return

ElseIf @error == 7 Then

logger(10015)

SetError(10015)

Return

EndIf

$code = getValidateCode()

If @error Then

logger(10016)

SetError(10016)

Return

EndIf

; _IEFormElementSetValue ($oText, $code)

_IEFormElementSetValue ($oText, $code & "1")

If @error == 3 Then

logger(10017)

SetError(10017)

Return

ElseIf @error == 7 Then

logger(10018)

SetError(10018)

Return

EndIf

$oSubmit = _IEGetObjByName ($oIE, "btnSubmit")

If @error == 7 Then

logger(10019)

SetError(10019)

Return

EndIf

_IEAction ($oSubmit, "focus")

Send("{enter}")

ConsoleWrite("submitted")

ConsoleWrite("done")

ConsoleWrite("1")

ConsoleWrite("2")

ConsoleWrite("3")

ConsoleWrite("4")

Sleep(500)

;Send("{enter}")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;

;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

#cs

ControlSend($guiHandle, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")

Sleep(1000)

If WinExists("Microsoft Internet Explorer", "请输入有效的验证码") Then

TrayTip("debug", "请输入有效的验证码", 20)

ControlClick("Microsoft Internet Explorer", "请输入有效的验证码", "[CLASS:Button; TEXT:确定; Instance:1;]")

logger(10020)

SetError(10020)

Return

EndIf

If WinExists("Microsoft Internet Explorer", "网上刷卡成功") Then

TrayTip("debug", "网上刷卡成功", 20)

ControlClick("Microsoft Internet Explorer", "网上刷卡成功", "[CLASS:Button; TEXT:确定; Instance:1;]")

SetError(0)

Return

EndIf

ControlClick("Microsoft Internet Explorer", "请输入有效的验证码", 2)

;Send("{ENTER}")

$sum1 = PixelChecksum(476, 365, 591, 376)

$sum2 = PixelChecksum(59, 45, 174, 56)

MouseMove(476, 365)

MsgBox(0,"debug", "sum1=" & $sum1 & ", sum2=" & $sum2)

#ce

EndFunc

Share this post


Link to post
Share on other sites

If you can give me a clean example I'll take a look, The code you posted gives the warnings and errors below.

Also, adding the following line at the top of your script will output lines of code as they execute to the SciTe console:

#AutoIt3Wrapper_run_debug_mode=Y

Dale

+>08:52:14 Starting AutoIt3Wrapper v.1.9.2
>Running AU3Check (1.54.9.0)  from:C:\Program Files\AutoIt3\beta
C:\Documents and Settings\hohm\My Documents\My Downloads\AutoCheckingDaemon.au3(19,17) : WARNING: $interval: possibly used before declaration.
    Sleep($interval)
    ~~~~~~~~~~~~~~~^
C:\Documents and Settings\hohm\My Documents\My Downloads\AutoCheckingDaemon.au3(20,25) : WARNING: $begin: possibly used before declaration.
    $dif = TimerDiff($begin)
    ~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\hohm\My Documents\My Downloads\AutoCheckingDaemon.au3(23,33) : WARNING: $totalTimeRan: possibly used before declaration.
        $totalTimeRan = $totalTimeRan +
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\hohm\My Documents\My Downloads\AutoCheckingDaemon.au3(61,34) : WARNING: $APP_NAME: possibly used before declaration.
    $guiHandle = GUICreate($APP_NAME,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\hohm\My Documents\My Downloads\AutoCheckingDaemon.au3(305,24) : WARNING: $logFile: possibly used before declaration.
    _FileWriteLog($logFile,
    ~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\hohm\My Documents\My Downloads\AutoCheckingDaemon.au3(313,19) : WARNING: $regBase: possibly used before declaration.
    RegWrite($regBase,
    ~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\hohm\My Documents\My Downloads\AutoCheckingDaemon.au3(326,36) : WARNING: $oIE: possibly used before declaration.
    $oForm = _IEFormGetObjByName ($oIE,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\hohm\My Documents\My Downloads\AutoCheckingDaemon.au3(338,37) : WARNING: $id: possibly used before declaration.
    _IEFormElementSetValue ($oText, $id)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\hohm\My Documents\My Downloads\AutoCheckingDaemon.au3(340,37) : WARNING: $pwd: possibly used before declaration.
    _IEFormElementSetValue ($oPwd, $pwd)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\hohm\My Documents\My Downloads\AutoCheckingDaemon.au3(490,19) : WARNING: $jdkPath: possibly used before declaration.
    RunWait($jdkPath &
    ~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\hohm\My Documents\My Downloads\AutoCheckingDaemon.au3(525,26) : WARNING: $titleBarOffset: possibly used before declaration.
    $picY = $titleBarOffset +
    ~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\hohm\My Documents\My Downloads\AutoCheckingDaemon.au3(568,42) : WARNING: $timer possibly not declared/created yet
            $timer[$i][0][0] = StringLeft($var, 2)
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\hohm\My Documents\My Downloads\AutoCheckingDaemon.au3(614,14) : WARNING: $monitor: possibly used before declaration.
    If $monitor ==
    ~~~~~~~~~~~~^
C:\Documents and Settings\hohm\My Documents\My Downloads\AutoCheckingDaemon.au3(614,39) : WARNING: $MON_STATUS_EXECUTING: possibly used before declaration.
    If $monitor == $MON_STATUS_EXECUTING And
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\hohm\My Documents\My Downloads\AutoCheckingDaemon.au3(614,57) : WARNING: $monitorCount: possibly used before declaration.
    If $monitor == $MON_STATUS_EXECUTING And $monitorCount <
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\hohm\My Documents\My Downloads\AutoCheckingDaemon.au3(621,39) : WARNING: $MON_STATUS_RETIED_DONE: possibly used before declaration.
        monitorClose($MON_STATUS_RETIED_DONE)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\hohm\My Documents\My Downloads\AutoCheckingDaemon.au3(628,39) : WARNING: $curTask: possibly used before declaration.
        failureNotice("ÈÎÎñ£º¡¾" & $curTask &
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\hohm\My Documents\My Downloads\AutoCheckingDaemon.au3(629,42) : WARNING: $MON_STATUS_RETRIED_FAILED: possibly used before declaration.
        monitorClose($MON_STATUS_RETRIED_FAILED)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\hohm\My Documents\My Downloads\AutoCheckingDaemon.au3(633,29) : WARNING: $timer: possibly used before declaration.
    If $timer[@WDAY - 2][0][0] ==
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\hohm\My Documents\My Downloads\AutoCheckingDaemon.au3(644,32) : WARNING: $MON_STATUS_DONE: possibly used before declaration.
        monitorClose($MON_STATUS_DONE)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\hohm\My Documents\My Downloads\AutoCheckingDaemon.au3(665,48) : ERROR: syntax error
    $curTaskDetailInfo = @YEAR & "-" & @MON & "-" @MDAY
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\hohm\My Documents\My Downloads\AutoCheckingDaemon.au3(674,37) : WARNING: $MON_STATUS_RETRIED_DONE: possibly used before declaration.
        $flag <> $MON_STATUS_RETRIED_DONE And
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\hohm\My Documents\My Downloads\AutoCheckingDaemon.au3(676,31) : WARNING: $MON_STATUS_UNKOWN: possibly used before declaration.
        $flag <> $MON_STATUS_UNKOWN Then
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\hohm\My Documents\My Downloads\AutoCheckingDaemon.au3(792,62) : WARNING: $curTaskDetailInfo: possibly used before declaration.
    MsgBox(64, $APP_NAME, "ÉÏÒ»´ÎÈÎÎñÊÇ£º" & $curTaskDetailInfo &
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\hohm\My Documents\My Downloads\AutoCheckingDaemon.au3(164,29) : WARNING: $logFile: declared global in function only. Prefer top of file.
    Global $logFile = "log.txt"
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\hohm\My Documents\My Downloads\AutoCheckingDaemon.au3 - 1 error(s), 24 warning(s)

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

If you can give me a clean example I'll take a look, The code you posted gives the warnings and errors below.

yes, this is the example you can look at, I wrote it last night(in my timezone :) ), this is the same as my problem, the URL is

http://www.autoitscript.com/forum/index.php?showtopic=51798

BTW, I tried to get the IE object by using _IECreate(), and use the same code given in the example, and it works fine. Once I create the IE object in a embedded activeX object of AutoIt GUI, it doesn't work. I am thinking that is this bug of the IE.au3?

again, thanks for your time

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