Jump to content

[RESOLVED] Find Internet Explorer security radio button state


dickep
 Share

Recommended Posts

I have searched here and cannot find what I think it the answer.

I have to do an application that reads the tree in the internet explorer security options settings (Internet Explorer -> Tools menu -> Internet Options -> Security tab -> Custom level and read out of the Settings window). Now, while I can get the stuff (all the text that is), I can't figure out how to get the state of each item that has a radio button.

I know, I need code to be here - well, I thing I don't need it since this is just one part, but let me know.

Thanks in advance.

Edited by dickep
Link to comment
Share on other sites

I have searched here and cannot find what I think it the answer.

I have to do an application that reads the tree in the internet explorer security options settings (Internet Explorer -> Tools menu -> Internet Options -> Security tab -> Custom level and read out of the Settings window). Now, while I can get the stuff (all the text that is), I can't figure out how to get the state of each item that has a radio button.

I know, I need code to be here - well, I thing I don't need it since this is just one part, but let me know.

Thanks in advance.

Have you tried with _GUICtrlButton_GetCheck?

Link to comment
Share on other sites

Yes, in fact, I am putting my code here for all to see (and critique - I can take it). The message box says all the buttons are cleared (same as 0) so...... need some directions/help.

#include <GuiButton.au3>
#include <GUIConstants.au3>
#include <GUITab.au3>
#include <GuiTreeView.au3>
#include <WindowsConstants.au3>

#include <Array.au3>
Opt("WinTitleMatchMode", 2)

Dim $sTitle = "Internet Options"
Dim $tSecurity = "Security"

If WinExists("Internet Explorer") Then
    ; window already open, do't do anything
    ;   but go to end of IF stuff
    MsgBox(0, "", "Found the window")
Else
    ; need to open the window
    ; first open IE
    Run("iexplore.exe")
    WinWait("Internet Explorer", 45)
    WinActivate("Internet Explorer")
    Send("^t")

EndIf

WinActivate("Internet Explorer")
sleep(2000) ; wait 2 seconds

Send("{ALT}t")
sleep(250)
send("o")
; now find the tab Security

$hWnd = WinGetHandle("[CLASS:#32770; TITLE:Internet Options]")
sleep (100)
WinActivate($hWnd)
sleep (100)
$hTab = ControlGetHandle($hWnd, "", "SysTabControl321")
$TabID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hTab)
$TabID = $TabID[0]
_ArrayDisplay($TabID)
$tCount = _GUICtrlTab_GetItemCount($hTab) ; get the number of tabs in window
; now find Security tab and click on it
$x = 0
$bFound = False
#cs
MsgBox(0,"","Security tab found at index: " & _GUICtrlTab_FindTab($hTab, "Security"))
while not $bFound and $x <= $tCount
    _GUICtrlTab_SetCurFocus($hTab, $x)
    _GUICtrlTab_SetCurSel($hTab, $x)
    msgbox(0,""," Tab " & $x & " of " & $tCount & " Tabs found" & @CRLF & "Tab name: " & _GUICtrlTab_GetItemtext($hTab,$x))
;   msgbox(0,""," Tab " & $x & " of " & $tCount & " Tabs found" & @CRLF & "Tab name: " & _GUICtrlTab_GetCurSel($hTab))
;   if _GUICtrlTab_GetItemText($hTab,$x) = $tSecurity Then
;       _GUICtrlTab_SetCurFocus($hTab, $x)
;       $sResult = _SendMessage($hWnd, $WM_NOTIFY, $TabID, $TCN_SELCHANGE)
;       ExitLoop
;   Else
        $x +=1
;   EndIf
WEnd

#ce

; assume that SECURITY tab is the second (number 1 starting from 0 on left) tab
_GUICtrlTab_SetCurFocus($hTab, 1)
$sResult = _SendMessage($hWnd, $WM_NOTIFY, $TabID, $TCN_SELCHANGE)
WinActivate("Internet Options")
sleep(1000)
; now send the command to open the custom item
send("{TAB}")
sleep(200)
send("!c")
sleep(1000)

