Sign in to follow this  
Followers 0
cache

how to select listview321 items

4 posts in this topic

#1 ·  Posted (edited)

I am trying to automate disabling "Display Shutdown Event Tracker" by using autoit3 with gpedit.msc on 2003 R2

I tried the registry way but it does not work and that's why I am trying autoit.

Here is my code:

run("mmc gpedit.msc")

WinWait("Group Policy Object Editor")

WinActivate("Group Policy Object Editor")

Send("a")

Send("{NUMPADADD}")

Send("s")

;; The following suppose to select the first item on the (right hand side) listview321 control that starts with "d"

ControlSend("Group Policy Object Editor", "", 12786, "d")

The last line of code is not doing what I wanted to. Nothing was being selected. The focus seems still on the left hand side of the listview321 control.

Can anyone point out where I have done wrong? How I can select "Display Shutdown Event Tracker" item?

Thanks!

I also tried

ControlListView ( "Group Policy Object Editor", "", 12786, "Select", 17, 'Display Shutdown Event Tracker' )

but no luck....... :)

Edited by cache

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I am trying to automate disabling "Display Shutdown Event Tracker" by using autoit3 with gpedit.msc on 2003 R2

I tried the registry way but it does not work and that's why I am trying autoit.

Here is my code:

run("mmc gpedit.msc")

WinWait("Group Policy Object Editor")

WinActivate("Group Policy Object Editor")

Send("a")

Send("{NUMPADADD}")

Send("s")

;; The following suppose to select the first item on the (right hand side) listview321 control that starts with "d"

ControlSend("Group Policy Object Editor", "", 12786, "d")

The last line of code is not doing what I wanted to. Nothing was being selected. The focus seems still on the left hand side of the listview321 control.

Can anyone point out where I have done wrong? How I can select "Display Shutdown Event Tracker" item?

Thanks!

I also tried

ControlListView ( "Group Policy Object Editor", "", 12786, "Select", 17, 'Display Shutdown Event Tracker' )

but no luck....... :P

Your misuse of the last parameter in the "Select" command may have confused the issue. Try:

For $n = 0 To ControlListView("Group Policy Object Editor", "", 12786, "GetItemCount") - 1
     If StringLeft(ControlListView("Group Policy Object Editor", "", 12786, "GetText", $n), 1) = "D" Then
          ControlListView("Group Policy Object Editor", "", 12786, "Select", $n)
     EndIf
Next

:)

Edit: Added "- 1" to the the item count, since the items are numbered from 0 and the count starts at 1.

Edited by PsaltyDS

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

#3 ·  Posted (edited)

Your misuse of the last parameter in the "Select" command may have confused the issue. Try:

For $n = 0 To ControlListView("Group Policy Object Editor", "", 12786, "GetItemCount") - 1
     If StringLeft(ControlListView("Group Policy Object Editor", "", 12786, "GetText", $n), 1) = "D" Then
          ControlListView("Group Policy Object Editor", "", 12786, "Select", $n)
     EndIf
Next

:)

Edit: Added "- 1" to the the item count, since the items are numbered from 0 and the count starts at 1.

Thx!! After a bit modification, the script worked as what it supposed to!!

Thank you very much!

Here is my final code that disable the "Shutdown Event Tracker" on 2003

just in case for other members' reference.

====================================

Local $title="Group Policy Object Editor"

Local $policy_name="Display Shutdown Event Tracker"

Local $pg_ctl_id=12786

run("mmc gpedit.msc")

WinWait($title)

WinActivate($title)

Send("a")

Send("{NUMPADADD}")

Send("s")

Sleep(2000)

For $n = 0 To ControlListView($title, "", $pg_ctl_id, "GetItemCount") - 1

If StringLeft(ControlListView($title, "", $pg_ctl_id, "GetText", $n), Stringlen($policy_name)) = $policy_name Then

ControlListView($title, "", $pg_ctl_id, "Select", $n)

ControlSend($title, "", $pg_ctl_id, "{ENTER}")

winwait($policy_name)

WinActivate($policy_name)

send("!d" & "!a")

ControlClick($policy_name, "OK", 1)

WinClose($title)

exitLoop

EndIf

Next

Edited by cache

Share this post


Link to post
Share on other sites

Thx!! After a bit modification, the script worked as what it supposed to!!

Thank you very much!

Here is my final code that disable the "Shutdown Event Tracker" on 2003

just in case for other members' reference.

====================================

Local $title="Group Policy Object Editor"
Local $policy_name="Display Shutdown Event Tracker"
Local $pg_ctl_id=12786
run("mmc gpedit.msc")
WinWait($title)
WinActivate($title)
Send("a")
Send("{NUMPADADD}")
Send("s")
Sleep(2000)
For $n = 0 To ControlListView($title, "", $pg_ctl_id, "GetItemCount") - 1
     If StringLeft(ControlListView($title, "", $pg_ctl_id, "GetText", $n), Stringlen($policy_name)) = $policy_name Then
          ControlListView($title, "", $pg_ctl_id, "Select", $n)
          ControlSend($title, "", $pg_ctl_id, "{ENTER}")
          winwait($policy_name)
          WinActivate($policy_name)
          send("!d" & "!a")
          ControlClick($policy_name, "OK", 1)
          WinClose($title)
          exitLoop
     EndIf
Next
You're welcome, glad it worked! :)

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