veda2010 Posted July 21, 2015 Share Posted July 21, 2015 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 Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 21, 2015 Moderators Share Posted July 21, 2015 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 NextI 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. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
veda2010 Posted July 21, 2015 Author Share Posted July 21, 2015 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. Not 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 WEndGUIDelete() it throws some error messageLine8: (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", ^ERRORError: Variable used without being declared. ThanksVeda Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 21, 2015 Moderators Share Posted July 21, 2015 What version of AutoIt are you using? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
veda2010 Posted July 21, 2015 Author Share Posted July 21, 2015 I'm using 3.3.12.0 Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted July 21, 2015 Share Posted July 21, 2015 (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_FILESYou need to #include FileConstants.au3 Edited July 21, 2015 by ViciousXUSMC Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now