Sign in to follow this  
Followers 0
Karel

Changing checked items in wireless network properties

7 posts in this topic

Hi,

I want to create a script that can check and uncheck items inside the wireless network properties window, i've managed to get the window opened and highlight the first item but for some reason i can't get it to check/uncheck:

Run ( "rundll32.exe shell32,Control_RunDLL Ncpa.cpl" )

WinWaitActive("Network Connections")

$nic = ControlListView("Network Connections", "", "SysListView321", "FindItem", "Wireless Network Connection")

ControlFocus("Network Connections", "", ControlListView("Network Connections", "", "SysListView321", "Select", $nic))

Send("!{Enter}")

WinWait("Wireless Network Connection Properties")

If Not WinActive("Wireless Network Connection Properties") Then

WinActivate("Wireless Network Connection Properties")

EndIf

WinWaitActive("Wireless Network Connection Properties")

ControlListView ("Wireless Network Connection Properties", "", 16012,"DeSelect",0)

Thanks,

Karel.

Share this post


Link to post
Share on other sites



Welcome to the forum!

Take a look at MouseClick, ControlSend and ControlClick in the help file. Usually you can use the spacebar to check or uncheck a item so

Send("{SPACE}")

Should work when you have highlighted the item.

And a last tip use the autoit tags [ autoit ] [ /autoit ] (remove the spaces) to wrap the code you post. Makes it so much easier to read.

Happy scripting..:)

Share this post


Link to post
Share on other sites

Cheers Uten!

I need to verify which items have been checked on the list, when using the ControlListView command i can only get the text of each item but i cannot get which items have been checked.

Using the "ControlListView" function I cannot find anywhere in the help file a command that can test whether a check box has been checked.

I've tried using _GUICtrlListViewGetCheckedState function but it always returns 1 even if i put index=100 (?!?)

Any idea?

Thanks.

Share this post


Link to post
Share on other sites

Looks like you have encountered a bug in the UDF there?

It's a bit hard for me to help you out since I don't have the same wireless setup (I don't have any on this PC) as you have.

I take it you have tested the helpfile sample.

To me it seems like the _GuiCtrlListViewGetCheckedState should be modified like this:

If ($ret == -1) OR ($ret == 0) Then
    Return $LV_ERR
ElseoÝ÷ Ù:¢÷«¶jǨ~ë®Æ¬)à~íë-jר}¨­zkaj×hzÉèµìb²Û®f²mæî´Z½éèµÈ^rG¶¡Ë¦z{*'jëh×6If (BitAND($ret, 0x3000) == 0x3000) Then
    $isChecked = 0
ElseIf (BitAND($ret, 0x2000) == 0x2000) Then
    $isChecked = 1
Else
    Return $LV_ERR
EndIf

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Try this in place of the function of the include and see if it works on the wireless, don't have one to test, tested on autoit and local area connections listviews and seems to work.

Func _GUICtrlListViewGetCheckedState($h_listview, $i_index)
    Local $ret
    If IsHWnd($h_listview) Then
        $ret = _SendMessage ($h_listview, $LVM_GETITEMSTATE, $i_index, $LVIS_STATEIMAGEMASK)
        If @error Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
        If (BitAND($ret, 0x3000) == 0x3000) Then Return 0
        Return 1
    Else
        $ret = GUICtrlSendMsg($h_listview, $LVM_GETITEMSTATE, $i_index, $LVIS_STATEIMAGEMASK)
        If @error Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
        If (BitAND($ret, 0x2000) == 0x2000) Then Return 1
    EndIf
    Return 0
EndFunc   ;==>_GUICtrlListViewGetCheckedState
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

I've played a bit with the _GUICtrlList functions and when i called these functions using the controlID number, it always failed - gave me 0 as a result on every function i've tried.

So i've tried using the HWND number as a parameter rather than the controlID and it looked better (i.e. gave me the correct item count and item text) BUT for some reason the only function that didn't work well is _GUICtrlListViewGetCheckedState which always returned 1 no matter which index i've supplied.

So I've just took this bit of code:

$ret = _SendMessage ($h_listview, $LVM_GETITEMSTATE, $i_index, $LVIS_STATEIMAGEMASK)oÝ÷ ٩ݦ¸§µçb¶ß~Þ½êòצ~íç!yÉv+^È­­ën®wó_vjw_¢»azz'rçbµé¬ÚÞ¶êçyÝvÛÏ0'+y«Z²+ZrÛ°¢¹,nëmæⵧíz¼­ÛºÚ"µÍY
]S
    ÌÍÜ]Ì
HOHÌ
H[]]

Doesn't as it always returns 1.

Does this mean that there's a bug in this function or is it just for this specific control?

Do you know what excatly _SendMessage returns? the help reference is not very clear.

Thanks,

Karel.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Idiot proofed for those who can't use a valid index

Func _GUICtrlListViewGetCheckedState($h_listview, $i_index)
    If $i_index < 0 Or $i_index > _GUICtrlListViewGetItemCount($h_listview) - 1 Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
    If @error Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
    Local $ret
    If IsHWnd($h_listview) Then
        $ret = _SendMessage($h_listview, $LVM_GETITEMSTATE, $i_index, $LVIS_STATEIMAGEMASK)
        If @error Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
        If (BitAND($ret, 0x3000) == 0x3000) Then Return 0
        Return 1
    Else
        $ret = GUICtrlSendMsg($h_listview, $LVM_GETITEMSTATE, $i_index, $LVIS_STATEIMAGEMASK)
        If @error Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
        If (BitAND($ret, 0x2000) == 0x2000) Then Return 1
    EndIf
    Return 0
EndFunc   ;==>_GUICtrlListViewGetCheckedState
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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