Jump to content

Automating destination folder and SysTreeView32 (PARTIALLY SOLVED)


sdraw107
 Share

Recommended Posts

Hi,

I've been using AuotoIt for a while now so am reasonably capable with the syntax and common functions. However, I've run into a couple of issues while trying to build a script which automates software installers. The script I am currently working on is for installing FileZilla (http://filezilla-project.org/). The first issue relates to selecting which components to install. This is presented as a SysTreeView32 with checkboxes for "FileZilla Client", "Icon sets", "Language files", "Shell Extension", and "Desktop Icon", as per this screenshot:

Posted Image

I am trying to automate this using the ControlTreeView function. The following commands work fine for that function: Exists, GetText, IsChecked, Select. However, Check and Uncheck do nothing (even though Exists is able to recognise any given item on the TreeView). In order to emulate the Check and Uncheck commands I have had to resort to the following code, which first sees if the item is already checked, and then based on that sends a spacebar to the treeview to check or uncheck it:

If ControlTreeView($handle, "", $treeView32, "IsChecked", "Icon sets") == 0 Then
    ControlTreeView($handle, "", $treeView32, "Select", "Icon sets")
    Sleep(20)
    ControlSend($handle, "", $treeView32, " ")
EndIf

Although the above code works, I dislike hacks like this and would prefer to be communicating directly with the control itself. I'm puzzled as to why IsChecked works but Check doesn't. Any ideas?

EDIT: I have solved the second problem below. The solution is in one of my replies.

The second problem is with the point at which the installer asks the user to choose a destination folder for the installation:

Posted Image

When I use AutoIt Window Info, it considers the entire area with the words "Destination Folder", the edit box with the path, the browse button, and the surrounding border, to be a single object of class Button. I am unable to target a specific component of it e.g. the path or the browse button. I am again forced to resort to a hack, by relying on the fact that the path box is next in the tab sequence from the cancel button:

BlockInput(1)
WinActivate($handle)
;Set focus on cancel button
ControlFocus($handle, "", "[CLASS:Button; INSTANCE:3]")
;Press tab to move to the path edit box
ControlSend($handle, "", "[CLASS:Button; INSTANCE:3]", "{TAB}")
;Enter the desired path
SendKeepActive($handle)
Send("c:\program files\FileZilla FTP Client")
SendKeepActive("")
BlockInput(0)

Because I am sending the path as a string, I am also obliged to use BlockInput to prevent the user from accidentally inserting an undesired character in the path.

Any help on either of these issues will be much appreciated.

Edited by sdraw107
Link to comment
Share on other sites

Update: I have been able to solve the second problem. It occured to me that the AutoIt Window Info tool may be missing on some of the controls when they are "inside" the graphical area of another control. Sure enough, I used WinGetClassList and saw an Edit control which the Window Info tool had not indentified. That control contained the destination folder which I was trying to access.

Still stumped by the first problem though. Anyone ever come across a TreeView32 whereby Exists and IsChecked report back correct information, but Check doesn't work?

Link to comment
Share on other sites

Use the control UDFs for these situations.

Get the Winspector and Window Detective utilities,

they find controls that the Au3Info app doesn't.

#include <WinAPI.au3>
#Include <GuiTreeView.au3>

;FileZilla Client 3.3.5.1 Setup has a space at the end of the title, hence StringStripWS()
Local $hWin = WinGetHandle("[TITLE:FileZilla Client 3.3.5.1 Setup; CLASS:#32770]")
If IsHWnd($hWin) = 0 Or StringStripWS(WinGetTitle($hWin) ,3) <> "FileZilla Client 3.3.5.1 Setup" Then ;Or  _WinAPI_GetClassName($hWin) <> "#32770" Then
    ConsoleWrite("! Error: Failed to retrieve FileZilla Client 3.3.5.1 Setup handle" & @CRLF)
EndIf

WinActivate($hWin)

Local $hTreeView = ControlGetHandle($hWin, "", "[CLASSNN:SysTreeView321; ID:1032]")
If IsHWnd($hTreeView) = 0 Or _WinAPI_GetClassName($hTreeView) <> "SysTreeView32" Then
    ConsoleWrite("! Error: Failed to retrieve SysTreeView32 handle" & @CRLF)
EndIf

;Local $pItem = _GUICtrlTreeView_FindItem($hTreeView, "Icon sets")
;If _GUICtrlTreeView_GetChecked($hTreeView, $pItem) = True Then

If ControlTreeView($hWin, "", $hTreeView, "IsChecked", "Icon sets") = 1 Then
    Local $pItem = _GUICtrlTreeView_FindItem($hTreeView, "Icon sets")

    If IsPtr($pItem) = 0 Then Exit
    _GUICtrlTreeView_SetChecked($hTreeView, $pItem, False)
    If ControlTreeView($hWin, "", $hTreeView, "IsChecked", "Icon sets") = 1 Then
        ConsoleWrite("!Error: Failed to uncheck 'Icon sets'" & @CRLF)
    Else
        ConsoleWrite("+'Icon sets' unchecked" & @CRLF & @CRLF)
    EndIf
EndIf

;Destination Folder
;~ Local $hEdit = ControlGetHandle($hWin, "", "[CLASSNN:Edit1; ID:1019]")
;~ Local $sEditTxt = ControlGetText ($hWin, "", $hEdit)
;~ $sEditTxt = StringReplace($sEditTxt, 1, "D", 1, 0)
;~ ControlSetText($hWin, "", $hEdit, $sEditTxt)

I see fascists...

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