Jump to content
Sign in to follow this  

ControlTreeView Check & IsChecked refuse to work

Recommended Posts

I'm trying to (un)tick checkboxes and select radiobuttons using ControlTreeView. The problem is that both refuse to work. However, "Exists" and "Select" both work (Although I do not see a (blue or dotted) selection box the latter causes the treeview to scroll the item into view).

What is going on here, and how do I fix it ?

I've been both googeling and searching this forum for quite a bit of time. Although the problem seems to exist for years I've not seen an explanation (other than a 32 vs 64 bit OS) nor found a solution. Is this one of those "won't fix" issues ?

Ah, I almost forgot: The version (AutoIt3.exe) shows

Share this post

Link to post
Share on other sites

One more thing you forgot, @BitRot, your code :) Please post what you have, or a reproducer that shows your issue, so we're not guessing at what you're trying to do.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Share this post

Link to post
Share on other sites
One more thing you forgot, @BitRot, your code

I didn't. Forget that is. That was a consious decision. Including not mentioning the OS version it runs on.

What do you need ? And don't say "everything" please.

Mind you, I already mentioned that two other outof the same group seem to work.

But, lets see if you can spot a mistake :-)

$hProcess = Run('rundll32.exe shell32.dll,Options_RunDLL 0')

[snip making sure the proces and window are there]

$sAppletTitle = "Folder Options"
ConsoleWriteError (ControlTreeView($sAppletTitle,"","SysTreeView321","Select","Files and Folders|Do not cache thumbnails") & @crlf)
ConsoleWriteError (ControlTreeView($sAppletTitle,"","SysTreeView321","Exists","Files and Folders|Do not cache thumbnails") & @crlf)
ConsoleWriteError (ControlTreeView($sAppletTitle,"","SysTreeView321","Check","Files and Folders|Do not cache thumbnails") & @crlf)
Fails (returns -1 , no checkable control found)
ConsoleWriteError (ControlTreeView($sAppletTitle,"","SysTreeView321","IsChecked","Files and Folders|Do not cache thumbnails") & @crlf)

Currently, after some testing (using a "real" programming language :-p ) I think I know why it fails (marshalling related), but I'm surprised that that I've not seen it mentioned anywhere, particulary including AutoIt's Help...

Share this post

Link to post
Share on other sites

For the off chance that anybody reads this:

