Jump to content

How to select the first item in a list


Recommended Posts

I am writing a script that opens a program then opens up a folder and it needs to select files from within this folder. I need it to select them in order but i cannot seem to make it to select the first one. this is the code i have for that

ControlListView ( "Open", "", "[CLASS:DirectUIHWND; INSTANCE:2]", "Select", $Nmodels )

how do i make it so that it selects the first one. right now it goes directly to the middle one.

thanks

Link to comment
Share on other sites

What makes you think that "DirectUIHWND" class would respond to the regular Windows SysListView32 API, which is what ControlListView() uses?

:idea:

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

this is the information that autoit window info gives me. i also want to mention that i am working on windows server 2008 R2. i also tried using [CLASS:SysListView32; INSTANCE:1] which works fine in windows server 2008 but for some reason it doesnt work now with R2. any ideas?

Edited by tironci
Link to comment
Share on other sites

maybe i'm not being clear. the script works fine with "CLASS:SysListView32" in win xp and win server 2008. but when i try to use it in win server 2008 r2 it doesn't work and when i use autoit window info it gives me "CLASS:DirectUIHWND" for the same listview. thats why i'm having a problem and not understanding why. i don't know if i'm being clear enough.

Link to comment
Share on other sites

The explorer view in Vista shows SysListView for the contents list, and DirectUIHWND for the toolbar buttons (Organize/Views/Explore/Share/Burn). I don't have Server 2008 to compare that with.

But again, if the content list in Server 2008 is also DirectUIHWND, I don't think you can expect the SysListView API functions of ControlListView() to work on it.

A quick search of the forums turns up lots of depressing answers like this one:

The control class is now "DirectUIHWND" which I don't think is compatible with any of the listview functions in AutoIt. I can't seem to find anything about it on MSDN.

:idea:

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

This is true of Windows 7 explorer also. No more SysListView.

I am having the same problem. So If we can't use SysListView, and DirectUIHWND is the "new" thing. How can we control the new list?

My command as SysListView was:

ControlListView ( "Open", "", "[CLASS:SysListView32; INSTANCE:1]", "Select", $Nmodels )

Is there any other Control to proper select files displayed by DirectUIHWND?

Link to comment
Share on other sites

So far doesn't seem to exist an answer so I created a work around.

If anyone has a better work around please let me know.

winActivate("Open")

            sleep($sleep)
            $n = 8 ;This is somewhat a "magic" number that can mess things up in my environment it was 8
            Send("{TAB " & $n & "}") ;press tab $n times
            Sleep($sleep)

            ;only needed to select the first file 
            if $Nitems = 0 Then
                sleep($sleep)
                send("{DOWN}")
                sleep($sleep)
                send ("{UP}")
            EndIf

            ; used to select the other items in the list
            if $Nitems > 0 Then
                sleep ($sleep)
                send ("{DOWN " & $Nitems & "}")
                sleep ($sleep)
            EndIf
Link to comment
Share on other sites

  • 3 years later...
  • Moderators

autoitaddicted,

And just how is a PureBasic forum thread supposed to help? :huh:

I see you have done the same thing here - please do not do it again unless you translate the code into AutoIt as well. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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