AutoHotkey Community

It is currently May 25th, 2012, 11:32 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: Searching in Listview
PostPosted: February 3rd, 2008, 5:22 pm 
Offline

Joined: June 17th, 2007, 7:45 pm
Posts: 161
Location: C:\
I have a gui with a listview that contains a big list of movies
added in this way : LV_Add("Text" ,"Hitman") for example
have sorted the alphabetically but it doesnt help me much anymore because the list has become too big
is there a way to search a movie name for example in the list?

_________________
Signature oO


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2008, 6:33 pm 
Offline

Joined: September 1st, 2007, 8:56 pm
Posts: 120
Here's what I recommend: type the movies into a .txt file.

Once typed, FileReadLine the whole thing and add those values into a string, delimited by a |. Create the GUI and add the Listbox, blah blah, but this time, at the top, create an edit box.
Each time the user enters a new value into the edit box (this is checked with GUI, Add, Edit, gEdit) have the gosub (labeled Edit:) retrieve the information from that, lparse through the string, and check if the entered text is contained within that string. If it is, add it to the List.

NOTE: ListView does not support dynamic information readjustment. Please consider the use of a ListBox instead, as it is not only much more simplistic but can be managed very quickly.

If you need me to create a quick example, I will, but I hope you can figure it out on your own.

Have fun.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2008, 6:56 pm 
Offline

Joined: April 19th, 2005, 10:26 am
Posts: 2249
Location: switzerland
here an example ( search in all 5 columns the variable AL )
Code:
Gui,1:Add,Edit,x10  y10 w200 h20           vAL,
.........
return

SEARCH:
Gui,1:Submit,nohide
Gui,1:Listview,A1
if AL=
   return

