I think that's this is nearly a standard solution, so maybe there exists some plug&play script?
- Read a predefined text-file
- search all strings containing *mysearch*
- list them to user
- user clicks to input/paste it
If a code like this exists I would be happy for a hint/link
Peter
Simple text search from text-file?
Simple text search from text-file?
Peter (AHK Beginner) / Win 10 x64, AHK Version v1.1.33
Re: Simple text search from text-file?
Untested!
Code: Select all
FilePath := "complete path to the string-containing file goes here"
^a::
InputBox, SearchString, , % "Input string to search."
ResultList := []
ChosenString := ""
Loop, Read, %FilePath%
if (InStr(A_LoopReadLine, SearchString))
ResultList.Push(A_LoopReadLine)
if (!ResultList.Length)
{
MsgBox % "No match found!"
return
}
Gui, DisplayResults:New
Gui, Add, Text, , % "Click on a line to select it."
for key, value in ResultList
{
if (key = 1)
Gui, Add, Radio, gSelectResult vChosenString, %value%
else
Gui, Add, Radio, gSelectResult, %value%
Gui, DisplayResults:Show
return
SelectResult:
Gui, DisplayResults:Submit
Send % ResultList[ChosenString]
return
Re: Simple text search from text-file?
Great-thanks. Here is the tested version.
Code: Select all
FilePath := "complete path to the string-containing file goes here"
^a::
InputBox, SearchString, , % "Input string to search."
ResultList := []
ChosenString := ""
Loop, Read, %FilePath%
{
if (InStr(A_LoopReadLine, SearchString))
{
ResultList.Push(A_LoopReadLine)
}
}
if (!ResultList.Length())
{
MsgBox % "No match found!"
return
}
Gui, DisplayResults:New,-MaximizeBox -MinimizeBox , Search results
Gui, Add, Text, w250, % "Click on a line to select and type it."
for key, value in ResultList
{
if (key = 1)
Gui, Add, Radio, gSelectResult vChosenString, %value%
else
Gui, Add, Radio, gSelectResult, %value%
}
Gui, DisplayResults:Show
return
SelectResult:
Gui, DisplayResults:Submit
Send % ResultList[ChosenString]
return
Peter (AHK Beginner) / Win 10 x64, AHK Version v1.1.33
Re: Simple text search from text-file?
Glad that worked for you, it was pretty much off the top of my head.
Re: Simple text search from text-file?
There must be a lot of AHK in it ...MaxAstro wrote:... off the top of my head.
Peter (AHK Beginner) / Win 10 x64, AHK Version v1.1.33
Re: Simple text search from text-file?
What would the script look like if they referred to the text string that would be in the script?
Thank you!
Thank you!
Who is online
Users browsing this forum: OrangeCat and 293 guests