;MsgBox0,"","Tree count: " & _GUICtrlTreeView_GetCount(
$treeview = ControlGetHandle("Security Settings - Local Intranet Zone", "", "[CLASS:SysTreeView32]")
$item = _GUICtrlTreeView_GetSelection($treeview)
$item = _GUICtrlTreeView_GetNext($treeview, $item)
$finish = _GUICtrlTreeView_GetCount($treeview)
$count =0
While 1
      $count = $count + 1
      $text = _GUICtrlTreeView_GetTree($treeview, $item)  ;$text holds parent|item name
      msgbox(0,"","Item # " & $count & " text is: " & $text & @CRLF & _
      StringFormat("State for Index %d? %s", $count, _ExplainState(_GUICtrlButton_GetCheck($treeview))))
      If $count = $finish then ExitLoop

      $item = _GUICtrlTreeView_GetNext($treeview, $item)

WEnd

Func _ExplainState($iState, $fPushButton = False)
    Local $sText = ""
    If Not $fPushButton And Not $iState Then Return _
            @CRLF & "Indicates the button is cleared. Same as a return value of zero." & @CRLF
    If BitAND($iState, $BST_CHECKED) = $BST_CHECKED Then _
            $sText &= @CRLF & "Indicates the button is checked." & @CRLF
    If BitAND($iState, $BST_FOCUS) = $BST_FOCUS Then _
            $sText &= @CRLF & "Specifies the focus state. A nonzero value indicates that the button has the keyboard focus." & @CRLF
    If BitAND($iState, $BST_INDETERMINATE) = $BST_INDETERMINATE Then _
            $sText &= @CRLF & "Indicates the button is grayed because the state of the button is indeterminate." & @CRLF
    If $fPushButton Then
        If BitAND($iState, $BST_PUSHED) = $BST_PUSHED Then
            $sText &= @CRLF & "Specifies the highlight state." & @CRLF
        Else
            $sText &= @CRLF & "Specifies not highlighted state." & @CRLF
        EndIf
    EndIf
    Return $sText
EndFunc   ;==>_ExplainState
Link to comment
Share on other sites

  • Moderators

dickep,

I have not used it myself but ControlCommand with the "IsChecked" Option is what you want. Something along the lines of:

$IsChecked = ControlCommand("Window Title", "", $idChkBox, "IsChecked") ; Where $idChkBox is the control ID

should do it.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Not sure what you mean here. Each item in the treeview has the same control ID. I have posted the Window Info capture for the 4th and 5th item in the display. They have almost the same information - especially for the control information.

So, not sure how to make this work - if it could.

If you would be so kind as to maybe give an example of how to use this to see the state of the radio button in the window.

Thanks

;  WINDOW CAPTURE 1 - item 5 (radio button)
>>>> Window <<<<
Title:  Security Settings - Local Intranet Zone
Class:  #32770
Position:   1463, -99
Size:   417, 479
Style:  0x94C800CC
ExStyle:    0x00010101
Handle: 0x035C08EC

>>>> Control <<<<
Class:  SysTreeView32
Instance:   1
ClassnameNN:    SysTreeView321
Name:   
Advanced (Class):   [CLASS:SysTreeView32; INSTANCE:1]
ID: 1024
Text:   Tree1
Position:   27, 31
Size:   354, 270
ControlClick Coords:    84, 203
Style:  0x50310014
ExStyle:    0x00000204
Handle: 0x007D08EE

>>>> Mouse <<<<
Position:   1577, 164
Cursor ID:  2
Color:  0x316AC5

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
Tree1
*Takes effect after you restart Internet Explorer
Reset custom settings
&Reset to:
Medium-low (default)
R&eset...
OK
Cancel
Settings


>>>> Hidden Text <<<<
&Java Custom Settings...


;-----------------------------------
;
;  WINDOW CAPTURE 2 - item 4 (radio button)
>>>> Window <<<<
Title:  Security Settings - Local Intranet Zone
Class:  #32770
Position:   1463, -99
Size:   417, 479
Style:  0x94C800CC
ExStyle:    0x00010101
Handle: 0x035C08EC

>>>> Control <<<<
Class:  SysTreeView32
Instance:   1
ClassnameNN:    SysTreeView321
Name:   
Advanced (Class):   [CLASS:SysTreeView32; INSTANCE:1]
ID: 1024
Text:   Tree1
Position:   27, 31
Size:   354, 270
ControlClick Coords:    75, 182
Style:  0x50310014
ExStyle:    0x00000204
Handle: 0x007D08EE

>>>> Mouse <<<<
Position:   1568, 143
Cursor ID:  2
Color:  0x316AC5

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
Tree1
*Takes effect after you restart Internet Explorer
Reset custom settings
&Reset to:
Medium-low (default)
R&eset...
OK
Cancel
Settings


>>>> Hidden Text <<<<
&Java Custom Settings...

dickep,

I have not used it myself but ControlCommand with the "IsChecked" Option is what you want. Something along the lines of:

$IsChecked = ControlCommand("Window Title", "", $idChkBox, "IsChecked") ; Where $idChkBox is the control ID

should do it.

M23

Link to comment
Share on other sites

  • Moderators

dickep,

Looks like an interesting control! I am afraid that with IE applets you are now well out of my comfort zone - sorry. :D I know that ControlCommand works nicely with more "regular" controls, which is why I suggested it.

However, there are others around here who know much more. Hang on and they will no doubt pop in some time. Perhaps you should edit the thread title to include "Internet Explorer" - that usually gets the IE gurus running! :huggles:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

THanks for you input. I was thinking this was a "regular" control - just part of the applet, but, maybe not.

Not sure how to edit title of the thread but would like to.

dickep,

Looks like an interesting control! I am afraid that with IE applets you are now well out of my comfort zone - sorry. :D I know that ControlCommand works nicely with more "regular" controls, which is why I suggested it.

However, there are others around here who know much more. Hang on and they will no doubt pop in some time. Perhaps you should edit the thread title to include "Internet Explorer" - that usually gets the IE gurus running! :huggles:

M23

Link to comment
Share on other sites

Not sure how to edit title of the thread but would like to.

When you created the first post you wrote the thread title, so how would you logically change the title? By pressing "edit" on the first post! :D
Link to comment
Share on other sites

Anyone else tried getting the radio button status from within a Windows application/applet???

I did something similar, but I was not dealing with a tree, I was dealing with a list.

Not sure if it can help but here it is:

$hWnd = ControlGetHandle("title of the window","","[CLASS:SysListView32]")
$numberOfItemsInList = _GUICtrlListView_GetItemCount($hWnd)

For $i = 0 To ($numberOfItemsInList -1)
     If _GUICtrlListView_GetItemChecked($hWnd, $iIndex) = True Then ; Item is checked, do whatever is required
Next
Link to comment
Share on other sites

Thanks, but tried this a while ago - no luck.

Just seems that the IE Security tab does respond to some of the TreeView calls, but not to all of them - unless I am missing something here.

I did something similar, but I was not dealing with a tree, I was dealing with a list.

Not sure if it can help but here it is:

$hWnd = ControlGetHandle("title of the window","","[CLASS:SysListView32]")
$numberOfItemsInList = _GUICtrlListView_GetItemCount($hWnd)

For $i = 0 To ($numberOfItemsInList -1)
     If _GUICtrlListView_GetItemChecked($hWnd, $iIndex) = True Then ; Item is checked, do whatever is required
Next

Link to comment
Share on other sites

  • Moderators

dickep,

It might just me being pessimistic - but perhaps MS have decided to make this particular applet pretty difficult to automate for obvious reasons! :D

However, do not get discouraged too easily - there might well be a solution out there!

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I am not getting discouraged, but very frustrated. I am going to find someone somewhere that can help me understand what MS is doing and/or try to ferret out the information. I do need this for some activities - need to make sure that all machines are set the same way and writing them all down is really painful (and not the accepted answer for me)>

Thanks for your help and hope someone will have the help I need

dickep,

It might just me being pessimistic - but perhaps MS have decided to make this particular applet pretty difficult to automate for obvious reasons! :D

However, do not get discouraged too easily - there might well be a solution out there!

M23

Link to comment
Share on other sites

  • Moderators

dickep,

Nothing personal, but when you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

OK, I found what I think will work for this . Seems that someone else had the same problem, and, to my happiness, has a solution.

It can be found here if you want to use it.

So far my testing has proved good. Just need to figure out some things, but I can read the help file first, try some things, and then, if necessary, come back here.

For now, consider this SOLVED/RESOLVED.

Thanks all for your input.

E

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...