I have the following folders on my desktop:
Aaronwinston
Ablebot
Applebottom
Axium
I want to be able to type the first couple letters of the folder name into an inputbox and have folder name be known.
If I type "Able" then I want "Ablebot" to be stored as a variable
If I type "Ap" then I want "Applebottom" to be stored as a variable
If I type "Apple" then I want "Applebottom" to be stored as a variable
Obtain folder location based on inputbox entry
Started by
Xx7
, Nov 20 2011 07:02 PM
9 replies to this topic
#1
Posted 20 November 2011 - 07:02 PM
#2
Posted 20 November 2011 - 08:12 PM
An idea:
+s:: inputbox, V, Folder,,,128,128 If (V="Able") V := "Ablebot" msgbox, %V% return
#3
Posted 20 November 2011 - 08:33 PM
Thanks, but I'm going to have 100's of folders, so it would be inefficient to define each one.
I can use this to easily do it through menu commands, but I want to obtain the file name as a variable, so I can go directly to it instead of using menu commands.
I can use this to easily do it through menu commands, but I want to obtain the file name as a variable, so I can go directly to it instead of using menu commands.
Run, C:\Desktop
Sleep, 500
Send, {Tab}%V%
Send, {enter}{enter}
#4
Posted 20 November 2011 - 09:03 PM
-_-;
#5
Posted 20 November 2011 - 09:17 PM
InputBox, what
Loop %A_Desktop%\%what%*
, 1
{
MsgBox % A_LoopFileName
break
} :?:
#6
Posted 21 November 2011 - 12:01 AM
This does not sound exactly like what you are wanting but you may find it useful.
<!-- m -->http://portableapps....istary_portable<!-- m -->
Sometimes there already is an app for that. 8)
<!-- m -->http://portableapps....istary_portable<!-- m -->
Sometimes there already is an app for that. 8)
#7
Posted 21 November 2011 - 01:02 AM
And sometimes there is already an operating system for that.
<!-- m -->http://vvcap.net/db/...9zvS7oQ5AZp.htp<!-- m -->
An alternative script if there is multiple matches and run the folder when you hit enter:
<!-- m -->http://vvcap.net/db/...9zvS7oQ5AZp.htp<!-- m -->
An alternative script if there is multiple matches and run the folder when you hit enter:
/*
Notes:
*Hit enter to run the selected folder
*New folders can be selected to search in
*/
#SingleInstance, Force ; Beginning Preferences
SetBatchLines, -1 ; Faster script speeds
; ############### MAIN GUI ########################
Gui, Add, Edit, vMyEdit1 gMatchFolders,
Gui, Add, ListBox, r10 vListBox1,
Gui, Add, Button, Default Hidden gGetFolder,
Gui, Add, Text,, Folder to search in:
Gui, Add, Edit, vSearchFolder ReadOnly, %A_Desktop% ; Start with desktop
gui, add, Button, ys gSelectfolderlocation y220, ...
Loop, %A_Desktop%\*, 2 ; Gets a list of your desktop folders and adds them to the variable later added to the Listbox
{
If (!DFolderList)
DFolderList := A_LoopFileName "|"
else
DFolderList := DFolderList A_LoopFileName "|"
}
GuiControl,, ListBox1, |%DFolderList%
Gui, Show, Autosize, Folder Selection
return
; ############## MATCH FOLDERS TO WHAT YOU TYPE IN THE EDIT FIELD ################ NOTE: CASE INSENITIVE MATCHING
MatchFolders:
Gui, Submit, Nohide ; Submits GUI
DFolderList := RegExReplace(DFolderList, "\|\|", "|") ; Start off with no selections
If (RegExMatch(DFolderList, "i)" MyEdit1)) ; Check for your selection
{
DFolderList := ""
Loop, %SearchFolder%\%MyEdit1%*, 2 ; Replace list with one that matches the folders
{
If (!DFolderList)
DFolderList := A_LoopFileName "||"
else
DFolderList := DFolderList A_LoopFileName "|"
}
GuiControl,, ListBox1, |%DFolderList% ; Replace with the new selection
}
Else ;If (!RegExMatch(DFolderList, "i)" MyEdit1))
{
ToolTip, Folder not found.
SetTimer, ToolTipOff, -2000
}
FoundMatchFlag := ""
FoundPos := "" ; Clear found position
return
Selectfolderlocation: ; Selects a new folder location
FileSelectFolder, SearchFolderReplacement,,, Select folder to search within
GuiControl,, SearchFolder, %SearchFolderReplacement%
GuiControl,, ListBox1, ; Clear search content
Goto, MatchFolders ; To update the list
return
GetFolder: ; Enter to Run the highlighted folder
Gui, Submit, NoHide
Loop, %SearchFolder%\*, 2
{
If (A_LoopFileName = ListBox1)
Run, %A_LoopFileFullPath%
}
return
ToolTipOff: ; Turns off the tooltip if needed
ToolTip
return
GuiClose: ; Close GUI
ExitApp
#8
Posted 26 November 2011 - 06:57 PM
Great, thanks alot!
Nimda, I used your code.
. Jpjazzy, that is very useful... will use in the future!
Nimda, I used your code.
^!t::
;Type single digit year, then " ", then first few letters of company
;Eg. "9 Box" will open folder C:\Users\BD\Desktop\Folder\B\Boxite\2009
InputBox, SearchTerm
StringLeft, Year1, SearchTerm, 1 ;First char is var Year1
StringTrimLeft, Company1, SearchTerm, 2 ;Third char on is name of Company1
StringLeft, FirstLetter1, Company1, 1 ;First letter of Company1 needed for folders
;-----Search for the full company name in the folder-----
Loop C:\Users\BD\Desktop\Folder\%FirstLetter1%\%Company1%*
, 1
{
Company1 = % A_LoopFileName ;changes abreviated company to FULL name
break
}
;-----Changes 8 into 2008, 9 into 2009... etc.------
if (Year1 = 8)
{
Year1 := 2008
}
else if (Year1 = 9)
{
Year1 := 2009
}
else if (Year1 = 0)
{
Year1 := 2010
}
else if (Year1 = 1)
{
Year1 := 2011
}
;-------------------------------------------------------
Run C:\Users\BD\Desktop\Folder\%FirstLetter1%\%Company1%\%Year1%
Return
#9
Posted 26 November 2011 - 08:10 PM
Thanks for sharing. :-]
#10
Posted 26 November 2011 - 08:27 PM
Though your code will function on your specific pc, it is always better to use variable paths whenever possible as they are more reliable and they are a lot shorter than your path. In your run path towards the end you could use A_desktop rather than an absolute path. Just good programming technique to get in the habbit of.