LV_Delete()
I=0
loop,read,c:\test.txt
  {
 ifinstring,A_LOOPREADLINE,%AL%
       {
     I++
     LR=%A_loopreadline%
     B1=
     B2=
     B3=
     B4=
     B5=
     stringsplit,B,LR,`;,
     LV_Add("",B1,B2,B3,B4,B5)
       }
  }
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2008, 7:25 pm 
Offline

Joined: January 18th, 2006, 7:39 am
Posts: 274
Location: Conway, Arkansas
Democratus wrote:
NOTE: ListView does not support dynamic information readjustment.


In what way do you mean? I can dynamically manipulate a Listview with all manner of data.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2008, 8:22 pm 
Offline

Joined: September 1st, 2007, 8:56 pm
Posts: 120
I've reread through the manual on the topic of ListViews, and I have no idea how I came under the impression that they were limited in that respect. Thank you for pointing this out, skwire.

Please negate my prior statement.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2008, 8:34 pm 
Offline

Joined: January 18th, 2006, 7:39 am
Posts: 274
Location: Conway, Arkansas
Democratus wrote:
I've reread through the manual on the topic of ListViews, and I have no idea how I came under the impression that they were limited in that respect.


Yep, they're most flexible control available in AHK (IMHO). =]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 4th, 2008, 12:11 am 
Offline

Joined: June 17th, 2007, 7:45 pm
Posts: 161
Location: C:\
thanks for your help Democratus but i would like to have it in the same file
because retyping the huge movie list would be a pain

_________________
Signature oO


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 4th, 2008, 12:37 am 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
Alekoz wrote:
retyping the huge movie list would be a pain


Can you post the code ?

Might be of some relevance: http://www.autohotkey.com/forum/viewtop ... 4981#94981

:)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 4th, 2008, 6:54 am 
Offline

Joined: May 10th, 2007, 2:52 am
Posts: 194
Location: China/ Canada
It would be recommended to output information to a file instead. However, if you would like to search ListView, try
Code:
Gui, Add, ListView, r20 w700 -Multi, Name|Size (KB)
Loop, %A_WorkingDir%\*.*
 LV_Add("", A_LoopFileName, A_LoopFileSizeKB)
LV_ModifyCol()  ; Auto-size each column to fit its contents.
Gui, Add, Edit, section vSearchText
Gui, Add, Button, ys gSearchTest, Search Test
Gui, Show
return

SearchTest:
SearchRec0 = 0
SearchRec1 := LV_GetCount()
SearchCheck = 0
CheckStatus = 1
GuiControlGet, SearchText
SearchCheck := Round((SearchCheck + SearchRec1) / 2)
Loop
{
 LV_GetText(TextCheck, SearchCheck)
 If (SearchText < TextCheck)
  SearchRec1 := SearchCheck
 Else if (SearchText > TextCheck)
  SearchRec0 := SearchCheck
 SearchCheck := Round((SearchRec0 + SearchRec1) / 2)
 If (TextCheck = SearchText)
  break
 Else if (SearchRec1 = SearchRec0)
  break
 Else if (SearchRec1 - SearchRec0 = 1)
 {
  If CheckStatus = 0
   break
  CheckStatus -= 1
 }
}
LV_Modify(SearchCheck, "+Focus")
ControlClick, SysListView321, A
ControlSend, SysListView321, {Down}{Up}, ahk_class AutoHotkeyGUI
return

_________________
Sakurako ^_^


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 5th, 2008, 5:29 pm 
Offline

Joined: June 17th, 2007, 7:45 pm
Posts: 161
Location: C:\
Sakurako wrote:
It would be recommended to output information to a file instead. However, if you would like to search ListView, try
Code:
Gui, Add, ListView, r20 w700 -Multi, Name|Size (KB)
Loop, %A_WorkingDir%\*.*
 LV_Add("", A_LoopFileName, A_LoopFileSizeKB)
LV_ModifyCol()  ; Auto-size each column to fit its contents.
Gui, Add, Edit, section vSearchText
Gui, Add, Button, ys gSearchTest, Search Test
Gui, Show
return

SearchTest:
SearchRec0 = 0
SearchRec1 := LV_GetCount()
SearchCheck = 0
CheckStatus = 1
GuiControlGet, SearchText
SearchCheck := Round((SearchCheck + SearchRec1) / 2)
Loop
{
 LV_GetText(TextCheck, SearchCheck)
 If (SearchText < TextCheck)
  SearchRec1 := SearchCheck
 Else if (SearchText > TextCheck)
  SearchRec0 := SearchCheck
 SearchCheck := Round((SearchRec0 + SearchRec1) / 2)
 If (TextCheck = SearchText)
  break
 Else if (SearchRec1 = SearchRec0)
  break
 Else if (SearchRec1 - SearchRec0 = 1)
 {
  If CheckStatus = 0
   break
  CheckStatus -= 1
 }
}
LV_Modify(SearchCheck, "+Focus")
ControlClick, SysListView321, A
ControlSend, SysListView321, {Down}{Up}, ahk_class AutoHotkeyGUI
return


this works good on this script
but it didnt when i added it to mine...it just selected random names

_________________
Signature oO


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 7th, 2008, 12:34 pm 
Offline

Joined: May 10th, 2007, 2:52 am
Posts: 194
Location: China/ Canada
Specify column number after SearchCheck in LV_GetText() ~
Export ListView:
Code:
Progress, A B1 T
Num0 := LV_GetCount("Column") * LV_GetCount()
Num_Mod := Floor(Num0 * 0.01)
NumCheck = 0
ListViewCheck =
Loop % LV_GetCount("Column")
{
 ColumnNum := A_Index
 LV_GetText(ColumnName, "0", A_Index)
 ColumnNameCheck =
 Loop, Parse, ColumnName
  If A_LoopField is alnum
   ColumnNameCheck .= A_LoopField
  Else
   ColumnNameCheck .= "_"
 ColumnName := ColumnNameCheck "_"
 Loop % LV_GetCount()
 {
  NumCheck += 1
  LV_GetText(TextCheck, A_Index, ColumnNum)
  ListViewCheck .= ColumnName A_Index " = " TextCheck "`n"
  If Mod(NumCheck, Num_Mod) = 0
   Progress, % NumCheck / Num0 * 100
 }
}
Progress, Off
TimeCheck := A_Now
FileAppend, %ListViewCheck%, ListViewCheck%TimeCheck%.txt
Run, ListViewCheck%TimeCheck%.txt
ListViewCheck =
return

_________________
Sakurako ^_^


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Bravo to Sakurako
PostPosted: April 17th, 2008, 12:52 pm 
Offline

Joined: October 27th, 2006, 11:35 am
Posts: 5
Location: BELGIUM
Sakurako...For your SCRIPT about ListView :
Posted: Thu Feb 07, 2008 1:34 pm

Bye from BELGIUM (french language).
:roll:

_________________
lucgod1 (LIEGE - BELGIUM)


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, LazyMan, Yahoo [Bot] and 72 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group