The problem turned out not to be AutoIt (my apologies for assuming so), but rather the TreeView (as used by XPsp3's "Folder Options" dialog -> "View". It happens to fake checkboxes (and radio buttons) by re-purposing the "file extension" images. (thats the reason of the problem)

The begin of the solution for the faked checkboxes is to use _GUICtrlTreeView_SetImageIndex to assign the correct image. The faked radio buttons can also be altered this way too, but than the other radio buttons (in the same group) will not respond to the change. To get that to work the (much simpler) _GUICtrlTreeView_ClickItem should be used - which has an added benefit that the dialog registers a change and enables the "Apply" button at he bottom.
(thats the solution)

(hmm... I would have liked to see a preview of what I'm about to post. Will the above > convert or not ...)

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By jdegraff
      I'm trying to add a bit of functionality to the FastStone File Rename dialog. I can access every control that I need to except the one that contains the files to be renamed. If I do some exploring in a vbScript shell I get
      :c  = "TTntTreeView.UnicodeClass1"
      You can see that the treeview control reports having five items, which is the number displayed. If I manually select (mouse) item #3 I can see the result by
      But I do not know how to get the text for the selected item. If "#3" is the item reference then I should be able to
      if I go strictly by the help file, but it returns nothing.
      So it appears that item 3 exists, but
      does not have any text???
      and it also appears item 9 exists (it does not)
      causes the first item to be selected, as does
      Here is the output from the Window Info tool
      >>>> Window <<<<
      Title:  Batch Image Convert / Rename
      Class:  TBatchConvert
      Position:   501, 83
      Size:   760, 520
      Style:  0x16CD0000
      ExStyle:    0x00010100
      Handle: 0x0000000001950796
      >>>> Control <<<<
      Class:  TTntTreeView.UnicodeClass
      Instance:   1
      ClassnameNN:    TTntTreeView.UnicodeClass1
      Advanced (Class):   [CLASS:TTntTreeView.UnicodeClass; INSTANCE:1]
      ID: 37030040
      Position:   354, 79
      Size:   378, 188
      ControlClick Coords:    108, 86
      Style:  0x54010039
      ExStyle:    0x00000200
      Handle: 0x0000000002350898
      >>>> Mouse <<<<
      Position:   970, 279
      Cursor ID:  0
      Color:  0xE1E1E1
      >>>> StatusBar <<<<
      >>>> ToolsBar <<<<
      >>>> Visible Text <<<<
      Batch Rename
      Images + Videos (*.jpg;*.jpe;*.jpeg;*.bmp;*.gif;*.tif;*.tiff;*.cur;*.ico;*.png;*.pcx;*.jp2;*.j2k;*.tga;*.ppm;*.wmf;*.psd;*.crw;*.nef;*.cr2;*.orf;*.raf;*.dng;*.mrw;*.pef;*.srf;*.arw;*.rw2;*.x3f;*.sr2;*.srw;*.nrw;*.rwl;*.eps;*.avi;*.mpeg;*.mpg;*.wmv;*.mov;*.mp4;*.mts;*.mkv;*.m4v)
      Search and Replace
      Use Filename Template
      No Sort
      Add All
      No Change

    • By ur
      if ControlClick("[CLASS:MsiDialogCloseClass]"," ","[CLASS:SysTreeView32; INSTANCE:1]") Then $htreeview=ControlGetHandle($hwnd,"","[CLASS:SysTreeView32; INSTANCE:1]") ControlTreeView($hwnd," ",$htreeview,"Select","#4") The above code worked well to enable the martupgrade feature on windows 7.
      As part of our Installation Testing Automation before delivering the installer to end user.To confirm whether all the screens are working good.

      But it is not working on windows 10.
      $h= ControlTreeView($hwnd," ",$htreeview,"Select","#4") The $h is getting value 1,which means error.
    • By tremolux66
      I'm automating a commercial app that will copy files/folders from an optical disc to a folder on a hard drive, and am unable to check an item in a SysTreeView32 control in the app's main window. The disc and its top-level folders are displayed as a simple tree, and I've written a test script that probes and manipulates the control by calling ControlTreeView(). The script cannot, on its own, check the desired item in the TreeView, but it can check the item with some manual intervention. I need to know if there's something missing, or if a different approach is needed.
      The operations currently being tested are:
      Waiting until the contents of the TreeView control appear before proceeding (the app can take a long time to display the control contents), and Checking the first item's checkbox (i.e., the disc itself), thus selecting the entire disc contents for copying. The test script can complete the first operation successfully, but not the second: there is a side-effect of the first that apparently causes the second one to fail.
      When the control's contents eventually become visible, they look like this; note the position of the scrollbar:

      The wait is done by repeatedly selecting the first item until @error=0 using the following code fragment (note: the code has been edited for brevity and to remove certain information):
      ; Wait for the DM window to become active ; -- _WinWaitActivate() is from AU3 Recorder-generated code $hWnd1 = _WinWaitActivate($sDMtitle,"") ; Wait for the SysTreeViewList32 control to display its first item $sCtrlAdvMode = "[CLASS:SysTreeView32; INSTANCE:1]" $i = 0 $iRetVal = ControlTreeView($hWnd1,"",$sCtrlAdvMode,"Select","#0") $iAtError = @error While $iAtError <> 0 $i += 1 If $i > 20 Then ExitLoop Sleep(5000) $iRetVal = ControlTreeView($hWnd1,"",$sCtrlAdvMode,"Select","#0") $iAtError = @error WEnd If $i > 20 Then ConsoleWrite("Select: Unable to select 1st item after 20 tries" & @CRLF) This works - the script successfully loops until the contents are visible, but when the item selection finally succeeds, the control contents scroll horizontally, hiding the checkboxes:

      The script then tries to check the first item by calling ControlTreeView() from the following code fragment (again, edited for brevity, etc.):
      ; Check the first item $iRetVal = ControlTreeView($hWnd1,"",$sCtrlAdvMode,"Check","#0") If @error <> 0 Then ConsoleWrite("Check: Unable to check 1st item, return=" & $iRetVal & ", @error=" & @error & ", @extended=" & @extended & @CRLF) $iRetVal = ControlTreeView($hWnd1,"",$sCtrlAdvMode,"IsChecked","#0") ConsoleWrite("IsChecked: return=" & $iRetVal & ", @error=" & @error & ", @extended=" & @extended & @CRLF) The Check call always returns @error=1, and the IsChecked call returns without error, but with a value of False. (The boxes remain unchecked on the screen as well.)
      HOWEVER: With some experimentation I discovered that if I put a pause in the test script so that I can manually scroll the TreeView to make the checkboxes visible, then the Check call works - the boxes in the control are all checked, and the IsChecked call returns True.
      Any suggestions for making this work under program control (no manual intervention)? The application needs to be completely automated.
      Note: I have tried another method for the wait-loop (getting the first item's checkbox value), hoping it would achieve the desired result without scrolling the tree. However, the IsChecked call returns with @error=0 (and False) on the first call, long before the tree was visible.
    • By kcvinu
      Hi all,
      I am experimenting with ControlTreeView function. But when i try this code, it is not doing anything.
      ControlTreeView("PhraseExpress Freeware v10.5.41f","",132066,"Select","PhraseExpress|Ahat|#3") Please see this image. I have use "WinActivate" function before this code. But no way.

    • By Brian39
      I have made a script for SAP application. I use the "MouseClick" to click on the arrow left of "HR" to expand tree. Then "MouseClick" to double click on "Tidsregistrering". This work fine but I would like to use something like "ControlTreeView" to expand the "HR" folder and "ControlClick" to activate "Tidsregistrering".
      I have attached a screendump with "Autoit window info". But I cant get it to work.
      To expand the "HR" folder I use: ControlTreeView("SAP Easy Access", "", "[iD:100]", "Expand")
      To enter "Tidsregistrering" menu I use: ControlClick("SAP Easy Access", "", "[iD:100]")

      Hopefully someone could point me in the right direction

  • Create New...