Jump to content
Sign in to follow this  
cracksys

Directing focus on specific file within a folder view

Recommended Posts

cracksys

hi all,

here's the thing,

i wanted to unrar specific file (xxx.rar) by using it context menu -- right clicking.

question is, how do i get the file selected (click once)? i can't continue with MouseCoord because that file's position within a folder is constantly changing.

thanks

Share this post


Link to post
Share on other sites
JackDinn

$file_name="ver 1.7.txt"
$folder="C:\Documents and Settings\Greg\Desktop\ClipCatch Pack"
WinActivate($folder)
WinWaitActive ($folder)
$item=ControlListView ($folder,"","SysListView321","FindItem",$file_name)
$count=ControlListView ($folder,"","SysListView321","GetItemCount")
ControlListView ($folder,"","SysListView321","deSelect",0,$count)
ControlListView ($folder,"","SysListView321","Select",$item)

if you know what the name of the file is then you can do this. (folder will have to be open already) if not just use

ShellExecute($folder)
- open folder Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites
Melba23

cracksys,

An Explorer list is a ListView, so you can use the _GUIListView UDF to get the contents and their positions:

#Include <GuiListView.au3>
#include <Array.au3>

$sFolder_Name = "Your_Folder_Name"
$hExplorer_List = ControlGetHandle($sFolder_Name, "", "[CLASS:SysListView32;INSTANCE:1]" )

; Save the listview items and positions to an array
Global $aExplorer_Contents[_GUICtrlListView_GetItemCount($hExplorer_List)][5]
For $i = 0 to _GUICtrlListView_GetItemCount($hExplorer_List) - 1
   ; Name
    $aExplorer_Contents[$i][0] = _GUICtrlListView_GetItemText($hExplorer_List, $i)
; If you use icons
    $aPos = _GUICtrlListView_GetItemPosition($hExplorer_List, $i)
   ; Left
    $aExplorer_Contents[$i][1] = $aPos[0]
   ; Top
    $aExplorer_Contents[$i][2] = $aPos[1]
; If you use lists
    $aPos = _GUICtrlListView_GetItemRect($hExplorer_List, $i)
; Left
    $aExplorer_Contents[$i][3] = $aPos[0]
   ; Top
    $aExplorer_Contents[$i][4] = $aPos[1]
Next

; Show the contents and their positions
_ArrayDisplay($aExplorer_Contents)

This will give you a list of the contents and their positions within the Explorer ListView. Over to you to click on the one you want.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites
cracksys

@JackDinn

thanks. i tested and both of $count, $item variable contained 0 in the end

could it be that because i'm using vista?

@Melba23

haven't had time to test it yet. maybe tomorrow. but thanks. ^_^

Share this post


Link to post
Share on other sites
Yashied

cracksys,

An Explorer list is a ListView, so you can use the _GUIListView UDF to get the contents and their positions:

#Include <GuiListView.au3>
#include <Array.au3>

$sFolder_Name = "Your_Folder_Name"
$hExplorer_List = ControlGetHandle($sFolder_Name, "", "[CLASS:SysListView32;INSTANCE:1]" )

; Save the listview items and positions to an array
Global $aExplorer_Contents[_GUICtrlListView_GetItemCount($hExplorer_List)][5]
For $i = 0 to _GUICtrlListView_GetItemCount($hExplorer_List) - 1
  ; Name
    $aExplorer_Contents[$i][0] = _GUICtrlListView_GetItemText($hExplorer_List, $i)
; If you use icons
    $aPos = _GUICtrlListView_GetItemPosition($hExplorer_List, $i)
  ; Left
    $aExplorer_Contents[$i][1] = $aPos[0]
  ; Top
    $aExplorer_Contents[$i][2] = $aPos[1]
; If you use lists
    $aPos = _GUICtrlListView_GetItemRect($hExplorer_List, $i)
; Left
    $aExplorer_Contents[$i][3] = $aPos[0]
  ; Top
    $aExplorer_Contents[$i][4] = $aPos[1]
Next

; Show the contents and their positions
_ArrayDisplay($aExplorer_Contents)

This will give you a list of the contents and their positions within the Explorer ListView. Over to you to click on the one you want.

M23

Melba23, I see you are the master of "SysListView32". Good example again.

^_^

Share this post


Link to post
Share on other sites
cracksys

i'm sorry but i couldn't find any EDIT button in here

@JackDinn

i managed to get your example up and running. it worked well if $file_name is a sub-folder name but it won't if i changed it to any file name within that folder.

any thought on this?

Share this post


Link to post
Share on other sites
Yashied
JackDinn

@JackDinn

i managed to get your example up and running. it worked well if $file_name is a sub-folder name but it won't if i changed it to any file name within that folder.

any thought on this?

pass, it works fine for me with both $File_name = "subfolder" or "file name". if you can select a folder then it should be no problem to select a file in same location.

have you misspelt or left of the suffix from the file name or to many back slashes in path?

what does $item return?

what does $count return?

whats your full path ?

whats your file name ?

and show me what you got so far (just this bit of script)

Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites
cracksys

@JackDinn

i had a quick rewrite and found out that $file_name="File1.rar" won't work if my explorer setting is set to Hide Known Extensions.

i could just set $file_name="File1" but problem arise when there's a folder called File1 in the same directory. so how do i make sure $item, $count point to File1 not the folder called File1?

i'll post my script when i get back home.

@Yashied

i'm sorry but i think you misunderstood my question. here's the situation -- i have a bunch of portable apps within 1 folder that i RAR-ed whenever i left home for office & vice versa. this RAR file will be transited on a removable drive. when i arrived at my destination, i will unRAR it back.

i just want to automate the process of -- copying File.rar to computer, unRAR it then RAR it back and copying it to the removable drive when i'm finished.

Share this post


Link to post
Share on other sites
JackDinn

ahh , have to be difficult , lol

$file_type = "Text Document"
$file_name = "ver 1.5.txt"
$folder = "C:\Documents and Settings\Greg\Desktop\ClipCatch Pack"
$file = _select_file_in_folder($file_name, $folder, $file_type)
MsgBox(0, "File Selected", $file)


Func _select_file_in_folder($file_name, $folder, $file_type)
    ShellExecute($folder);open folder
    WinActivate($folder)
    WinWaitActive($folder)
    ControlListView($folder, "", "SysListView321", "SelectClear")
    For $x = 1 To ControlListView($folder, "", "SysListView321", "GetItemCount")
        If ControlListView($folder, "", "SysListView321", "GetText", $x) = $file_name Then
            If ControlListView($folder, "", "SysListView321", "GetText", $x, 2) = $file_type Then
                ControlListView($folder, "", "SysListView321", "Select", $x)
                Return $x
            EndIf
        EndIf
    Next
    Return 0
EndFunc;==>_select_file_in_folder

note:- $file_type -- (as in "Text Document" or "Compressed (zipped) Folder") in your case, i think "WinRAR archive"

thing is that there are much better ways of doing what your describing (moving files around, basically and a bit of archiving see :- zip UDF) but this should do ya 4 now ^_^

try out. good luck

Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites
dexto

ControlListView ($folder,"","SysListView321","Select",$item)

Selects the file ok but is it possible to make sure the selected file is visible?

Share this post


Link to post
Share on other sites
Melba23

dexto,

Look at _GUICtrlListView_EnsureVisible in the Help file.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.