AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Refresh folder Dir using Listview GUI

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
icefreez



Joined: 15 May 2007
Posts: 39

PostPosted: Mon Nov 05, 2007 3:15 pm    Post subject: Refresh folder Dir using Listview GUI Reply with quote

I have this script I am using to display specific file types in a specific directory and refresh it with a set interval. It is working properly however I have a small issue. The only way I can figure out how to do this is to wipe the listview's contents and then repopulate it. This results in a small flicker as the listview repopulates.

I am also aware of the "GuiControl" function but am unsure how I can use it to update a dynamically changing number of rows, since the number of files in the directory will change over time.

Any suggestion how to stop the listview from flickering as it refreshes?

Current Script:
Code:
Gui, Add, ListView, vLiveQueueList x5 y5 w200 h350 gLiveList, Live Queue
Gui, Show, NoActivate

folderdir = C:\live\queue\
fileext = dat
refreshtime = 5000 ;5 seconds

loop
{
;wipe out listview
Gui, Listview, LiveQueueList
LV_Delete()

;list files
Gui, Listview, LiveQueueList
Loop, %folderdir%*.%fileext%
   LV_Add("", A_LoopFileName)
sleep, %refreshtime%
}
return


LiveList:
Gui, Listview, LiveQueueList
;launch file
if A_GuiEvent = DoubleClick
{
    LV_GetText(RowText, A_EventInfo)  ; Get the text from the row's first field.
    run, %folderdir%%RowText%
}
;open files directory
else if A_GuiEvent = R
{
   run, %folderdir%
}
return

GuiClose:
ExitApp
Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 6847
Location: Pacific Northwest, US

PostPosted: Mon Nov 05, 2007 4:35 pm    Post subject: Reply with quote

if you keep track of everything internally, you can use LV_Delete to remove items, LV_Add to add new ones and then LV_Modify to sort.

Listviews do not respond to GuiControl Commands.
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
garry



Joined: 19 Apr 2005
Posts: 1186
Location: switzerland

PostPosted: Mon Nov 05, 2007 5:07 pm    Post subject: Reply with quote

example:
Code:
Gui, Add, ListView, vLiveQueueList x5 y5 w200 h350 gLiveList, Live Queue
Gui, Show, NoActivate

folderdir = C:\test\
fileext = *
settimer,aaa,5000

LB:
LV_Delete()
Loop, %folderdir%*.%fileext%
   LV_Add("", A_LoopFileName)
return

aaa:
gosub,LB
return
;.....
Back to top
View user's profile Send private message
icefreez



Joined: 15 May 2007
Posts: 39

PostPosted: Mon Nov 05, 2007 5:35 pm    Post subject: Reply with quote

This method does exactly what my script does. If you have alot of files in that directory it refreshes after the set time. This dumps the data from the listview and repopulates it causing the GUI to flicker if you have alot of files or have enough files to make a scroll bar show.

I am trying to get it so that it updates the data with out dumping all the data out of the listview. Optimally I would like it to just modify line by line with the updated data.

The problem I am having is that the number of files in this directory is always changing so I cay assume I will always have a set number of rows to modify. Sometimes I will have 20 sometimes I will have 0.
Back to top
View user's profile Send private message
garry



Joined: 19 Apr 2005
Posts: 1186
Location: switzerland

PostPosted: Mon Nov 05, 2007 5:44 pm    Post subject: Reply with quote

maybe try a loop with filegettime and show all new modificated ?
FileGetTime, OutputVar [, Filename, WhichTime]
whichTime:
M = Modification time (this is the default if the parameter is omitted)
C = Creation time
A = Last access time
Back to top
View user's profile Send private message
icefreez



Joined: 15 May 2007
Posts: 39

PostPosted: Wed Nov 07, 2007 4:33 pm    Post subject: Reply with quote

Well the modified times are not always a method I can use to determine if new files have been added or removed so I devised a simple work around.

Before doing a listview wipe and repopulate I check the number of files in the directory and compare it to the number of files in the directory upon last check. This ensures that it only refreshes when new files enter the directory.
Back to top
View user's profile Send private message
icefreez



Joined: 15 May 2007
Posts: 39

PostPosted: Wed Feb 27, 2008 5:44 pm    Post subject: Reply with quote

Just incase anyone searches for this post in the future I came up with a simpler way to check for file changes to a directory. Simply loop through the folder and store all file names in one long variable. When you loop through again you compair teh two variables. this tells if a file has been renamed, or the contents of the folder has been updated.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group