Jump to content

Help with search function


Recommended Posts

Hey guys...I have once again been stumped, and I need your help. There hasn't been anything thus far that you guys haven't been able to solve. You guys are great. But anyways, the problem that I am having is with a search function that I am doing with a GUI program that I am building. I am having the user enter a specified directory in one inputbox, and then in another inputbox, I have them enter a search term. I am displaying the results of the search in a list within m GUI. So basically I am searching for

($searchDirectory & $searchItem & ".*"). It returns fine to the list if what the user entered is directly in that directory. Say if the user entered test, it will search in that directory for test.*, and return anything that has the filename test, but it won't return anything other than that with test in the name such as test_1, test_2, test1. Is there something that I am missing to be able to search within the filename as well as the entire filename? Thanks in advance guys.

Link to comment
Share on other sites

  • Moderators

Maybe try StringInString($FileName, $SearchItem)...

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Okay, phew...so I'm pretty sure I finally go that all settled out. And now...I have another problem... :D . Well, it isn't necessarily a problem. It is more something I would like to implement. I have the search that returns the results to a list. That works fine...but I was wondering if there was any way that I could maybe double click on one of the results to open the file up or maybe say if it was music, drag it over to Windows Media Player to play it. Is there any possibility of this? Thanks in advance.

Link to comment
Share on other sites

Okay, phew...so I'm pretty sure I finally go that all settled out. And now...I have another problem... :whistle: . Well, it isn't necessarily a problem. It is more something I would like to implement. I have the search that returns the results to a list. That works fine...but I was wondering if there was any way that I could maybe double click on one of the results to open the file up or maybe say if it was music, drag it over to Windows Media Player to play it. Is there any possibility of this? Thanks in advance.

Yes, this is all possible. Look at MouseClick & MouseClickDrag. Plus, there are plenty of ways to accomplish what you want without simulating mouse movements.

bump

You never said if Smoke's suggestion worked for you, so the casual observer may be led to believe you just ignored his helpful post.

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Link to comment
Share on other sites

I'm sorry...I didn't mean to neglect my response to Smoke. But yeah...I used a variation of StringInStr and it worked great....as far as I know. I have tried some things that you mentioned Skruge, but I haven't been able to really get anything productive to come out of it. If you were in a situation like this...what avenue would you take to tackle this? Thanks again guys.

Link to comment
Share on other sites

Something like this? (Needs beta)

#NoTrayIcon
#include <file.au3>
#include <array.au3>
#include <GUIConstants.au3>

Global Const $WM_COMMAND = 0x0111
Global Const $LBN_SELCHANGE = 1
Global Const $LBN_DBLCLK = 2

Local $SearchPath, $FileList, $FileFilter

$Form1 = GUICreate("File Browser", @DesktopWidth / 4, @DesktopHeight / 4, @DesktopWidth / 6, @DesktopHeight / 6, -1, $WS_EX_TOOLWINDOW)
$List1 = GUICtrlCreateList("", 0, 0, @DesktopWidth / 4, @DesktopHeight / 4, -1, $WS_EX_CLIENTEDGE)
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")

$SearchPath = FileSelectFolder("Select a folder to search", Default, 2 + 4, @DesktopDir)
If @error Then Exit
$FileFilter = InputBox("Enter your search filter", "Use Wildcards", "*.*")
If @error Then Exit
$FileList = _FileListToArray($SearchPath, $FileFilter, 1)
If @error Then Exit
GUICtrlSetData($List1, _ArrayToString($FileList, "|", 1, $FileList[0]))

GUISetState(@SW_SHOW)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
            ;;;;;;;
    EndSelect
WEnd

Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    $nNotifyCode = BitShift($wParam, 16)
    $nID = BitAND($wParam, 0x0000FFFF)
    $hCtrl = $lParam
    If $nID = $List1 Then
        Switch $nNotifyCode
            Case $LBN_DBLCLK
                Run(@ComSpec & ' /c Start "" "' & $SearchPath & "\" & GUICtrlRead($List1) & '"', $SearchPath, @SW_HIDE)
        EndSwitch
    EndIf
EndFunc   ;==>MY_WM_COMMAND

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

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