Sign in to follow this  
Followers 0
veda2010

Looking for App to search a file in the specific directory and open

6 posts in this topic

Hello Everyone,

 

This is Veda, First of all, i'm not familiar with AutoIt tool. I just use help and google it to create some code to ease my daily work.

Can anyone help me to create a custom GUI to search a file in a directory and then open it? I know, that we do in windows search but the problem is, the directory in which i need to search is located in other location. So, i usually map the drives and go to each folder to find the file which i'm looking for. It will take a while to search using windows search.

Thanks in advance !!!

I hope, i will try to learn Autoit and help others too.

 

Thanks 

Veda

Share this post


Link to post
Share on other sites



So you want to create a GUI, search for a file in a network location, and then open it. I would start with the following:

basic template for a GUI:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

GUICreate("Test", 300, 300)
GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

GUIDelete()

You didn't explain how you want to search for the file (is the user going to input the name, or are you going to have it already in the script?) Either way, you can read all the files in that directory to an array, and then open the file if it exists:

#include <File.au3>

Local $aFiles = _FileListToArray("\\server\share\folder", "*.doc", $FLTA_FILES, True)
    For $i = 1 To $aFiles[0]
        If StringInStr($aFiles[$i], "Name of my file") Then
            ;do stuff here
        EndIf
    Next

I would start with this, try it out on your own and try to modify it to your needs. Then come back if you run into issues, and post what you have done.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Thanks for the quick response JLogan3o13.

I am looking for something like a window where we can put the file name to search and then it shows the file in the. click to open the file or something.

I tried the below mentioned code.  :DNot sure whether i copied the code correctly  or not 

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <File.au3>

GUICreate("Test", 300, 300)
GUISetState(@SW_SHOW)

Local $aFiles = _FileListToArray("C:\Users\Veda\Documents\", "*.xlsx", $FLTA_FILES, True)
    For $i = 1 To $aFiles[0]
        If StringInStr($aFiles[$i], "Testing") Then
            ;do stuff here
        EndIf
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

GUIDelete()

 

 it throws some error message

Line8: (File ""C:\Users\Veda\Documents\Search.au3")

Local $aFiles=

_FileListToArray("C:\Users\Veda\Documents\", "*.xlsx", $FLTA_FILES, True)

Local $aFile =

_FileListToArray("C:\Users\Veda\Documents\", "*.xlsx", ^ERROR

Error: Variable used without being declared.

 

Thanks

Veda 

 

Share this post


Link to post
Share on other sites

What version of AutoIt are you using?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

I'm using 3.3.12.0

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Id probably build a GUI with a combobox that drops down with your search location selection.  This box would be populated from a .txt file (others may prefer .ini files) so this way you can update your search locations without changing your script only the text file.  Next would be an inputbox to type the name of the file your looking for.  Finally a button to execute the search and preform the desired tasks.

The error your seeing is saying that you have no value declared for the constant $FLTA_FILES

You need to #include FileConstants.au3

Edited by ViciousXUSMC

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  
Followers 0