Sign in to follow this  
Followers 0
NewPlaza

Check box status in htm file

6 posts in this topic

Hello,

I am very new at this and having problems checking the status of a checkbox in a test page.

My code is as followed.

#include <GUIConstants.au3>

#include <IE.au3>

_IEErrorHandlerRegister ()

$oIE = _IECreateEmbedded ()

GUICreate("Embedded Web control Test", 640, 580, _

(@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _

$WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 600, 360)

$GUI_Button_Finish = GUICtrlCreateButton("Finish", 230, 420, 100, 30)

GUISetState() ;Show GUI

_IENavigate ($oIE, "Example.htm")

; Waiting for user to close the window

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $GUI_Button_Finish

For $i = 1 to 5

If $oCheck.Checked Then

MsgBox(0, "Form Values", "Box " & $i & " is checked)

EndIf

EndSelect

WEnd

GUIDelete()

Exit

Any help would be very much appreciated.

Share this post


Link to post
Share on other sites



That demo script won't run. There is no Next to close the For loop, and the $oCheck element is not set before checking it. You also didn't provide Example.htm, and can't load it that way at any rate.

Try the example scripts under _IEFormElementCheckboxSelect().

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

My bad, I forgot the example.htm file

<HTML>
<HEAD>

<TITLE>Select a box</TITLE>
</HEAD>
<BODY>



<font face='Arial'>
<form name='ExampleForm' action='javascript:alert("ExampleForm Submitted");' method='post'>
<table border=1>


<tr><td><input type='checkbox' name='checkboxG1Example' value='gameBasketball'><img src="box1.ico" alt="" width="32" height="32"> Box 1</tr></td>
<tr><td><input type='checkbox' name='checkboxG1Example' value='gameBasketball'><img src="box2.ico" alt="" width="32" height="32"> Box 2</tr></td>
<tr><td><input type='checkbox' name='checkboxG1Example' value='gameBasketball'><img src="box3.ico" alt="" width="32" height="32"> Box 3</tr></td>
<tr><td><input type='checkbox' name='checkboxG1Example' value='gameBasketball'><img src="box4.ico" alt="" width="32" height="32"> Box 4</tr></td>
<tr><td><input type='checkbox' name='checkboxG1Example' value='gameBasketball'><img src="box5.ico" alt="" width="32" height="32"> Box 5</tr></td>


</table>
</form>
</font>
</BODY>
</HTML>

Yes, next wasnt there.. some how it didnt get copied. Heres the code.

It does load BUT it doesnt know which checkboxes are clicked after I hit the finish button.

#include <GUIConstants.au3>
#include <IE.au3>

_IEErrorHandlerRegister ()

$oIE = _IECreateEmbedded ()
GUICreate("Embedded Web control Test", 640, 580, _
        (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _
        $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 600, 360)
$GUI_Button_Finish = GUICtrlCreateButton("Finish", 230, 420, 100, 30)

GUISetState()       ;Show GUI

_IENavigate ($oIE, "D:\Example.htm")

; Waiting for user to close the window
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_Button_Finish
            For $i = 1 to 5
                If $oCheck.Checked Then
                    MsgBox(0, "Form Values", "Box " & $i & " is checked")
                EndIf               
            Next
            
    EndSelect
WEnd

GUIDelete()

Exit

Share this post


Link to post
Share on other sites

I don't understand why you are still posting code you never ran to test for yourself. You didn't include the WindowsConstants.au3 file, so your GUI styles fail (and aren't required anyway), and you still didn't declare or define where $oCheck came from. Just running syntax checker in SciTE would have gotten you that far.

For the sake of others who might be interested and want to actually put some effort into a similar script:

Test1.html:

<HTML>
    <HEAD>
        <TITLE>Select a box</TITLE>
    </HEAD>
    <BODY>
        <font face='Arial'>
        <form name='ExampleForm' action='javascript:alert("ExampleForm Submitted");' method='post'>
        <table border=1>
            <tr><td><input type='checkbox' name='checkboxG1Example' value='gameBasketball'><img src="box1.ico" alt="" width="32" height="32"> Checkbox 0</tr></td>
            <tr><td><input type='checkbox' name='checkboxG1Example' value='gameBasketball'><img src="box2.ico" alt="" width="32" height="32"> Checkbox 1</tr></td>
            <tr><td><input type='checkbox' name='checkboxG1Example' value='gameBasketball'><img src="box3.ico" alt="" width="32" height="32"> Checkbox 2</tr></td>
            <tr><td><input type='checkbox' name='checkboxG1Example' value='gameBasketball'><img src="box4.ico" alt="" width="32" height="32"> Checkbox 3</tr></td>
            <tr><td><input type='checkbox' name='checkboxG1Example' value='gameBasketball'><img src="box5.ico" alt="" width="32" height="32"> Checkbox 4</tr></td>
        </table>
        </form>
        </font>
    </BODY>
</HTML>

And Test1.au3:

#include <GUIConstants.au3>
#include <IE.au3>

_IEErrorHandlerRegister()

$oIE = _IECreateEmbedded()
GUICreate("Embedded Web control Test", 640, 580)
$GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 600, 360)
$GUI_Button_Finish = GUICtrlCreateButton("Finish", 230, 420, 100, 30)
GUISetState() ;Show GUI

_IENavigate($oIE, @ScriptDir & "\Test1.html")
$oForm = _IEFormGetObjByName($oIE, "ExampleForm")

; Waiting for user to close the window
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_Button_Finish
            For $i = 0 To 4
                If _IEFormElementCheckBoxSelect($oForm, $i, "CheckboxG1Example", -1, "ByIndex") Then
                    MsgBox(0, "Form Values", "Box " & $i & " is checked")
                EndIf
            Next
    EndSelect
WEnd

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

I do apologize for my ignorance and lack of programming/testing my code.

Thank you all for your help.

Share this post


Link to post
Share on other sites

The not testing was the only part that was a little annoying.

Just get in the habit of running Tidy (ctrl-t) and syntax checker (ctrl-F5) in SciTE on your code before posting. You'll find that's enough to diagnose a fair amount of your issues right there.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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