Jump to content

Need Help With ControlFocus


MElkins
 Share

Recommended Posts

Can someone please help me with this. I have an AutoIt script I'm trying to get to work in Vista 32bit. The ControlFocus command won't detect the control. The Control ID according to AutoInfo is 1123. Below is the code snippet and the AutoInfo dump.

What I'm trying to do is scroll down the Customize Start Menu items and turn certain options on or off.

I open the window by running rundll32.exe shell32.dll,Options_RunDLL 1

I would appreciate any help you might offer.

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

$WinTitle = "Customize Start Menu"

$WinTxt = "Start menu"

$CtrlId = "[iD:1123]"

$RetSts = ControlFocus($WinTitle, $WinTxt, $CtrlId)

IF $RetSts = 0 Then

MsgBox(0, $MsgTitle, "Could not find the " & $WinTitle & "/" & $CtrlId & " Control!")

Else

[AutoIt Code]

Endif

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

>>>> Window <<<<

Title: Customize Start Menu

Class: #32770

Position: 259, 232

Size: 383, 470

Style: 0x94C800CC

ExStyle: 0x00010101

Handle: 0x001F0252

>>>> Control <<<<

Class: SysTreeView32

Instance: 1

ClassnameNN: SysTreeView321

Advanced (Class): [CLASS:SysTreeView32; INSTANCE:1]

ID: 1123

Text: StartMenuSe&ttings

Position: 11, 42

Size: 357, 202

ControlClick Coords: 348, 170

Style: 0x50210001

ExStyle: 0x00000204

Handle: 0x000103E2

>>>> Mouse <<<<

Position: 621, 466

Cursor ID: 2

Color: 0xD4D0C8

>>>> StatusBar <<<<

>>>> Visible Text <<<<

You can customize how links, icons, and menus look and behave on the Start menu.

StartMenuSe&ttings

Start menu size

&Number of recent programs to display:

9

Use &Default Settings

Show on Start menu

&Internet link:

Internet Explorer

&E-mail link:

Microsoft Office Outlook

OK

Cancel

>>>> Hidden Text <<<<

Link to comment
Share on other sites

Are you perhaps not waiting for the window to come up first?

$WinTitle = "Customize Start Menu"
$WinTxt = "Start menu"
$CtrlId = "[ID:1123]"

WinWait($WinTitle, $WinTxt)

$RetSts = ControlFocus($WinTitle, $WinTxt, $CtrlId)
IF $RetSts = 0 Then
  MsgBox(0, $MsgTitle, "Could not find the " & $WinTitle & "/" & $CtrlId & " Control!")
Else
  [AutoIt Code] 
Endif

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
Link to comment
Share on other sites

I managed to get past the ControlFocus by removing the Window Text (""), but now I'm having problems with AutoIt not seeing the items listed in the control ("Connect To, "Default Programs", etc.).

$WinTitle = "Customize Start Menu"

$WinTxt = "Start menu"

$RetSts = WinWaitActive ($WinTitle, $WinTxt, 10)

If $RetSts = 0 Then

MsgBox(0, $MsgTitle, "Could not find the " & $WinTitle & "/" & $WinTxt & " Window!")

Exit

$CtrlId = "[iD:1123]"

$RetSts = ControlFocus($WinTitle, "", $CtrlId)

IF $RetSts = 0 Then

MsgBox(0, $MsgTitle, "Could not find the " & $WinTitle & "/" & $CtrlId & " Control!")

Exit

Endif

$Idx = ControlListView($WinTitle, "", $CtrlId, "FindItem", "Connect To")

If $Idx < 0 Then

MsgBox(0, $MsgTitle, "Could not find the " & $WinTitle & "/" & $CtrlId & " Connect To!")

Else

$Idx = ControlListView($WinTitle, "", $CtrlId, "Deselect", $Idx)

EndIf

$Idx = ControlListView($WinTitle, "", $CtrlId, "FindItem", "Default Programs")

If $Idx < 0 Then

MsgBox(0, $MsgTitle, "Could not find the " & $WinTitle & "/" & $CtrlId & " Default Programs!")

Else

$Idx = ControlListView($WinTitle, "", $CtrlId, "Deselect", $Idx)

EndIf

Edited by MElkins
Link to comment
Share on other sites

I managed to get past the ControlFocus by removing the Window Text (""), but now I'm having problems with AutoIt not seeing the items listed in the control ("Connect To, "Default Programs", etc.).

$WinTitle = "Customize Start Menu"

$WinTxt = "Start menu"

$RetSts = WinWaitActive ($WinTitle, $WinTxt, 10)

If $RetSts = 0 Then

MsgBox(0, $MsgTitle, "Could not find the " & $WinTitle & "/" & $WinTxt & " Window!")

Exit

$CtrlId = "[iD:1123]"

$RetSts = ControlFocus($WinTitle, "", $CtrlId)

IF $RetSts = 0 Then

MsgBox(0, $MsgTitle, "Could not find the " & $WinTitle & "/" & $CtrlId & " Control!")

Exit

Endif

$Idx = ControlListView($WinTitle, "", $CtrlId, "FindItem", "Connect To")

If $Idx < 0 Then

MsgBox(0, $MsgTitle, "Could not find the " & $WinTitle & "/" & $CtrlId & " Connect To!")

Else

$Idx = ControlListView($WinTitle, "", $CtrlId, "Deselect", $Idx)

EndIf

$Idx = ControlListView($WinTitle, "", $CtrlId, "FindItem", "Default Programs")

If $Idx < 0 Then

MsgBox(0, $MsgTitle, "Could not find the " & $WinTitle & "/" & $CtrlId & " Default Programs!")

Else

$Idx = ControlListView($WinTitle, "", $CtrlId, "Deselect", $Idx)

EndIf

According to your first post, the control is a TreeView, not a ListView. Try ControlTreeView() on it...?

:)

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