 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Alekoz
Joined: 17 Jun 2007 Posts: 157
|
Posted: Sun Feb 03, 2008 5:22 pm Post subject: Searching in Listview |
|
|
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? _________________ My BF2 Scripts |
|
| Back to top |
|
 |
Democratus
Joined: 01 Sep 2007 Posts: 120
|
Posted: Sun Feb 03, 2008 6:33 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
garry
Joined: 19 Apr 2005 Posts: 1035 Location: switzerland
|
Posted: Sun Feb 03, 2008 6:56 pm Post subject: |
|
|
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
|
|
|
| Back to top |
|
 |
skwire
Joined: 18 Jan 2006 Posts: 132 Location: Conway, Arkansas
|
Posted: Sun Feb 03, 2008 7:25 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
Democratus
Joined: 01 Sep 2007 Posts: 120
|
Posted: Sun Feb 03, 2008 8:22 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
skwire
Joined: 18 Jan 2006 Posts: 132 Location: Conway, Arkansas
|
Posted: Sun Feb 03, 2008 8:34 pm Post subject: |
|
|
| 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). =] |
|
| Back to top |
|
 |
Alekoz
Joined: 17 Jun 2007 Posts: 157
|
Posted: Mon Feb 04, 2008 12:11 am Post subject: |
|
|
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 _________________ My BF2 Scripts |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5890
|
|
| Back to top |
|
 |
Sakurako
Joined: 10 May 2007 Posts: 142
|
Posted: Mon Feb 04, 2008 6:54 am Post subject: |
|
|
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 |
_________________
|
|
| Back to top |
|
 |
Alekoz
Joined: 17 Jun 2007 Posts: 157
|
Posted: Tue Feb 05, 2008 5:29 pm Post subject: |
|
|
| 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 _________________ My BF2 Scripts |
|
| Back to top |
|
 |
Sakurako
Joined: 10 May 2007 Posts: 142
|
Posted: Thu Feb 07, 2008 12:34 pm Post subject: |
|
|
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 |
_________________
|
|
| Back to top |
|
 |
lucgod1
Joined: 27 Oct 2006 Posts: 3 Location: BELGIUM
|
Posted: Thu Apr 17, 2008 12:52 pm Post subject: Bravo to Sakurako |
|
|
Sakurako...For your SCRIPT about ListView :
Posted: Thu Feb 07, 2008 1:34 pm
Bye from BELGIUM (french language).
 _________________ lucgod1 (LIEGE - BELGIUM) |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|